CI #3034
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: CI | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
release: | |
types: | |
- published | |
schedule: | |
# Run CI daily and check that tests are working with latest dependencies | |
- cron: "0 0 * * *" | |
jobs: | |
FlowNet: | |
runs-on: ubuntu-18.04 | |
strategy: | |
matrix: | |
python-version: ["3.7", "3.8"] | |
flownet-model: [ "egg"] | |
env: | |
PYTHONWARNINGS: default | |
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 non-python dependencies | |
run: sudo bash ./apt_install.sh | |
- name: πΏ Download FlowNet test data | |
env: | |
INPUT_MODEL_FOLDER: ./flownet-testdata/${{ matrix.flownet-model }}/input_model | |
# If you want the CI to (temporarily) run against your fork of the testdata, | |
# 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/flownet-testdata.git --recursive | |
for f in $INPUT_MODEL_FOLDER/*.tar.gz; do tar -zxvf "$f" -C $INPUT_MODEL_FOLDER; done | |
- name: π¦ Install FlowNet | |
run: | | |
pip install "matplotlib<3.2" # As long as ERT requires it... | |
pip install . | |
- name: π¦ Install test dependencies | |
run: pip install .[tests] | |
- name: π§Ύ List all installed packages | |
run: pip freeze | |
- name: π΅οΈ Check code style & linting | |
run: | | |
black --check tests/ src/ setup.py | |
pylint src/ tests/ setup.py | |
mypy --ignore-missing-imports src/ setup.py | |
- name: π€ Run tests | |
run: | | |
pytest --cov=flownet --cov-fail-under=29 ./tests | |
- name: π Run full FlowNet example | |
run: | | |
pushd ./flownet-testdata/${{ matrix.flownet-model }} | |
flownet ahm ./config/assisted_history_matching.yml ./some_ahm_run --update-config ./ci_config/assisted_history_matching.yml | |
flownet ahm ./config/assisted_history_matching.yml ./some_ahm_run2 --update-config ./ci_config/assisted_history_matching.yml --restart-folder ./some_ahm_run | |
flownet pred ./config/prediction.yml ./some_pred_run ./some_ahm_run --update-config ./ci_config/prediction.yml | |
(test -f ./config/hyperparameter.yml && flownet hyperparam ./config/hyperparameter.yml ./hyper --update-config ./ci_config/assisted_history_matching.yml) || echo Skipping hyperparameter run... | |
- name: π Build documentation | |
run: | | |
pushd docs | |
make html | |
popd | |
- name: π’ Build and deploy Python package | |
if: github.event_name == 'release' && matrix.python-version == '3.7' | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.pypi_flownet_token }} | |
run: | | |
python -m pip install --upgrade setuptools wheel twine | |
python setup.py bdist_wheel | |
twine upload dist/* | |
- name: π Update GitHub pages | |
if: github.event_name != 'schedule' && github.ref == 'refs/heads/master' && matrix.python-version == '3.7' | |
run: | | |
cp -R ./docs/_build ../_build | |
git config --local user.email "flownet-github-action" | |
git config --local user.name "flownet-github-action" | |
git fetch origin gh-pages | |
git checkout --track origin/gh-pages | |
git clean -f -f -d -x | |
git rm -r * | |
cp -R ../_build/html/* . | |
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 |