Feature/pysurfex experiment #372
Workflow file for this run
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: Python package | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
if: github.repository_owner == 'metno' | |
strategy: | |
fail-fast: true | |
matrix: | |
os: [ "ubuntu-latest" ] | |
env: [ "pytest" ] | |
python-version: [ "3.8" ] | |
name: "${{ matrix.os }}, python=${{ matrix.python-version }}" | |
runs-on: ${{ matrix.os }} | |
container: | |
image: python:${{ matrix.python-version }}-bullseye | |
env: | |
COVERAGE_FILE: ".coverage.${{ matrix.env }}.${{ matrix.python-version }}" | |
steps: | |
#---------------------------------------------- | |
# check-out repo | |
#---------------------------------------------- | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
apt-get update | |
apt-get install -y libudunits2-dev libproj-dev libeccodes0 libeccodes-dev libnetcdf-dev netcdf-bin | |
#---------------------------------------------- | |
# --- configure poetry & install project ---- | |
#---------------------------------------------- | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Load cached venv (if cache exists) | |
id: cached-poetry-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }} | |
- name: Install dependencies (if venv cache is not found) | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --no-root --only main,test | |
- name: Install the project itself | |
run: poetry install --no-interaction --only-root | |
#---------------------------------------------- | |
# run test suite and report coverage | |
#---------------------------------------------- | |
- name: Run tests | |
run: | | |
poetry run pytest | |
- name: Coveralls | |
if: ${{ matrix.python-version == 3.8 }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
export COVERALLS_REPO_TOKEN=${{secrets.COVERALLS_REPO_TOKEN}} | |
git config --global --add safe.directory $PWD | |
poetry run coveralls | |
- name: Create documentation | |
if: ${{ matrix.python-version == 3.8 }} | |
run: | | |
cd docs | |
poetry run python auto_sphinx.py | |
make html | |
- name: Commit documentation changes | |
if: ${{ matrix.python-version == 3.8 }} | |
run: | | |
git clone https://github.com/metno/pysurfex.git --branch gh-pages --single-branch gh-pages | |
cp -r docs/build/html/* gh-pages/ | |
cd gh-pages | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add . | |
git commit -m "Update documentation" -a || true | |
# The above command will fail if no changes were present, so we ignore | |
# the return code. | |
- name: Push changes | |
if: ${{ matrix.python-version == 3.8 && github.event_name != 'pull_request' }} | |
uses: ad-m/github-push-action@master | |
with: | |
branch: gh-pages | |
directory: gh-pages | |
github_token: ${{ secrets.GITHUB_TOKEN }} |