Ensure closure of session on error #42
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: test | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
jobs: | |
local: | |
name: Tests | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
python-version: [ '3.10', '3.11' ] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '${{ matrix.python-version }}' | |
# https://github.com/snok/install-poetry#caching-the-poetry-installation | |
- name: Load cached poetry installation | |
id: cached-poetry | |
uses: actions/cache@v3 | |
with: | |
path: ~/.local | |
key: poetry-0 # increment to reset cache | |
- name: Install Python Poetry | |
if: steps.cached-poetry.outputs.cache-hit != 'true' | |
uses: snok/install-poetry@c9e8b50048357a728ac0409bae3d7c0a1685118a | |
with: | |
version: '1.5.1' | |
- name: miniChRIS | |
uses: FNNDSC/miniChRIS-docker@master | |
- name: Install | |
run: poetry install --with=dev | |
- name: Test | |
id: test | |
run: | | |
set +e | |
for attempt in {1..5}; do | |
echo " +---------------------+ " | |
echo " | ATTEMPT $attempt | " | |
echo " +---------------------+ " | |
poetry run pytest --cov=aiochris --cov-report=xml | |
if [ "$?" = 0 ]; then | |
if [ "$attempt" != "1" ]; then | |
echo "::warning ::Tests took $attempt attempts." | |
fi | |
exit 0 | |
fi | |
done | |
exit 1 | |
continue-on-error: true | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
files: ./coverage.xml | |
env_vars: 'python-${{ matrix.python-version }}' | |
- name: End test | |
run: '[ "${{ steps.test.outcome }}" = "success" ]' |