Skip to content

Commit

Permalink
Added tests in .github/workflows/
Browse files Browse the repository at this point in the history
  • Loading branch information
rickecon committed Oct 30, 2023
1 parent a3cfd9b commit a00c344
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 3 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Check Black formatting
name: Check code formatting

on: [push, pull_request]

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"
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
@@ -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.
29 changes: 29 additions & 0 deletions .github/workflows/docs_check.yml
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a00c344

Please sign in to comment.