forked from equinor/webviz-subsurface-components
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (116 loc) · 4.68 KB
/
typescript.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
133
134
135
136
137
138
139
140
141
142
143
144
145
name: webviz-subsurface-components
defaults:
run:
working-directory: ./typescript
on:
push:
pull_request:
branches:
- master
release:
types:
- published
schedule:
# Run CI daily and check that tests are working with latest dependencies
- cron: "0 0 * * *"
jobs:
typescript:
# Run on all events defined above, except pushes which are not to master
if: github.event_name != 'push' || github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: 📖 Checkout commit locally
uses: actions/checkout@v3
- name: 🐍 Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: 📦 Install build dependencies
run: |
# In https://github.com/equinor/webviz-subsurface-components/pull/1010 we
# loosened up npm constraint to include npm version using lockfileVersion: 1
# for downstream users. However in the development of this repository we
# want to limit ourselves to lockfileVersion: 3.
# While waiting for dropping node 14 and npm 6 support, we include this manual
# check:
grep -q '"lockfileVersion": 3,' ./package-lock.json
npm ci CYPRESS_INSTALL_BINARY=0 --ignore-scripts
- name: ⏭️ Modifications when prerelease
if: github.event.release.prerelease
run: echo "NPM_PUBLISH_TAG=next" >> $GITHUB_ENV
- name: 🏗️ Build JavaScript part
run: |
npx nx run-many -t build
- name: 🕵️ Check code style, linting and typechecking
run: |
npm run validate
- name: 🤖 Run correctness tests
if: github.event_name != 'release' # Related to https://github.com/equinor/webviz-subsurface-components/issues/409
run: |
npx nx run-many -t test_correctness
- name: 🔼 Build and publish Node.js package
if: github.event_name == 'release'
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
# Parse mono-repo tag (git tag format: "package@version")
echo ${{ github.ref_name }}
PACKAGE=`python -c "tag='${{ github.ref_name }}'; print(tag.split('@')[0])"`
VERSION=`python -c "tag='${{ github.ref_name }}'; print(tag.split('@')[1])"`
npm config set '//registry.npmjs.org/:_authToken' '${NPM_TOKEN}'
cd packages/${PACKAGE}
npm version --allow-same-version --no-git-tag-version ${VERSION}
# Use 'latest' tag if $NPM_PUBLISH_TAG is not set:
npm publish --access public --tag ${NPM_PUBLISH_TAG:-latest}
- name: 📚 Build Storybook
run: npm run build-storybook
- name: 📚 Update Storybook
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
rm -rf ../../storybook-static
mv ./storybook-static ../..
git config --local user.email "webviz-github-action"
git config --local user.name "webviz-github-action"
git fetch origin gh-pages
git checkout --track origin/gh-pages
git clean -f -f -d -x
git rm -r --ignore-unmatch ../*
mv ../../storybook-static ..
git add ../storybook-static
if git diff-index --quiet HEAD; then
echo "No changes in documentation. Skip documentation deploy."
else
git commit -m "Update Github Pages"
git push "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" gh-pages
fi
smoke_tests:
# Run on all events defined above, except pushes which are not to master
if: github.event_name != 'push' || github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
name: "Storybook Smoke Tests"
container:
image: mcr.microsoft.com/playwright:v1.39.0-jammy
options: --user 1001
steps:
- name: 📖 Checkout commit locally
uses: actions/checkout@v3
- name: 📦 Install build dependencies
run: |
npm ci CYPRESS_INSTALL_BINARY=0 --ignore-scripts
- name: 🏗️ Build packages
run: |
npx nx run-many -t build
- name: 📚 Build Storybook
run: npm run build-storybook
- name: Run smoke tests
env:
PORT: 8080
HOST: 127.0.0.1
run: |
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
"npx http-server storybook-static --port $PORT -a $HOST" \
"npx wait-on http://$HOST:$PORT/ && npm run storybook:test -- --ci --url http://$HOST:$PORT/"