webviz-subsurface #4586
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: webviz-subsurface | |
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: | |
# 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 | |
env: | |
PYTHONWARNINGS: default # We want to see e.g. DeprecationWarnings | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.8", "3.9", "3.10"] | |
steps: | |
- name: π§Ή Remove unused pre-installed software | |
run: | | |
# https://github.com/actions/virtual-environments/issues/751 | |
# https://github.com/actions/virtual-environments/issues/709 | |
sudo apt-get purge p7zip* yarn ruby-full ghc* php7* | |
sudo apt-get autoremove | |
sudo apt-get clean | |
df -h | |
- name: π Checkout commit locally | |
uses: actions/checkout@v2 | |
- name: π Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: π¦ Install webviz-subsurface with dependencies | |
run: | | |
pip install --upgrade pip | |
if [[ $(pip freeze) ]]; then | |
pip freeze | grep -vw "pip" | xargs pip uninstall -y | |
fi | |
pip install "shapely<2" | |
pip install "bleach<5" # https://github.com/equinor/webviz-config/issues/586 | |
pip install "werkzeug<2.1" # ...while waiting for https://github.com/plotly/dash/issues/1992 | |
pip install "selenium<4.3" # breaking change in selenium==4.3 | |
pip install . | |
# Testing against our latest release (including pre-releases) | |
pip install --pre --upgrade webviz-config webviz-core-components webviz-subsurface-components | |
- name: π¦ Install test dependencies | |
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 | |
export PATH=$PATH:$PWD | |
- name: π§Ύ List all installed packages | |
run: pip freeze | |
- name: π΅οΈ Check code style & linting | |
run: | | |
black --check webviz_subsurface tests setup.py | |
pylint webviz_subsurface tests setup.py | |
bandit -r -c ./bandit.yml webviz_subsurface tests setup.py | |
isort --check-only webviz_subsurface tests setup.py | |
mypy --package webviz_subsurface | |
- name: π€ Run tests | |
env: | |
# If you want the CI to (temporarily) run against your fork of the testdada, | |
# change the value her from "equinor" to your username. | |
TESTDATA_REPO_OWNER: equinor | |
# If you want the CI to (temporarily) run against another branch than master, | |
# change the value her from "master" to the relevant branch name. | |
TESTDATA_REPO_BRANCH: master | |
run: | | |
git clone --depth 1 --branch $TESTDATA_REPO_BRANCH https://github.com/$TESTDATA_REPO_OWNER/webviz-subsurface-testdata.git | |
# Copy any clientside script to the test folder before running tests | |
mkdir ./tests/assets && cp ./webviz_subsurface/_assets/js/* ./tests/assets | |
pytest ./tests --headless --forked --testdata-folder ./webviz-subsurface-testdata | |
rm -rf ./tests/assets | |
webviz docs --portable ./docs_build --skip-open | |
- name: π³ Build Docker example image | |
run: | | |
pip install --pre webviz-config-equinor | |
export SOURCE_URL_WEBVIZ_SUBSURFACE=https://github.com/$GITHUB_REPOSITORY | |
export GIT_POINTER_WEBVIZ_SUBSURFACE=$GITHUB_REF | |
webviz build ./webviz-subsurface-testdata/webviz_examples/webviz-full-demo.yml --portable ./example_subsurface_app --theme equinor | |
rm -rf ./webviz-subsurface-testdata | |
pushd example_subsurface_app | |
docker build -t webviz/example_subsurface_image:equinor-theme . | |
popd | |
- name: π³ Update Docker Hub example image | |
if: github.event_name != 'schedule' && github.ref == 'refs/heads/master' && matrix.python-version == '3.8' | |
run: | | |
echo ${{ secrets.dockerhub_webviz_token }} | docker login --username webviz --password-stdin | |
docker push webviz/example_subsurface_image:equinor-theme | |
- name: π³ Update review/test Docker example image | |
if: github.ref != 'refs/heads/master' && contains(github.event.head_commit.message, '[deploy test]') && matrix.python-version == '3.8' | |
run: | | |
docker tag webviz/example_subsurface_image:equinor-theme ${{ secrets.review_docker_registry_url }}/${{ secrets.review_container_name }} | |
echo ${{ secrets.review_docker_registry_token }} | docker login ${{ secrets.review_docker_registry_url }} --username ${{ secrets.review_docker_registry_username }} --password-stdin | |
docker push ${{ secrets.review_docker_registry_url }}/${{ secrets.review_container_name }} | |
- 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 }} | |
run: | | |
python -m pip install --upgrade setuptools wheel twine | |
python setup.py sdist bdist_wheel | |
twine upload dist/* | |
- name: π Update GitHub pages | |
if: github.event_name == 'release' && matrix.python-version == '3.8' | |
run: | | |
cp -R ./docs_build ../docs_build | |
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 * | |
cp -R ../docs_build/* . | |
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 | |
webviz-subsurface-windows: | |
# 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: windows-latest | |
env: | |
PYTHONWARNINGS: default # We want to see e.g. DeprecationWarnings | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.8"] | |
steps: | |
- name: π Checkout commit locally | |
uses: actions/checkout@v2 | |
- name: π Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: π¦ Install webviz-subsurface with dependencies | |
run: | | |
pip install --upgrade pip | |
pip install "bleach<5" # https://github.com/equinor/webviz-config/issues/586 | |
pip install "werkzeug<2.1" # ...while waiting for https://github.com/plotly/dash/issues/1992 | |
pip install "selenium<4.3" # breaking change in selenium==4.3 | |
pip install "scipy<1.9.3" # breaking change in scipy==1.9.3 | |
pip install "pytest<7.2.0" | |
pip install "pytest-xdist<3.0" | |
pip install "xtgeo<2.20.2" | |
pip install . | |
- name: Test import | |
run: | | |
import webviz_subsurface | |
shell: python |