Skip to content

3.6.0.rc2

3.6.0.rc2 #443

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python application
on:
push:
# branches: [ "master" ]
pull_request:
branches: [ "master" ]
release:
branches: [ "master" ]
permissions:
contents: read
jobs:
verify:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
# - uses: actions/checkout@v4
- uses: actions/checkout@master
- name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v5
uses: actions/setup-python@master
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 coverage setuptools build
pip install -e .
# python -c "import configparser; c=configparser.ConfigParser(); c.read('setup.cfg'); print(c['options']['install_requires'])" > requirements.txt
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: File list
run: |
ls -lR
- name: Run Unit Tests and Generate Coverage Report
run: |
# Ensure temporary files are created in a unique, local directory
export TMPDIR=${RUNNER_TEMP}
coverage run -m unittest discover tests -t .
coverage report -m
coverage xml
coverage html
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
# with:
# name: codecov-imagedata
# fail_ci_if_error: false
# flags: unittests
# verbose: false
# env:
# token: ${{ secrets.CODECOV_TOKEN }}
# - name: Archive code coverage html report
# uses: actions/upload-artifact@v4
# with:
# name: code-coverage-report
# path: htmlcov
build_wheel:
name: Build wheel and source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
pip install --upgrade pip wheel
- name: Build wheels
run: |
pipx run build --sdist --wheel
ls -l dist
- uses: actions/upload-artifact@v4
with:
path: dist/*
publish-to-pypi:
name: Publish Python distribution to PyPi
# if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs: [verify, build_wheel]
runs-on: ubuntu-latest
environment:
name: pypi
permissions:
contents: read
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this)
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
path: dist
# - name: Verify distribution
# run: |
# pip install twine pillow
# twine check dist/*
- name: Upload distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1