Skip to content

Commit 5416e51

Browse files
authored
ci: add test pipeline (#3)
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent b818cbd commit 5416e51

2 files changed

Lines changed: 136 additions & 20 deletions

File tree

‎.github/workflows/python-publish.yml‎

Lines changed: 57 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,67 @@ name: Upload Python Package
1010

1111
on:
1212
release:
13-
types: [published]
13+
types: [ published ]
14+
15+
env:
16+
PYTHON_VERSION_DEFAULT: "3.14"
1417

1518
permissions:
1619
contents: read
1720

1821
jobs:
19-
deploy:
20-
22+
quick-test:
23+
name: QuickTest
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
# see https://github.com/actions/checkout
28+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
29+
with:
30+
persist-credentials: false
31+
- name: Setup Python Environment
32+
# see https://github.com/actions/setup-python
33+
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
34+
with:
35+
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
36+
architecture: 'x64'
37+
- name: Validate Python Environment
38+
shell: python
39+
run: |
40+
import sys
41+
print('Python %s on %s in %s' % (sys.version, sys.platform, sys.getdefaultencoding()))
42+
- name: Install env dependencies
43+
run: python -m pip install --upgrade pip
44+
- name: Install project
45+
run: python -m pip install --user -e ".[testing]"
46+
- name: Run Tests
47+
run: python -m pytest tests
48+
publish:
49+
name: Publish
50+
needs:
51+
- quick-test
2152
runs-on: ubuntu-latest
22-
2353
steps:
24-
- uses: actions/checkout@v3
25-
- name: Set up Python
26-
uses: actions/setup-python@v3
27-
with:
28-
python-version: '3.x'
29-
- name: Install dependencies
30-
run: |
31-
python -m pip install --upgrade pip
32-
pip install build
33-
- name: Build package
34-
run: python -m build
35-
- name: Publish package
36-
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
37-
with:
38-
user: __token__
39-
password: ${{ secrets.PYPI_API_TOKEN }}
54+
- name: Checkout
55+
# see https://github.com/actions/checkout
56+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
57+
with:
58+
persist-credentials: false
59+
- name: Setup Python Environment
60+
# see https://github.com/actions/setup-python
61+
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
62+
with:
63+
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
64+
architecture: 'x64'
65+
- name: Install env dependencies
66+
run: |
67+
python -m pip install --upgrade pip
68+
python -m pip install build
69+
- name: Build package
70+
run: python -m build
71+
- name: Publish package
72+
# see https://github.com/pypa/gh-action-pypi-publish
73+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 # v1.4.2
74+
with:
75+
user: __token__
76+
password: ${{ secrets.PYPI_API_TOKEN }}

‎.github/workflows/python-tests.yml‎

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
10+
name: Python CI
11+
12+
on:
13+
workflow_dispatch:
14+
pull_request:
15+
push:
16+
tags: [ 'v*' ] # run again on release tags to have tools mark them
17+
branches: [ 'main', 'next' ]
18+
schedule:
19+
# schedule daily tests, since some dependencies are not intended to be pinned
20+
# this means: at 23:42 every day
21+
- cron: '42 23 * * *'
22+
23+
env:
24+
PYTHON_VERSION_DEFAULT: "3.14"
25+
26+
permissions:
27+
contents: read
28+
29+
jobs:
30+
build-and-test:
31+
name: Test (${{ matrix.os }} py${{ matrix.python-version }} ${{ matrix.toxenv-factors }})
32+
runs-on: ${{ matrix.os }}
33+
timeout-minutes: 15
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
os:
38+
- ubuntu-latest
39+
- macos-latest
40+
- windows-latest
41+
python-version:
42+
- "3.14" # highest supported
43+
- "3.13"
44+
- "3.12"
45+
- "3.11"
46+
- "3.10"
47+
- "3.9" # lowest supported
48+
exclude:
49+
- os: macos-latest # macos-latest is incompatible with some PY versions
50+
python-version: "3.10"
51+
- os: macos-latest # macos-latest is incompatible with some PY versions
52+
python-version: "3.9"
53+
steps:
54+
- name: Disabled Git auto EOL CRLF transforms
55+
run: |
56+
git config --global core.autocrlf false
57+
git config --global core.eol lf
58+
- name: Checkout
59+
# see https://github.com/actions/checkout
60+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
61+
with:
62+
persist-credentials: false
63+
- name: Setup Python Environment
64+
# see https://github.com/actions/setup-python
65+
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
66+
with:
67+
python-version: ${{ matrix.python-version }}
68+
architecture: 'x64'
69+
- name: Validate Python Environment
70+
shell: python
71+
run: |
72+
import sys
73+
print('Python %s on %s in %s' % (sys.version, sys.platform, sys.getdefaultencoding()))
74+
- name: Install env dependencies
75+
run: python -m pip install --upgrade pip
76+
- name: Install project
77+
run: pip install --user -e ".[testing]"
78+
- name: Run Tests
79+
run: python -m pytest tests

0 commit comments

Comments
 (0)