-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
github actions: Try to parameterise testing
Having separate action files for different Python versions sucks.
- Loading branch information
1 parent
0b23433
commit 681789c
Showing
2 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Pre-merge and post-merge tests | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test: | ||
name: Run tests | ||
uses: ./.github/workflows/test.yml | ||
# https://wildwolf.name/github-actions-how-to-avoid-running-the-same-workflow-multiple-times/ | ||
if: > | ||
github.event_name != 'pull_request' | ||
|| github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | ||
strategy: | ||
matrix: | ||
python: | ||
- "3.5" | ||
- "3.11" | ||
- "3.12" | ||
platform: | ||
# This package is supposed to be OS-independent and is unlikely to have | ||
# OS-specific bugs, so we conserve runner usage by only testing on Linux | ||
# during pre-merge and post-merge testing. If it works on Linux, it'll | ||
# probably work on Mac and Windows too. But if an OS-specific bug does | ||
# slip through, we should catch it in pre-release testing. | ||
- ubuntu-latest | ||
exclude: | ||
# Python 3.5 does not run on ubuntu-latest | ||
- python: "3.5" | ||
platform: ubuntu-latest | ||
include: | ||
- python: "3.5" | ||
platform: ubuntu-20.04 | ||
- python: "3.12" | ||
platform: ubuntu-latest | ||
with: | ||
python-version: ${{ matrix.python }} | ||
platform: ${{ matrix.platform }} | ||
|
||
check: # This job does nothing and is only used for the branch protection | ||
# https://wildwolf.name/github-actions-how-to-avoid-running-the-same-workflow-multiple-times/ | ||
if: > | ||
github.event_name != 'pull_request' | ||
|| github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | ||
needs: | ||
- test | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Decide whether the needed jobs succeeded or failed | ||
uses: re-actors/alls-green@release/v1 | ||
with: | ||
jobs: ${{ toJSON(needs) }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Reusable workflow that runs all tests | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
python-version: | ||
type: string | ||
required: true | ||
platform: | ||
type: string | ||
required: true | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
# Environment variables to support color support (jaraco/skeleton#66): | ||
# Request colored output from CLI tools supporting it. Different tools | ||
# interpret the value differently. For some, just being set is sufficient. | ||
# For others, it must be a non-zero integer. For yet others, being set | ||
# to a non-empty value is sufficient. For tox, it must be one of | ||
# <blank>, 0, 1, false, no, off, on, true, yes. The only enabling value | ||
# in common is "1". | ||
FORCE_COLOR: 1 | ||
# Recognized by the `py` package, dependency of `pytest` (must be "1") | ||
PY_COLORS: 1 | ||
|
||
# Suppress noisy pip warnings | ||
PIP_DISABLE_PIP_VERSION_CHECK: 'true' | ||
PIP_NO_PYTHON_VERSION_WARNING: 'true' | ||
PIP_NO_WARN_SCRIPT_LOCATION: 'true' | ||
|
||
|
||
jobs: | ||
test: | ||
runs-on: ${{ inputs.platform }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
allow-prereleases: true | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 pytest coverage coverage-lcov toml pint | ||
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. | ||
flake8 . --count --exit-zero --max-complexity=10 --statistics | ||
- name: Test with py.test | ||
run: | | ||
coverage run -m pytest | ||
coverage-lcov | ||
- name: Coveralls | ||
uses: coverallsapp/github-action@master | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
path-to-lcov: ./lcov.info |