Use an organization variable for the Python testing matrix entries #15
Workflow file for this run
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: Build | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
pull_request: | |
env: | |
ARCALOT_PYTHON_SUPPORTED_VERSIONS: ${{ '[ "3.9", "3.10", "3.11", "3.12", "pypy3.9" ]' }} | |
jobs: | |
build: | |
name: Build | |
strategy: | |
matrix: | |
python-version: ${{ fromJSON(toJSON(vars.ARCALOT_PYTHON_SUPPORTED_VERSIONS)) }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Update version number | |
if: startsWith(github.ref, 'refs/tags/') | |
run: sed -i -e "s/0.0.0/${GITHUB_REF##*/}/" pyproject.toml | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Check isort, black, and flake8 | |
run: | | |
pip install black flake8 isort | |
isort --profile black . | |
black --line-length 79 . | |
flake8 . | |
- name: Install Python Poetry | |
uses: snok/[email protected] | |
with: | |
version: 1.4.2 | |
- name: Install project dependencies | |
run: poetry install --no-interaction | |
- name: Run tests with coverage | |
run: | | |
# Run the unit tests | |
poetry run python3 -m coverage run -a -m unittest discover -v src | |
# Generate the coverage HTML report | |
poetry run python3 -m coverage html | |
- name: Publish coverage report to job summary | |
# publishing only once | |
if: ${{ matrix.python-version == vars.ARCALOT_PYTHON_VERSION }} | |
run: | | |
poetry run html2text --ignore-images --ignore-links -b 0 htmlcov/index.html >> $GITHUB_STEP_SUMMARY | |
- name: Generate documentation | |
if: ${{ matrix.python-version == vars.ARCALOT_PYTHON_VERSION }} | |
run: | | |
poetry run sphinx-apidoc -o docs/ -f -a -e src/ --doc-project "Kubernetes library for Arcaflow" | |
poetry run make -C docs html | |
- name: Build | |
run: poetry build | |
- name: Upload dist artifact | |
if: ${{ matrix.python-version == vars.ARCALOT_PYTHON_VERSION }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
if-no-files-found: error | |
- name: Upload coverage HTML artifact | |
if: ${{ matrix.python-version == vars.ARCALOT_PYTHON_VERSION }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage | |
path: htmlcov | |
if-no-files-found: error | |
- name: Upload Sphinx documentation | |
if: ${{ matrix.python-version == vars.ARCALOT_PYTHON_VERSION }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: documentation | |
path: docs/build/html | |
if-no-files-found: error | |
publish: | |
name: Publish | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
- name: Install twine | |
run: pip install -U twine | |
- name: Publish | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{secrets.PYPI_TOKEN}} | |
TWINE_NON_INTERACTIVE: true | |
run: twine upload dist/* |