Skip to content

Commit

Permalink
Actions: Setup cache_population job
Browse files Browse the repository at this point in the history
cache_population runs an initial test and saves `mhkit_webread_cache` as
a github artifact. The main job runs next and should use this cache.
This should force tests that use cached_webread to request files from
the cache rather than downloading them.
  • Loading branch information
simmsa committed Dec 6, 2023
1 parent 7b2d50a commit 40a3599
Showing 1 changed file with 102 additions and 2 deletions.
104 changes: 102 additions & 2 deletions .github/workflows/unix_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,104 @@ on:
branches: [master, develop, ebbflood]

jobs:
cache_population:
strategy:
fail-fast: false

matrix:
os: [ubuntu-latest]
python-version: ["3.10"]
matlab-version: [R2022b]

runs-on: ${{ matrix.os }}

env:
mhkit-python-dir: "MHKiT-Python"
steps:
- name: Check out MHKiT-MATLAB
uses: actions/checkout@v4

- name: Check out MHKiT-Python
uses: actions/checkout@v4
with:
repository: "MHKiT-Software/MHKiT-Python"
path: ${{env.mhkit-python-dir}}

- name: Install & Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: TEST
channels: conda-forge

- name: Setup Python ${{ matrix.python-version }}
shell: bash -l {0}
run: |
conda create --name TEST python=${{ matrix.python-version }} numpy cython pip pytest hdf5 libnetcdf cftime netcdf4 --strict-channel-priority
conda activate TEST
export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH" # so setup.py finds nc-config
pip install -e . --no-deps --force-reinstall

- name: pip install mhkit module from source
shell: bash -l {0}
run: |
conda activate TEST
pip install -e .
working-directory: ${{env.mhkit-python-dir}}

- name: pip install mhkit-python-utils module from source
shell: bash -l {0}
run: |
conda activate TEST
pip install -e .

# - name: Test MHKiT-Python
# run: |
# pip install nose pytest
# nosetests -v --traverse-namespace mhkit
# working-directory: ${{env.mhkit-python-dir}}
# # if: always() && steps.runTests.outcome == 'failure'

- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
with:
release: ${{ matrix.matlab-version }}

# OutOfProcess is required to properly call netcdf/hdf5 and works reliably on macos and ubuntu
- name: Configure MATLAB Python Environment
shell: bash -l {0}
run: |
conda activate TEST
printf 'pyenv(Version="%s", ExecutionMode="OutOfProcess")\n' $(python -c "import sys; print(sys.executable)") > run.m

- name: Add MATLAB test commands
shell: bash
run: echo "version,
addpath(genpath('mhkit')),
import matlab.unittest.TestSuite,
import matlab.unittest.TestRunner,
testFolder = ['mhkit' filesep 'tests'],
suite = TestSuite.fromFolder(testFolder),
runner = TestRunner.withTextOutput,
results = runner.run(suite),
assertSuccess(results)" >> run.m

- name: Output run.m
shell: bash
run: cat run.m

- name: Run MATLAB Unit Tests
uses: matlab-actions/run-command@v1
with:
command: run
startup-options: -noFigureWindows

- name: Save mhkit_webread_cache directory as an artifact
uses: actions/upload-artifact@v2
with:
name: mhkit_webread_cache
path: mhkit_webread_cache
main:
strategy:
fail-fast: false
Expand All @@ -17,6 +115,9 @@ jobs:
python-version: [3.8, 3.9, "3.10", 3.11]
matlab-version: [R2021b, R2022a, R2022b, R2023a, R2023b]
exclude:
- python-version: "3.10"
matlab-version: R2022b
os: ubuntu-latest
- matlab-version: R2023b
python-version: 3.8
- matlab-version: R2023a
Expand Down Expand Up @@ -153,9 +254,8 @@ jobs:
# # if: always() && steps.runTests.outcome == 'failure'

- name: Download mhkit_webread_cache artifact
uses: actions/upload-artifact@v2
uses: actions/download-artifact@v3
with:
name: mhkit_webread_cache
path: mhkit_webread_cache

- name: Set up MATLAB
Expand Down

0 comments on commit 40a3599

Please sign in to comment.