Skip to content

Run unit tests, integration tests, and publish package if tagged #286

Run unit tests, integration tests, and publish package if tagged

Run unit tests, integration tests, and publish package if tagged #286

Workflow file for this run

name: Run tests
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
release:
schedule:
- cron: '0 2 * * 3,6'
jobs:
run-tests:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -el {0}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest",
"macos-13",
# "windows-latest" # rrcovNA cannot be build from source on windows-server
]
python-version: ["3.8"]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Miniconda
# ! change action https://github.com/mamba-org/setup-micromamba
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
# miniforge-version: latest
use-mamba: true
channel-priority: disabled
python-version: ${{ matrix.python-version }}
environment-file: environment.yml
activate-environment: vaep
auto-activate-base: true
# auto-update-conda: true
- name: inspect-conda-environment
run: |
conda info
conda list
conda info -e
- name: test-r-kernel-imports
run: |
Rscript -e "library(stringi)"
Rscript -e "library(stringr)"
Rscript -e "library(reshape2)"
# # currently part of environment
# - name: Install package and install library
# run: |
# pip install pytest pytest-cov
- name: Run Unit tests on installed package
run: |
pytest .
- name: View papermill help message for notebooks (as scripts)
run: |
cd project
papermill 01_0_split_data.ipynb --help-notebook
papermill 01_1_train_VAE.ipynb --help-notebook
papermill 01_1_train_DAE.ipynb --help-notebook
papermill 01_1_train_CF.ipynb --help-notebook
- name: Run demo workflow (integration test)
run: |
cd project
snakemake -p -c1 --configfile config/single_dev_dataset/example/config.yaml -n
snakemake -p -c1 -k --configfile config/single_dev_dataset/example/config.yaml
- name: Archive results
uses: actions/upload-artifact@v3
with:
name: example-workflow-results-${{ matrix.os }}
path: project/runs/example/01_2_performance_plots.html
test_pip_pkg_install:
runs-on: ${{ matrix.os }}
name: test-pip-installation
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.8"]
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- name: install pimms
run: python -m pip install .
- name: Install pytest
run: python -m pip install pytest pytest-cov
- name: Run pytest
run: pytest .
publish:
name: Publish package
if: startsWith(github.event.ref, 'refs/tags/v')
needs:
- run-tests
- test_pip_pkg_install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
python-version: "3.8"
- name: Install twine and build
run: python -m pip install --upgrade twine build
- name: Build
run: python -m build
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}