🧶 Format using black #228
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: Unit Tests | |
on: | |
push: | |
paths: | |
- 'iasc/**/*' | |
- 'frontend/**/*' | |
pull_request: | |
types: | |
- opened | |
jobs: | |
test: | |
name: Set up and test | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
# Shell needs to use login mode to activate the Conda environment | |
shell: bash -l {0} | |
services: | |
postgres: | |
image: postgres:15.2-alpine | |
env: | |
POSTGRES_USER: arc_iasc | |
POSTGRES_PASSWORD: arc_iasc_1234 | |
POSTGRES_DB: arc_iasc | |
ports: | |
- 5432:5432 | |
# The Postgres container does not provide a healthcheck | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- run: echo "date=$(date +'%Y-%m')" >> $GITHUB_OUTPUT | |
name: Get current date for caching Conda envs | |
id: date | |
- uses: actions/checkout@v2 | |
# https://github.com/actions/cache/issues/133#issuecomment-599102035 | |
- name: Fix /usr/share/miniconda directory permissions | |
run: sudo chown -R $(whoami):$(id -ng) /usr/share/miniconda | |
- uses: actions/cache@v3 | |
name: Cache Miniconda environment | |
with: | |
path: | | |
${{ env.CONDA_PREFIX }}/envs/ | |
/home/runner/conda_pkgs_dir/ | |
key: conda-${{ runner.os }}-${{ runner.arch }}-${{ steps.date.outputs.date }}-${{ hashFiles('conf/iasc.base.yml') }}-${{ env.CACHE_NUMBER }} | |
env: | |
# Increase this to manually invalidate the cache | |
CACHE_NUMBER: 0 + | |
CONDA_PREFIX: /usr/share/miniconda | |
id: cache | |
- uses: conda-incubator/setup-miniconda@v2 | |
name: Set Up Miniconda | |
with: | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
use-mamba: true | |
activate-environment: anaconda-client-env | |
environment-file: conf/iasc.base.yml | |
python-version: 3.8 | |
channels: conda-forge | |
# IMPORTANT! This needs to be set for caching to work properly: | |
use-only-tar-bz2: true | |
auto-activate-base: false | |
# https://github.com/conda-incubator/setup-miniconda/issues/105#issuecomment-730243912 | |
- | |
name: Install dev dependencies and list packages | |
run: | | |
conda env update -n anaconda-client-env -f conf/iasc.dev.yml | |
echo $CONDA_PREFIX | |
conda info | |
conda list | |
- name: Run Django tests | |
env: | |
ALLOWED_HOSTS: localhost,127.0.0.1 | |
DB_PASS: arc_iasc_1234 | |
# NB: Do not use secrets here; PRs do not allow them for security reasons. | |
run: coverage run --source='.' manage.py test | |
- name: Create coverage.py XML report | |
run: coverage xml | |
- name: Upload coverage reports to Codecov with GitHub Action | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} |