webviz-subsurface #5351
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", "3.11", "3.12"] | |
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@v4 | |
- name: π Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
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" | |
pip install "bleach" | |
pip install "werkzeug" | |
pip install "selenium" | |
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 | |
if: github.event_name != 'release' | |
run: | | |
black --check webviz_subsurface tests setup.py | |
pylint_exit_code=0 | |
pylint webviz_subsurface tests setup.py || pylint_exit_code=$? | |
error_bitmask=$((1 | 2 | 4)) # Fatal, Error, Warning | |
result=$(($pylint_exit_code & $error_bitmask)) | |
if [[ $result != 0 ]]; then | |
echo "Error: Pylint returned exit code $pylint_exit_code" | |
exit $pylint_exit_code | |
fi | |
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 | |
if: github.event_name != 'release' | |
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 | |
- name: π³ Build Docker example image | |
if: github.event_name != 'release' | |
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 | |
sed -i '29i RUN apt-get update && apt-get install -y libgomp1' Dockerfile # Temp. workaround for recent version of opm | |
docker build -t webviz/example_subsurface_image:equinor-theme . | |
popd | |
- name: π³ Update Docker Hub example image | |
if: github.event_name != 'release' && 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.event_name != 'release' && 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: | | |
webviz docs --portable ./docs_build --skip-open | |
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@v4 | |
- name: π Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: π¦ Install webviz-subsurface with dependencies | |
run: | | |
pip install --upgrade pip | |
pip install "bleach" | |
pip install "werkzeug" | |
pip install "selenium" | |
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 |