Skip to content

Unit tests

Unit tests #1088

Workflow file for this run

# Run unit tests from the ground up
# installing "pycontrails" into the Github OS environments
name: Unit tests
on:
# run on push to main
push:
branches:
- main
# run on all PRs
pull_request:
# Allows run manually from the Actions tab
workflow_dispatch:
# Run if a release is published
workflow_call:
# Global variables
env:
PYCONTRAILS_CACHE_DIR: '${{ github.workspace }}/.cache/pycontrails'
BADA_CACHE_DIR: '${{ github.workspace }}/.cache/bada/'
# disable all permissions at the top level
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
permissions: {}
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
unit-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
pyversion: ['3.10', '3.11', '3.12', '3.13']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.pyversion }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Cache mypy and pytest
uses: actions/cache@v4
with:
# Note the caches are specific to branches, so we don't need to specify here
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache
key: ${{ runner.os }}-mypy-pytest
path: |
${{ github.workspace }}/.mypy_cache
${{ github.workspace }}/.pytest_cache
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
# download BADA files for testing
- name: BADA files
run: |
mkdir -p ${{ env.BADA_CACHE_DIR }}
gcloud storage cp -r gs://contrails-301217-bada/bada/bada3 ${{ env.BADA_CACHE_DIR }}
gcloud storage cp -r gs://contrails-301217-bada/bada/bada4 ${{ env.BADA_CACHE_DIR }}
ls -l ${{ env.BADA_CACHE_DIR }}
- name: Install make - windows
if: ${{ matrix.os == 'windows-latest' }}
run: choco install make
- name: Install pycontrails (dev)
run: make dev-install
# https://cloud.google.com/artifact-registry/docs/python/authentication
- name: Install pycontrails-bada
run: |
pip install keyring keyrings.google-artifactregistry-auth
pip install -U -i https://us-central1-python.pkg.dev/contrails-301217/pycontrails/simple pycontrails-bada
- name: Show environment
run: |
pwd
ls -l .
ls -l pycontrails
python --version
mypy --version
pip list
- name: QC & Test
shell: bash
run: |
pip check
make lint
make mypy
make pytest