Merge pull request #97 from smarie/feature/96_syntax_error_coroutine #117
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
# .github/workflows/base.yml | |
name: Build | |
on: | |
# this one is to trigger the workflow manually from the interface | |
workflow_dispatch: | |
push: | |
tags: | |
- '*' | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
# pre-job to read nox tests matrix - see https://stackoverflow.com/q/66747359/7262247 | |
list_nox_test_sessions: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-python@v1 | |
with: | |
python-version: 3.7 | |
architecture: x64 | |
- name: Install noxfile requirements | |
shell: bash -l {0} | |
run: pip install -r noxfile-requirements.txt | |
- name: List 'tests' nox sessions | |
id: set-matrix | |
run: echo "::set-output name=matrix::$(nox -s gha_list -- tests)" | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} # save nox sessions list to outputs | |
run_all_tests: | |
needs: list_nox_test_sessions | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-latest ] # , macos-latest, windows-latest] | |
# all nox sessions: manually > dynamically from previous job | |
# nox_session: ["tests-2.7", "tests-3.7"] | |
nox_session: ${{ fromJson(needs.list_nox_test_sessions.outputs.matrix) }} | |
name: ${{ matrix.os }} ${{ matrix.nox_session }} # ${{ matrix.name_suffix }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v2 | |
# Conda install | |
- name: Install conda v3.7 | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
# auto-update-conda: true | |
python-version: 3.7 | |
activate-environment: noxenv | |
- run: conda info | |
shell: bash -l {0} # so that conda works | |
- run: conda list | |
shell: bash -l {0} # so that conda works | |
# Nox install + run | |
- name: Install noxfile requirements | |
shell: bash -l {0} # so that conda works | |
run: pip install -r noxfile-requirements.txt | |
- run: conda list | |
shell: bash -l {0} # so that conda works | |
- run: nox -s "${{ matrix.nox_session }}" | |
shell: bash -l {0} # so that conda works | |
# Share ./docs/reports so that they can be deployed with doc in next job | |
- name: Share reports with other jobs | |
# if: matrix.nox_session == '...': not needed, if empty wont be shared | |
uses: actions/upload-artifact@master | |
with: | |
name: reports_dir | |
path: ./docs/reports | |
publish_release: | |
needs: run_all_tests | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
steps: | |
- name: GitHub context to debug conditional steps | |
env: | |
GITHUB_CONTEXT: ${{ toJSON(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # so that gh-deploy works | |
# 1) retrieve the reports generated previously | |
- name: Retrieve reports | |
uses: actions/download-artifact@master | |
with: | |
name: reports_dir | |
path: ./docs/reports | |
# Conda install | |
- name: Install conda v3.7 | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
# auto-update-conda: true | |
python-version: 3.7 | |
activate-environment: noxenv | |
- run: conda info | |
shell: bash -l {0} # so that conda works | |
- run: conda list | |
shell: bash -l {0} # so that conda works | |
# Nox install | |
- name: Install noxfile requirements | |
shell: bash -l {0} # so that conda works | |
run: pip install -r noxfile-requirements.txt | |
- run: conda list | |
shell: bash -l {0} # so that conda works | |
# 5) Run the flake8 report and badge | |
- name: Run flake8 analysis and generate corresponding badge | |
shell: bash -l {0} # so that conda works | |
run: nox -s flake8 | |
# -------------- only on Ubuntu + MAIN PUSH (no pull request, no tag) ----------- | |
# 5) Publish the doc and test reports | |
- name: \[not on TAG\] Publish documentation, tests and coverage reports | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads') # startsWith(matrix.os,'ubuntu') | |
shell: bash -l {0} # so that conda works | |
run: nox -s publish | |
# 6) Publish coverage report | |
- name: \[not on TAG\] Create codecov.yaml with correct paths | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads') | |
shell: bash | |
run: | | |
cat << EOF > codecov.yml | |
# codecov.yml | |
fixes: | |
- "/home/runner/work/smarie/python-makefun/::" # Correct paths | |
EOF | |
- name: \[not on TAG\] Publish coverage report | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads') | |
uses: codecov/codecov-action@v1 | |
with: | |
files: ./docs/reports/coverage/coverage.xml | |
# -------------- only on Ubuntu + TAG PUSH (no pull request) ----------- | |
# 7) Create github release and build the wheel | |
- name: \[TAG only\] Build wheel and create github release | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
shell: bash -l {0} # so that conda works | |
run: nox -s release -- ${{ secrets.GITHUB_TOKEN }} | |
# 8) Publish the wheel on PyPi | |
- name: \[TAG only\] Deploy on PyPi | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
delete-artifacts: | |
needs: publish_release | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
steps: | |
- uses: kolpav/purge-artifacts-action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
expire-in: 0 # Setting this to 0 will delete all artifacts |