-
-
Notifications
You must be signed in to change notification settings - Fork 17
132 lines (113 loc) · 3.83 KB
/
ci-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# This is a basic workflow to help you get started with Actions
name: test
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the develop branch
push:
branches: [master, develop]
tags:
- "*"
pull_request:
branches: [master, develop]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
test:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Update npm and install packages
run: |
npm i -g npm@latest yarn@latest
yarn install
- name: Build packages
run: yarn babel
- name: Test with jest
run: yarn test
- name: Test with karma
run: yarn karma
- name: Install lcov and merge coverage info
run: |
sudo apt update
sudo apt install lcov
mkdir -p ./coverage
find ./packages -name lcov.info -exec echo -a {} \; | xargs lcov -o ./coverage/merged-lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: ./coverage/merged-lcov.info
webpage:
needs: test
if: ${{ (github.ref_name == 'master') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
- run: |
yarn
yarn docs
mv esdocs ~/docs
- name: Setup git
env:
WEBPAGE_REPO_DEPLOY_KEY: ${{ secrets.WEBPAGE_REPO_DEPLOY_KEY }}
run: |
echo "$WEBPAGE_REPO_DEPLOY_KEY" > ~/deploy_key.pem
chmod 600 ~/deploy_key.pem
git config --global user.email "[email protected]"
git config --global user.name "J via GitHub Actions"
- name: Update and deploy pages
env:
GIT_SSH_COMMAND: ssh -i ~/deploy_key.pem -o StrictHostKeyChecking=no -F /dev/null
run: |
mkdir -p ~/jscu-webpage
cd ~/jscu-webpage
git clone [email protected]:junkurihara/jscu-webpage.git .
rm -rf ./docs
mv ~/docs ./docs
git add .
if ! git diff --cached --quiet; then
echo 'Updated page and push via GitHub Actions'
git commit -am 'Updated page and push via GitHub Actions'
git push origin master
fi
publish:
needs: test
if: startsWith(github.event.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
# Defaults to the user or organization that owns the workflow file
scope: "@octocat"
- run: |
yarn
yarn build
bash scripts/publish.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}