From 40a3599efa4b24a29f9bc91659a877085ec5bd09 Mon Sep 17 00:00:00 2001 From: Andrew Simms Date: Wed, 6 Dec 2023 15:42:47 -0700 Subject: [PATCH] Actions: Setup cache_population job 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. --- .github/workflows/unix_unit_tests.yml | 104 +++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unix_unit_tests.yml b/.github/workflows/unix_unit_tests.yml index e746d5df5..653834853 100644 --- a/.github/workflows/unix_unit_tests.yml +++ b/.github/workflows/unix_unit_tests.yml @@ -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 @@ -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 @@ -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