Skip to content

Version 20230906

Version 20230906 #145

Workflow file for this run

# GitHub Actions docs: https://docs.github.com/en/actions/learn-github-actions
# Reference syntax: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
# Env. variables: https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables
# Add'l variables: https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions
# Requires encrypted secret (see https://docs.github.com/en/actions/reference/encrypted-secrets) secrets.pypi_password
# This file is automatically "updated" with PRs by the "pre-commit ci" app in GitHub https://pre-commit.ci; it is
# currently scheduled weekly at approximately 16:00 UTC Monday.
name: Test and deploy release
on: [push, pull_request, workflow_dispatch]
env:
FORCE_COLOR: 1
PYTHONUNBUFFERED: 1
PYTHONUTF8: 1
jobs:
# Set the job key. The key is displayed as the job name
# when a job name is not provided
# PRE-COMMIT IS ALREADY DONE BY GIT
# pre-commit:
# # Name the Job
# name: Quality assurance (pre-commit)
# # Set the type of machine to run on
# runs-on: ubuntu-latest
#
# steps:
# # Checks out a copy of the repository per https://github.com/actions/checkout
# - name: Check out repo
# uses: actions/checkout@main
#
# # Build Python and packages per https://github.com/actions/setup-python
# - name: Set up Python
# uses: actions/setup-python@main
# with:
# python-version: '3.11' # same as https://docs.readthedocs.io/en/stable/config-file/v2.html#build-tools-python
# cache: 'pip'
# cache-dependency-path: |
# requirements.txt
# tests/requirements_pre-commit.txt
#
# # Install dependencies needed by the repo: local in .pre-commit-config.yaml
# - name: Install dependencies
# run: |
# pip install -U pip wheel
# if [ -f tests/requirements_pre-commit.txt ]; then pip install -U -r tests/requirements_pre-commit.txt; fi
# if [ -f requirements.txt ]; then pip install -U -r requirements.txt; fi
#
# # The below has been replaced with the integration in GitHub of the "pre-commit ci" app https://pre-commit.ci
# # # Run pre-commit cache per https://github.com/pre-commit/action
# # - name: Run pre-commit
# # uses: pre-commit/action@v2.0.3
test:
name: "Test (${{ matrix.python-version }}, ${{ matrix.os }})"
# matrix.os is defined in strategy
runs-on: ${{ matrix.os }}
# Identifies any jobs that must complete successfully before this job will run
# needs: [pre-commit]
# A strategy creates a build matrix for your jobs. You can define different variations to run each job in
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.11', '3.10', '3.9', '3.8', '3.12.0-rc.1']
# for valid python-version see https://github.com/actions/python-versions/releases
env:
commitmsg: ${{ github.event.head_commit.message }} # only available at check-out; becomes env.commitmsg
steps:
# Checks out a copy of the repository per https://github.com/actions/checkout
- name: Check out repo
uses: actions/checkout@main
# Build Python and packages per https://github.com/actions/setup-python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@main
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
# pip -e installs a project in editable mode (i.e. setuptools “develop mode”) from a local project path
run: |
pip install -U pip setuptools wheel
pip install -U .
pip install -U coveralls -r tests/requirements_testing.txt
- name: Run tests (Linux/MacOS)
if: runner.os == 'Linux' || runner.os == 'macOS'
run:
python -m pytest tests/ -v --cov=./ --cov-report term --cov-report html --cov-report xml --cov-config=.coveragerc
env:
PYTHONUTF8: 1
- name: Run tests (Windows)
if: runner.os == 'Windows'
run:
# workaround for Windows fatal exception: access violation
python -m pytest tests/ -v --cov=./ --cov-report term --cov-report html --cov-report xml --cov-config=.coveragerc -p no:faulthandler
env:
PYTHONUTF8: 1
# # below not working as pytest-cov does not create the ./coverage/lcov.info file!
# - name: Upload LCOV coverage data to Coveralls
# uses: coverallsapp/github-action@master
# with:
# github-token: ${{ secrets.github_token }}
# flag-name: tests-${{ matrix.python-version }}-${{ matrix.os }}
# parallel: true
- name: Upload coverage to Coveralls (parallel)
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
COVERALLS_FLAG_NAME: tests-${{ matrix.python-version }}-${{ matrix.os }}
COVERALLS_PARALLEL: true
coveralls:
name: Indicate completion to coveralls.io
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Coveralls parallel finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
deploy:
name: Deploy release
runs-on: ubuntu-latest
# ref https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
needs: [test]
steps:
- name: Check out repo
uses: actions/checkout@main
- name: Set up Python
uses: actions/setup-python@main
with:
python-version: '3.11'
cache: 'pip'
# Install pip dependencies
- name: Install dependencies
run: |
pip install -U pip build
- name: Build dist
run: |
python -m build
# PyPI publish GitHub Action from https://github.com/pypa/gh-action-pypi-publish
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}
- name: Create GitHub release
id: create_release
uses: actions/create-release@main
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body_path: RELEASE.rst
draft: false
prerelease: false