From a00c34436e3b7c2f384ec986edf39b19c361b066 Mon Sep 17 00:00:00 2001 From: Richard Evans Date: Mon, 30 Oct 2023 01:54:28 -0600 Subject: [PATCH] Added tests in .github/workflows/ --- .github/workflows/build_and_test.yml | 47 +++++++++++++++++++ .../{check_black.yml => check_format.yml} | 6 +-- .github/workflows/deploy_docs.yml | 39 +++++++++++++++ .github/workflows/docs_check.yml | 29 ++++++++++++ .github/workflows/publish_to_pypi.yml | 30 ++++++++++++ 5 files changed, 148 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build_and_test.yml rename .github/workflows/{check_black.yml => check_format.yml} (63%) create mode 100644 .github/workflows/deploy_docs.yml create mode 100644 .github/workflows/docs_check.yml create mode 100644 .github/workflows/publish_to_pypi.yml diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml new file mode 100644 index 0000000..4ae149c --- /dev/null +++ b/.github/workflows/build_and_test.yml @@ -0,0 +1,47 @@ +name: Build and test [Python 3.9, 3.10] + +on: [push, pull_request] + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + python-version: ["3.9", "3.10"] + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Setup Miniconda using Python ${{ matrix.python-version }} + uses: conda-incubator/setup-miniconda@v2 + with: + miniforge-variant: Mambaforge + auto-update-conda: true + activate-environment: ogzaf-dev + environment-file: environment.yml + python-version: ${{ matrix.python-version }} + auto-activate-base: false + + - name: Build + shell: bash -l {0} + run: | + pip install -e . + pip install pytest-cov + pip install pytest-pycodestyle + - name: Test + shell: bash -l {0} + working-directory: ./ + run: | + pytest -m 'not local' --cov=./ --cov-report=xml + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + files: ./coverage.xml + flags: unittests + name: codecov-umbrella + fail_ci_if_error: true + verbose: true diff --git a/.github/workflows/check_black.yml b/.github/workflows/check_format.yml similarity index 63% rename from .github/workflows/check_black.yml rename to .github/workflows/check_format.yml index 6a0aa63..a261c25 100644 --- a/.github/workflows/check_black.yml +++ b/.github/workflows/check_format.yml @@ -1,4 +1,4 @@ -name: Check Black formatting +name: Check code formatting on: [push, pull_request] @@ -6,8 +6,8 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 - uses: psf/black@stable with: options: "-l 79 --check" diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml new file mode 100644 index 0000000..d8c2b7e --- /dev/null +++ b/.github/workflows/deploy_docs.yml @@ -0,0 +1,39 @@ +name: Build and Deploy Jupyter Book documentation +on: + push: + branches: + - main +jobs: + build-and-deploy: + if: github.repository == 'EAPD-DRB/OG-ZAF' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Setup Miniconda + uses: conda-incubator/setup-miniconda@v2 + with: + miniforge-variant: Mambaforge + activate-environment: ogzaf-dev + environment-file: environment.yml + python-version: "3.10" + auto-activate-base: false + + - name: Build # Build Jupyter Book + shell: bash -l {0} + run: | + pip install jupyter-book>=0.11.3 + pip install sphinxcontrib-bibtex>=2.0.0 + pip install -e . + python -m ipykernel install --user --name=ogzaf-dev + jb build ./docs/book + + - name: Deploy + uses: JamesIves/github-pages-deploy-action@releases/v4 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: gh-pages # The branch the action should deploy to. + FOLDER: docs/book/_build/html # The folder the action should deploy. diff --git a/.github/workflows/docs_check.yml b/.github/workflows/docs_check.yml new file mode 100644 index 0000000..77b245f --- /dev/null +++ b/.github/workflows/docs_check.yml @@ -0,0 +1,29 @@ +name: Check that docs build +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Setup Miniconda + uses: conda-incubator/setup-miniconda@v2 + with: + miniforge-variant: Mambaforge + activate-environment: ogzaf-dev + environment-file: environment.yml + python-version: "3.10" + auto-activate-base: false + + - name: Build # Build Jupyter Book + shell: bash -l {0} + run: | + pip install jupyter-book>=0.11.3 + pip install sphinxcontrib-bibtex>=2.0.0 + pip install -e . + python -m ipykernel install --user --name=ogzaf-dev + jb build ./docs/book diff --git a/.github/workflows/publish_to_pypi.yml b/.github/workflows/publish_to_pypi.yml new file mode 100644 index 0000000..3afbe4f --- /dev/null +++ b/.github/workflows/publish_to_pypi.yml @@ -0,0 +1,30 @@ +name: Publish package to PyPI + +on: + push: + branches: + - main + +jobs: + deploy: + name: Publish to PyPI + if: github.repository == 'EAPD-DRB/OG-ZAF' + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Build package + shell: bash -l {0} + run: | + pip install wheel + python setup.py sdist bdist_wheel + - name: Publish a Python distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI }} + skip_existing: true