|
|
|
|
|
name: Build |
|
|
on: |
|
|
|
|
|
workflow_dispatch: |
|
|
|
|
|
push: |
|
|
tags: |
|
|
- '*' |
|
|
branches: |
|
|
- main |
|
|
pull_request: |
|
|
branches: |
|
|
- main |
|
|
|
|
|
defaults: |
|
|
run: |
|
|
shell: bash -l {0} |
|
|
|
|
|
jobs: |
|
|
|
|
|
list_nox_test_sessions: |
|
|
runs-on: ubuntu-latest |
|
|
steps: |
|
|
- name: Checkout |
|
|
uses: actions/checkout@v4.1.1 |
|
|
|
|
|
- name: Install python 3.9 |
|
|
uses: actions/setup-python@v5.0.0 |
|
|
with: |
|
|
python-version: 3.9 |
|
|
architecture: x64 |
|
|
|
|
|
- name: Install noxfile requirements |
|
|
run: pip install -r noxfile-requirements.txt |
|
|
|
|
|
- name: List 'tests' nox sessions and required python versions |
|
|
id: set-matrix |
|
|
run: echo "matrix=$(nox --json -l -s tests -v)" >> $GITHUB_OUTPUT |
|
|
|
|
|
outputs: |
|
|
matrix: ${{ steps.set-matrix.outputs.matrix }} |
|
|
|
|
|
run_all_tests: |
|
|
needs: list_nox_test_sessions |
|
|
strategy: |
|
|
fail-fast: false |
|
|
matrix: |
|
|
|
|
|
|
|
|
os: [ ubuntu-latest ] |
|
|
|
|
|
|
|
|
nox_session: ${{ fromJson(needs.list_nox_test_sessions.outputs.matrix) }} |
|
|
|
|
|
name: ${{ matrix.os }} ${{ matrix.nox_session.python }} ${{ matrix.nox_session.session }} |
|
|
runs-on: ${{ matrix.os }} |
|
|
steps: |
|
|
- name: Checkout |
|
|
uses: actions/checkout@v4.1.1 |
|
|
|
|
|
- name: Install python ${{ matrix.nox_session.python }} for tests |
|
|
if: ${{ ! contains(fromJson('["3.13"]'), matrix.nox_session.python ) }} |
|
|
uses: MatteoH2O1999/setup-python@v3.2.1 |
|
|
id: set-py |
|
|
with: |
|
|
python-version: ${{ matrix.nox_session.python }} |
|
|
architecture: x64 |
|
|
allow-build: info |
|
|
cache-build: true |
|
|
|
|
|
- name: Install python ${{ matrix.nox_session.python }} for tests (3.13) |
|
|
if: contains(fromJson('["3.13"]'), matrix.nox_session.python ) |
|
|
uses: actions/setup-python@v5 |
|
|
id: set-py-latest |
|
|
with: |
|
|
|
|
|
|
|
|
python-version: ${{ format('~{0}.0-alpha.0', matrix.nox_session.python) }} |
|
|
architecture: x64 |
|
|
allow-build: info |
|
|
cache-build: true |
|
|
|
|
|
- name: Install python 3.12 for nox |
|
|
uses: actions/setup-python@v5.0.0 |
|
|
with: |
|
|
python-version: 3.12 |
|
|
architecture: x64 |
|
|
|
|
|
- name: pin virtualenv==20.15.1 in old python versions |
|
|
|
|
|
if: contains(fromJson('["2.7", "3.5", "3.6"]'), matrix.nox_session.python ) |
|
|
run: sed -i "s/virtualenv/virtualenv==20.15.1/g" noxfile-requirements.txt |
|
|
|
|
|
- name: Install noxfile requirements |
|
|
run: pip install -r noxfile-requirements.txt |
|
|
|
|
|
- name: Run nox session ${{ matrix.nox_session.session }} |
|
|
run: nox -s "${{ matrix.nox_session.session }}" -v |
|
|
|
|
|
|
|
|
- name: Share reports with other jobs |
|
|
if: runner.os == 'Linux' |
|
|
uses: actions/upload-artifact@v4.3.0 |
|
|
with: |
|
|
name: reports_dir |
|
|
path: ./docs/reports |
|
|
|
|
|
build_doc: |
|
|
runs-on: ubuntu-latest |
|
|
if: github.event_name == 'pull_request' |
|
|
steps: |
|
|
- name: Checkout |
|
|
uses: actions/checkout@v4.1.1 |
|
|
|
|
|
- name: Install python 3.9 for nox |
|
|
uses: actions/setup-python@v5.0.0 |
|
|
with: |
|
|
python-version: 3.9 |
|
|
architecture: x64 |
|
|
|
|
|
- name: Install noxfile requirements |
|
|
run: pip install -r noxfile-requirements.txt |
|
|
|
|
|
- name: Build the doc including example gallery |
|
|
run: nox -s docs -- build |
|
|
|
|
|
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" |
|
|
|
|
|
- name: Checkout with no depth |
|
|
uses: actions/checkout@v4.1.1 |
|
|
with: |
|
|
fetch-depth: 0 |
|
|
|
|
|
- name: Install python 3.9 for nox |
|
|
uses: actions/setup-python@v5.0.0 |
|
|
with: |
|
|
python-version: 3.9 |
|
|
architecture: x64 |
|
|
|
|
|
|
|
|
- name: Retrieve reports |
|
|
uses: actions/download-artifact@v4.1.1 |
|
|
with: |
|
|
name: reports_dir |
|
|
path: ./docs/reports |
|
|
|
|
|
|
|
|
- name: Install noxfile requirements |
|
|
run: pip install -r noxfile-requirements.txt |
|
|
|
|
|
|
|
|
- name: Run flake8 analysis and generate corresponding badge |
|
|
run: nox -s flake8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: \[not on TAG\] Publish documentation, tests and coverage reports |
|
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads') |
|
|
run: nox -s publish |
|
|
|
|
|
|
|
|
- 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@v4.0.1 |
|
|
with: |
|
|
files: ./docs/reports/coverage/coverage.xml |
|
|
- name: \[not on TAG\] Build wheel and sdist |
|
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads') |
|
|
run: nox -s build |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: \[TAG only\] Build wheel and create github release |
|
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
|
|
run: nox -s release -- ${{ secrets.GITHUB_TOKEN }} |
|
|
|
|
|
|
|
|
- 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 |
|
|
|