Skip to content

Test

Test #246

Workflow file for this run

name: Test
on:
workflow_dispatch:
push:
pull_request:
schedule: [{cron: '10 23 * * 6'}] # M H d m w (Sat at 23:10)
jobs:
check:
if: github.event_name != 'pull_request' || !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: set PYSHA
run: echo "PYSHA=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PYSHA }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: dependencies
run: pip install -U pre-commit
- uses: reviewdog/action-setup@v1
- if: github.event_name == 'push' || github.event_name == 'pull_request'
name: comment
run: |
if [[ $EVENT == pull_request ]]; then
REPORTER=github-pr-review
else
REPORTER=github-check
fi
pre-commit run -a todo | reviewdog -efm="%f:%l: %m" -name=TODO -tee -reporter=$REPORTER -filter-mode nofilter
pre-commit run -a flake8 | reviewdog -f=pep8 -name=flake8 -tee -reporter=$REPORTER -filter-mode nofilter
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EVENT: ${{ github.event_name }}
- run: pre-commit run -a --show-diff-on-failure
test:
if: github.event_name != 'pull_request' || !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)
name: py${{ matrix.python }}
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.7, 3.11]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- run: pip install -U .[dev]
- run: pytest --durations-min=1
- uses: codecov/codecov-action@v3
matlab:
if: github.event_name != 'pull_request' || !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)
name: MATLAB py${{ matrix.python }}
runs-on: [self-hosted, python, matlab]
strategy:
matrix:
python: [3.7, 3.8]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Run setup-python
run: setup-python -p${{ matrix.python }}
- run: pip install -U .[dev] 'setuptools<66' # ignore matlab engine PEP440 non-compliance https://github.com/pypa/setuptools/issues/3772
- run: pytest --durations-min=1
- uses: codecov/codecov-action@v3
- name: Post Run setup-python
run: setup-python -p${{ matrix.python }} -Dr
if: ${{ always() }}
deploy:
needs: [check, test, matlab]
name: PyPI Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- id: dist
uses: casperdcl/deploy-pypi@v2
with:
pip: true
gpg_key: ${{ secrets.GPG_KEY }}
password: ${{ secrets.PYPI_TOKEN }}
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
name: Release
run: |
changelog=$(git log --pretty='format:%d%n- %s%n%b---' $(git tag --sort=v:refname | tail -n2 | head -n1)..HEAD)
tag="${GITHUB_REF#refs/tags/}"
gh release create --title "spm12 $tag beta" --draft --notes "$changelog" "$tag" dist/${{ steps.dist.outputs.whl }} dist/${{ steps.dist.outputs.whl_asc }}
env:
GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }}