add bugfix #2782
Workflow file for this run
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: pytest | |
on: [push, pull_request] | |
jobs: | |
collect_references: | |
name: collect_references | |
outputs: | |
MATLAB_REFS_HASH: ${{ steps.matlab-refs-hash.outputs.MATLAB_REFS_HASH }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout repository | |
uses: actions/checkout@v4 | |
with: | |
path: k-Wave-python | |
# Calculate hash value that will be used as a cache key | |
- name: Calculate matlab references hash | |
id: matlab-refs-hash | |
run: | | |
MATLAB_REFS_HASH=$(find ./k-Wave-python/tests/matlab_test_data_collectors/matlab_collectors -type f | xargs sha1sum | sha1sum | awk '{ print $1 }'); | |
echo "MATLAB_REFS_HASH=$MATLAB_REFS_HASH" >> $GITHUB_OUTPUT | |
# Pull cache if exists, otherwise cache will be created at the specified path | |
- name: Cache collected references | |
uses: actions/cache@v3 | |
id: matlab-refs-cache | |
env: | |
cache-name: cache-matlab-references | |
with: | |
key: ${{ steps.matlab-refs-hash.outputs.MATLAB_REFS_HASH }} | |
path: ./collectedValues.tar.gz | |
- name: Checkout reference k-Wave repo | |
uses: actions/checkout@v4 | |
if: ${{ steps.matlab-refs-cache.outputs.cache-hit != 'true' }} | |
with: | |
repository: ucl-bug/k-wave | |
path: k-wave | |
ref: v1.4.0 | |
- name: setup MATLAB | |
uses: matlab-actions/setup-matlab@v1 | |
if: ${{ steps.matlab-refs-cache.outputs.cache-hit != 'true' }} | |
- name: run reference generation | |
uses: matlab-actions/run-command@v1 | |
if: ${{ steps.matlab-refs-cache.outputs.cache-hit != 'true' }} | |
with: | |
command: | | |
ls; | |
pwd; | |
if exist('k-wave/k-Wave'); ls 'k-wave/k-Wave'; end; | |
addpath('k-Wave-python','k-wave/k-Wave'); | |
cd k-Wave-python/tests/matlab_test_data_collectors; | |
run_all_collectors; | |
- name: Compress generated references | |
uses: a7ul/[email protected] | |
if: ${{ steps.matlab-refs-cache.outputs.cache-hit != 'true' }} | |
with: | |
command: c | |
cwd: ./k-Wave-python/tests/matlab_test_data_collectors/matlab_collectors/ | |
files: | | |
./collectedValues | |
outPath: collectedValues.tar.gz | |
- name: upload reference values artifact | |
id: artifact-upload-step | |
if: ${{ steps.matlab-refs-cache.outputs.cache-hit != 'true' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: matlab_reference_test_values | |
path: collectedValues.tar.gz | |
# overwrite: true | |
- name: Output artifact URL | |
if: ${{ steps.matlab-refs-cache.outputs.cache-hit != 'true' }} | |
run: echo 'Artifact URL is ${{ steps.artifact-upload-step.outputs.artifact-url }}' | |
test: | |
needs: collect_references | |
strategy: | |
matrix: | |
os: [ "windows-latest", "ubuntu-latest" , "macos-latest"] | |
python-version: [ "3.10", "3.11", "3.12", "3.13" ] | |
runs-on: ${{matrix.os}} | |
steps: | |
- uses: actions/checkout@v4 | |
# Pull the cache based on the hash value | |
- name: Cache collected references | |
uses: actions/cache@v3 | |
id: cache-matlab-refs | |
env: | |
cache-name: cache-matlab-references | |
with: | |
key: ${{ needs.collect_references.outputs.MATLAB_REFS_HASH }} | |
path: ./collectedValues.tar.gz | |
fail-on-cache-miss: true | |
enableCrossOsArchive: true | |
# Now we have the references archive available in this job, proceed by unpacking it | |
- name: unpack collectedValues | |
uses: a7ul/[email protected] | |
with: | |
command: x | |
cwd: ./tests/matlab_test_data_collectors/python_testers/ | |
files: ${{github.workspace}}/collectedValues.tar.gz | |
- name: where are the files? | |
run: | | |
ls ./tests/matlab_test_data_collectors/python_testers/ | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
- name: Install dependencies | |
run: | | |
pip install '.[test]' | |
- name: Test with pytest | |
run: | | |
coverage run | |
- name: Create coverage report | |
run: | | |
coverage xml | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
env_vars: ${{matrix.os}},${{ matrix.python-version }} | |
fail_ci_if_error: true | |
flags: ${{matrix.os}},${{ matrix.python-version }} | |
name: ${{matrix.os}},${{ matrix.python-version }} | |
verbose: true | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |