forked from equinor/webviz-subsurface-components
-
Notifications
You must be signed in to change notification settings - Fork 0
251 lines (218 loc) · 10.3 KB
/
webviz-subsurface-components.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: webviz-subsurface-components
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:
webviz-subsurface-components:
# Run on all events defined above, except pushes which are neither to master nor with a substring [deploy test] in commit message
if: github.event_name != 'push' || github.ref == 'refs/heads/master' || contains(github.event.head_commit.message, '[deploy test]')
runs-on: ubuntu-latest
strategy:
matrix:
include:
- python-version: "3.8"
run-performance-tests: false
- python-version: "3.9"
run-performance-tests: false
- python-version: "3.10"
run-performance-tests: false
- python-version: "3.10" # This particular job in the matrix is allowed to fail(for performance and cypress test)
run-performance-tests: true
e2e-tests: true
steps:
- name: 📖 Checkout commit locally
uses: actions/checkout@v3
- name: 🐍 Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: 📦 Install build dependencies
# The deckgl types package runs a postscript to setup, but since we ignore scripts, we need to set it up manually.
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,' ./typescript/package-lock.json
npm ci CYPRESS_INSTALL_BINARY=0 --ignore-scripts --prefix ./typescript
# cd python
# pip install "werkzeug<2.1" # ...while waiting for https://github.com/plotly/dash/issues/1992
# pip install "dash<2.5" # Build issue upstream in dash==2.5
# pip install "flask<2.3" # As we are using an old Dash version we need to use an older Flask version
# pip install .[dependencies]
# pip install dash[dev]
# cd ..
- name: ⏭️ Modifications when prerelease
if: github.event.release.prerelease
run: echo "NPM_PUBLISH_TAG=next" >> $GITHUB_ENV
- name: 🏗️ Build JavaScript part
working-directory: ./typescript
run: |
npx nx run-many -t build
# - name: 📦 Install webviz-subsurface-components with dependencies
# working-directory: ./python
# run: |
# pip install --upgrade pip
# pip install .
# - name: 📦 Install test dependencies
# working-directory: ./python
# run: |
# pip install .[tests]
# wget https://chromedriver.storage.googleapis.com/$(wget https://chromedriver.storage.googleapis.com/LATEST_RELEASE -q -O -)/chromedriver_linux64.zip
# unzip chromedriver_linux64.zip
# - name: 🧾 List all installed packages
# run: pip freeze
- name: 🕵️ Check code style, linting and typechecking
if: matrix.python-version == '3.8'
run: |
npm run validate --prefix ./typescript
# cd ./python
# black --check webviz_subsurface_components/ tests/ setup.py examples/
# pylint webviz_subsurface_components/ setup.py
# bandit -r -c ./bandit.yml webviz_subsurface_components/ tests/ setup.py examples/
# cd ..
# - name: 🤖 Run performance tests
# if: github.event_name != 'release' && matrix.run-performance-tests
# working-directory: ./typescript
# run: |
# npx nx run-many -t test_perf
- name: 🤖 Run correctness tests
if: github.event_name != 'release' # Related to https://github.com/equinor/webviz-subsurface-components/issues/409
working-directory: ./typescript
run: |
npx nx run-many -t test_correctness
# - name: 🤖 Run python tests
# if: github.event_name != 'release' # Related to https://github.com/equinor/webviz-subsurface-components/issues/409
# working-directory: ./python
# run: pytest ./tests --headless
# # This action allows caching cypress dependencies
# - name: Cache Cypress
# if: github.event_name != 'release' && matrix.e2e-tests
# id: cache-cypress
# uses: actions/cache@v3
# with:
# # list of files to cache and restore
# path: ~/.cache/Cypress
# # An explicit key for restoring and saving the cache
# key: cypress-cache-v2-${{ runner.os }}-${{ hashFiles('**/package.json') }}
# # now let's install Cypress binary
# - name: install cypress binary
# if: github.event_name != 'release' && matrix.e2e-tests
# working-directory: ./typescript
# run: npx cypress install
# # run the cypress tests
# - name: e2e on firefox
# if: github.event_name != 'release' && matrix.e2e-tests
# run: |
# mkdir clone
# cd clone
# git clone --branch cypress-snaps --depth 1 --filter=blob:none https://github.com/equinor/webviz-subsurface-components
# cd webviz-subsurface-components
# git sparse-checkout set typescript/cypress-visual-screenshots
# cd typescript
# mv * ../../../typescript/
# cd ../../../
# rm -rf clone
# cd typescript
# npx cypress run -b chrome --component --headed
# # upload the failure screenshots for reference
# - name: upload artifacts
# uses: actions/upload-artifact@v2
# if: github.event_name != 'release' && failure() && matrix.e2e-tests
# with:
# name: cypress-screenshots
# path: |
# typescript/cypress/screenshots
# typescript/cypress-visual-screenshots
# retention-days: 5
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
- name: 🔼 Build and publish Node.js package
if: github.event_name == 'release' && matrix.python-version == '3.8'
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: ./typescript
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 and deploy Python package
# if: github.event_name == 'release' && matrix.python-version == '3.8'
# env:
# TWINE_USERNAME: __token__
# TWINE_PASSWORD: ${{ secrets.pypi_webviz_token }}
# working-directory: ./python
# run: |
# export SETUPTOOLS_SCM_PRETEND_VERSION=${GITHUB_REF//refs\/tags\//}
# python -m pip install --upgrade setuptools wheel twine
# python setup.py sdist bdist_wheel
# twine upload dist/*
# - name: 📚 Build demo application
# run: npm run build:js-demo --prefix ./typescript
- name: 📚 Build Storybook
run: npm run build-storybook --prefix ./typescript
- name: 📚 Update Storybook
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || contains(github.event.head_commit.message, '[deploy test]')) && matrix.python-version == '3.8'
run: |
cp -r ./typescript/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 .
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
# - name: prepare for automated pull request
# id: check_file_changed
# if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || contains(github.event.head_commit.message, '[deploy test]')) && matrix.python-version == '3.10' && failure()
# working-directory: ./typescript
# run: |
# if [ -d "cypress-visual-screenshots/diff" ]
# then
# echo '::set-output name=status::true'
# npx cypress-image-diff -u
# rm -rf cypress-visual-screenshots/comparison
# rm -rf cypress-visual-screenshots/diff
# rm -rf cypress/screenshots
# rm -rf cypress/videos
# else
# echo '::set-output name=status::false'
# fi
# - name: Create Pull Request
# id: cpr
# uses: peter-evans/create-pull-request@5a6b15373e5788c38d83296b674ad5abea28085c
# if: steps.check_file_changed.outputs.status == 'true' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || contains(github.event.head_commit.message, '[deploy test]')) && matrix.python-version == '3.10' && failure()
# with:
# commit-message: updated cypress snapshots
# title: Cypress - New Snapshots generated for the commit "${{ github.event.head_commit.message }}" by ${{ github.event.commits[0].author.email }}
# body: This is an auto-generated PR to update cypress snapshots.
# base: cypress-snaps
# reviewers: ${{ github.event.sender.login }}
# delete-branch: true