tests: make sure they pass #250
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: "Conda + pip" | |
# Use login shell everywhere | |
# https://github.com/mamba-org/setup-micromamba/tree/fcc371cea11af9012e5e916ab2dab44b42acdaaa#about-login-shells | |
on: | |
push: | |
branches: | |
- "main" | |
- "master" | |
- "dev" | |
paths: | |
- "**.py" | |
- ".github/workflows/*.yml" | |
- "pyproject.toml" | |
- "poetry.lock" | |
- "locks/*" | |
pull_request: | |
paths: | |
- "**.py" | |
- ".github/workflows/*.yml" | |
- "pyproject.toml" | |
- "poetry.lock" | |
- "locks/*" | |
jobs: | |
run-linters: | |
name: "Run linters" | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: "Check out Git repository" | |
uses: "actions/checkout@v3" | |
- name: "Set up Python" | |
uses: "actions/setup-python@v3" | |
with: | |
python-version: "3.10" | |
- name: "Install Python dependencies" | |
run: "pip install 'black'" | |
- name: "Run linters" | |
run: "black --diff ./" | |
run-tests: | |
needs: "run-linters" | |
name: "Test Python ${{ matrix.python }} on ${{ matrix.os }} using ${{ matrix.mpi }}" | |
runs-on: "${{ matrix.os }}" | |
strategy: | |
fail-fast: false | |
matrix: | |
# os: [ "ubuntu-latest", "macos-latest" ] | |
# mpi: [ "mpich", "openmpi" ] | |
os: [ "ubuntu-latest"] | |
mpi: [ "openmpi" ] | |
python: [ "3.9", "3.10", "3.11", "3.12" ] | |
env: | |
SCHISM_ENV: "SCHISM_ENV" | |
DELFT3D_ENV: "DELFT3D_ENV" | |
PYPOSEIDON_ENV: "PYPOSEIDON_ENV" | |
# | |
SCHISM_LOCK: locks/conda-${{ matrix.os }}-schism_${{ matrix.mpi }}.lock | |
DELFT3D_LOCK: locks/conda-${{ matrix.os }}-delft3d_${{ matrix.mpi }}.lock | |
PYPOSEIDON_LOCK: locks/conda-${{ matrix.os }}-binary-p${{ matrix.python }}.lock | |
REQUIREMENTS_CI: locks/requirements-ci.txt | |
REQUIREMENTS_VIZ: locks/requirements-viz.txt | |
defaults: | |
run: | |
shell: "bash -elo pipefail {0}" | |
steps: | |
- run: "env | sort" | |
- uses: "actions/checkout@v3" | |
- name: "Install micromamba" | |
run: | | |
mkdir -p ~/.local/bin/ | |
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj -C ~/.local/bin/ --strip-components=1 bin/micromamba | |
echo export MAMBA_EXE=$(which micromamba) | tee -a ~/.bashrc | |
echo export MAMBA_ROOT_PREFIX=~/micromamba | tee -a ~/.bashrc | |
- run: which micromamba | |
- name: "Create ~/.condarc" | |
run: | | |
rm -rf ~/.condarc | |
cat << EOF > ~/.condarc | |
--- | |
auto_activate_base: false | |
auto_stack: false | |
channel_priority: strict | |
channels: | |
- gbrey | |
- conda-forge | |
EOF | |
- run: cat ~/.condarc | |
- name: "Cache ${{ env.SCHISM_ENV }}" | |
uses: actions/cache@v3 | |
id: cache-SCHISM_ENV | |
with: | |
path: ~/micromamba/envs/${{ env.SCHISM_ENV }} | |
key: ${{ matrix.os }}-${{ matrix.mpi }}-${{ env.SCHISM_ENV }}-${{ hashFiles( env.SCHISM_LOCK )}} | |
restore-keys: | | |
${{ matrix.os }}-${{ matrix.mpi }}-${{ env.SCHISM_ENV }}- | |
- name: "Cache ${{ env.DELFT3D_ENV }}" | |
uses: actions/cache@v3 | |
id: cache-DELFT3D_ENV | |
with: | |
path: ~/micromamba/envs/${{ env.DELFT3D_ENV }} | |
key: ${{ matrix.os }}-${{ matrix.mpi }}-${{ env.DELFT3D_ENV }}-${{ hashFiles( env.DELFT3D_LOCK )}} | |
restore-keys: | | |
${{ matrix.os }}-${{ matrix.mpi }}-${{ env.DELFT3D_ENV }}- | |
- name: "Cache ${{ env.PYPOSEIDON_ENV }}" | |
uses: actions/cache@v3 | |
id: cache-PYPOSEIDON_ENV | |
with: | |
path: ~/micromamba/envs/${{ env.PYPOSEIDON_ENV }} | |
key: ${{ matrix.os }}-${{ matrix.python }}-${{ env.PYPOSEIDON_ENV }}-${{ hashFiles( env.PYPOSEIDON_LOCK )}}-${{ hashFiles( env.REQUIREMENTS_CI )}} | |
restore-keys: | | |
${{ matrix.os }}-${{ matrix.python }}-${{ env.PYPOSEIDON_ENV }}-${{ hashFiles( env.PYPOSEIDON_LOCK )}} | |
${{ matrix.os }}-${{ matrix.python }}-${{ env.PYPOSEIDON_ENV }}- | |
- name: Cache tests/data/ | |
uses: actions/cache@v3 | |
env: | |
# Increase this value to reset cache if files in tests/data have been added/removed | |
CACHE_NUMBER: 0 | |
with: | |
path: /home/runner/work/pyPoseidon/pyPoseidon/tests/data | |
key: tests_data-${{ env.CACHE_NUMBER }} | |
- name: "Create ${{ env.SCHISM_ENV }}" | |
if: steps.cache-SCHISM_ENV.outputs.cache-hit != 'true' | |
run: micromamba create --yes --name ${SCHISM_ENV} -f ${SCHISM_LOCK} | |
- name: "Create ${{ env.DELFT3D_ENV }}" | |
if: steps.cache-DELFT3D_ENV.outputs.cache-hit != 'true' | |
run: micromamba create --yes --name ${DELFT3D_ENV} -f ${DELFT3D_LOCK} | |
- name: "Create ${{ env.PYPOSEIDON_ENV }}" | |
if: steps.cache-PYPOSEIDON_ENV.outputs.cache-hit != 'true' | |
run: micromamba create --yes --name ${PYPOSEIDON_ENV} -f ${PYPOSEIDON_LOCK} | |
- name: "Check schism version" | |
run: | | |
eval "$(micromamba shell hook)" | |
micromamba activate "${SCHISM_ENV}" | |
schism -v | |
- name: "Install python dependencies" | |
run: | | |
eval "$(micromamba shell hook)" | |
micromamba activate --stack "${PYPOSEIDON_ENV}" | |
python -mpip install -U pip | |
python -mpip install -r "${REQUIREMENTS_CI}" | |
python -mpip install ./ | |
- name: "Run tests: Basic" | |
run: | | |
eval "$(micromamba shell hook)" | |
micromamba activate "${SCHISM_ENV}" | |
micromamba activate --stack "${DELFT3D_ENV}" | |
micromamba activate --stack "${PYPOSEIDON_ENV}" | |
make test | |
# - name: "Run tests: Viz" | |
# if: matrix.python != '3.11' | |
# run: | | |
# eval "$(micromamba shell hook)" | |
# micromamba activate "${PYPOSEIDON_ENV}" | |
# python -mpip install -r "${REQUIREMENTS_VIZ}" | |
# make test_viz | |
- name: "Run tests: Schism" | |
run: | | |
eval "$(micromamba shell hook)" | |
micromamba activate "${SCHISM_ENV}" | |
# micromamba activate --stack "${DELFT3D_ENV}" | |
micromamba activate --stack "${PYPOSEIDON_ENV}" | |
make test_schism | |
- name: "Run tests: Delft" | |
run: | | |
eval "$(micromamba shell hook)" | |
# micromamba activate "${SCHISM_ENV}" | |
micromamba activate --stack "${DELFT3D_ENV}" | |
micromamba activate --stack "${PYPOSEIDON_ENV}" | |
make test_delft |