Skip to content

Costs tests

Costs tests #14

Workflow file for this run

name: "Testing Pull Request"
on:
pull_request:
branches:
- "master"
jobs:
prepare_matrix: ##############################################################################
runs-on: ubuntu-latest
outputs:
matrix_unit_test: ${{ steps.setmatrix.outputs.matrix1 }}
matrix_tutorial_test: ${{ steps.setmatrix.outputs.matrix2 }}
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/[email protected]
- name: Set Dynamic Matrix
id: setmatrix
run: |
matrix_str=$(python utils/info2json.py testing_matrix)
echo "matrix1=$matrix_str" >> $GITHUB_OUTPUT
matrix_str=$(python utils/info2json.py tutorial_testing_matrix)
echo "matrix2=$matrix_str" >> $GITHUB_OUTPUT
check_matrix: ##############################################################################
runs-on: ubuntu-latest
needs: prepare_matrix
steps:
- name: Install json2yaml
run: |
sudo npm install -g json2yaml
- name: Check matrix definition
run: |
matrix='${{ needs.prepare_matrix.outputs.matrix_unit_test }}'
echo $matrix
echo $matrix | jq .
echo $matrix | json2yaml
black: ######################################################################################
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install black
run: |
pip install black[jupyter]
- name: Run black formatter on PyDMD source code
run: |
black --check --diff --color pydmd/ utils/ tests/ setup.py
if [[ $? -ne "0" ]]; then
echo "Source code needs re-formatting"
exit 1
fi
- name: Run black formatter on PyDMD tutorials
run: |
black --check --diff --color tutorials/
if [[ $? -ne "0" ]]; then
echo "Tutorials need re-formatting"
exit 1
fi
sort_dependencies: ##########################################################################
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install isort
run: |
pip install isort
- name: Run isort on PyDMD source code
run: |
OUT=$(isort pydmd/ tests/)
if [[ $OUT ]]; then
echo "All imports are properly sorted"
else
echo "$OUT"
fi
unit_test: #################################################################################
needs: prepare_matrix
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{ fromJson(needs.prepare_matrix.outputs.matrix_unit_test) }}
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: setup.py
- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install .[test]
- name: Test with pytest
run: |
pytest
tutorial_test: ##############################################################################
needs: prepare_matrix
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{ fromJson(needs.prepare_matrix.outputs.matrix_tutorial_test) }}
fail-fast: false
env:
TUTORIAL_TIMEOUT: 1200s
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: setup.py
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -e .[test]
# Dependencies for tutorials
pip install jupyter pandas opencv-python ffmpeg-python
# timeout not available by default on MacOS
brew install coreutils || true
- uses: actions/cache@v2
id: cache-segtrackv2
with:
path: ./tutorials/tutorial12/SegTrackv2
key: SegTrackv2-key
# This is needed for tutorial12 for large file download
- name: Download SegTrackv2
if: steps.cache-segtrackv2.outputs.cache-hit != 'true'
run: |
curl https://web.engr.oregonstate.edu/~lif/SegTrack2/SegTrackv2.zip --output SegTrackv2.zip
unzip -qq SegTrackv2.zip
mv SegTrackv2 tutorials/tutorial12
- name: Setup FFmpeg
uses: FedericoCarboni/setup-ffmpeg@v2
- name: Check tutorial references
run: |
cd tutorials/
for dir in $(ls -d tutorial*/); do
if grep -q "$dir" "README.md"
then
echo "$dir is referenced"
else
echo "$dir not referenced"
exit 1
fi
done
- name: Test tutorials
run: |
set -x
cd tutorials/
for dir in $(ls -d tutorial*/); do
if [[ $dir != tutorial5* ]]
then
cd $dir
timeout --signal=SIGKILL $TUTORIAL_TIMEOUT python -Xfrozen_modules=off -m jupyter nbconvert --to notebook --execute *.ipynb
cd ..
fi
done
set +x