Skip to content

build: try not persisting default github token #416

build: try not persisting default github token

build: try not persisting default github token #416

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 --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