Skip to content

Commit 703d764

Browse files
author
Andy Babic
committed
Configure CI pipelines
1 parent 9b023ba commit 703d764

File tree

7 files changed

+248
-2
lines changed

7 files changed

+248
-2
lines changed

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for more information:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://containers.dev/guide/dependabot
6+
7+
version: 2
8+
updates:
9+
- package-ecosystem: "devcontainers"
10+
directory: "/"
11+
schedule:
12+
interval: weekly

.github/workflows/format.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Format
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- "stable/**"
8+
pull_request:
9+
branches: [main]
10+
11+
jobs:
12+
ruff:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- run: python -Im pip install --user ruff==0.8.4
19+
20+
- name: Run ruff
21+
working-directory: ./mlstreamfield
22+
run: ruff check . --output-format=github

.github/workflows/mypy.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
on: [pull_request]
2+
3+
jobs:
4+
type-check:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- name: Set up Python
9+
uses: actions/setup-python@v5
10+
with:
11+
python-version: '3.x'
12+
- name: Install dependencies
13+
run: |
14+
python -m pip install --upgrade pip flit
15+
python -m flit install --extras type-checking
16+
- name: Run type checker
17+
run: mypy mlstreamfield/ --strict

.github/workflows/publish.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read # to fetch code (actions/checkout)
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.11'
20+
cache: "pip"
21+
cache-dependency-path: "**/pyproject.toml"
22+
23+
- name: ⬇️ Install build dependencies
24+
run: |
25+
python -m pip install -U flit
26+
27+
- name: 🏗️ Build
28+
run: python -m flit build
29+
30+
- uses: actions/upload-artifact@v4
31+
with:
32+
path: ./dist
33+
34+
# https://docs.pypi.org/trusted-publishers/using-a-publisher/
35+
pypi-publish:
36+
needs: build
37+
environment: 'publish'
38+
39+
name: ⬆️ Upload release to PyPI
40+
runs-on: ubuntu-latest
41+
permissions:
42+
# Mandatory for trusted publishing
43+
id-token: write
44+
steps:
45+
- uses: actions/download-artifact@v4
46+
47+
- name: 🚀 Publish package distributions to PyPI
48+
uses: pypa/gh-action-pypi-publish@release/v1
49+
with:
50+
packages-dir: artifact/
51+
print-hash: true

.github/workflows/test.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- "stable/**"
8+
9+
pull_request:
10+
branches: [main]
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
permissions:
17+
contents: read # to fetch code (actions/checkout)
18+
19+
env:
20+
FORCE_COLOR: "1" # Make tools pretty.
21+
TOX_TESTENV_PASSENV: FORCE_COLOR
22+
PIP_DISABLE_PIP_VERSION_CHECK: "1"
23+
PIP_NO_PYTHON_VERSION_WARNING: "1"
24+
PYTHON_LATEST: "3.11"
25+
26+
jobs:
27+
test-sqlite:
28+
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
python-version: ["3.11", "3.12"]
32+
django: ["5.1"]
33+
wagtail: ["6.2", "6.3"]
34+
db: ["sqlite"]
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: Set up Python ${{ matrix.python-version }}
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: ${{ matrix.python-version }}
42+
43+
- name: Install dependencies
44+
run: |
45+
python -Im pip install --upgrade pip flit tox tox-gh-actions
46+
47+
- name: 🏗️ Build wheel
48+
run: python -Im flit build --format wheel
49+
50+
- name: Test
51+
env:
52+
TOXENV: py${{ matrix.python-version }}-django${{ matrix.django }}-wagtail${{ matrix.wagtail }}-sqlite
53+
run: |
54+
tox --installpkg ./dist/*.whl
55+
56+
- name: ⬆️ Upload coverage data
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: coverage-data-${{ matrix.python-version }}-${{ matrix.django }}-${{ matrix.wagtail }}-sqlite
60+
path: .coverage
61+
if-no-files-found: error
62+
include-hidden-files: true
63+
64+
test-postgres:
65+
runs-on: ubuntu-latest
66+
strategy:
67+
matrix:
68+
python-version: ["3.12"]
69+
django: ["5.1"]
70+
wagtail: ["6.2", "6.3"]
71+
db: ["postgres"]
72+
73+
services:
74+
postgres:
75+
image: postgres:15
76+
env:
77+
POSTGRES_PASSWORD: postgres
78+
ports:
79+
- 5432:5432
80+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
81+
82+
steps:
83+
- uses: actions/checkout@v4
84+
- name: Set up Python ${{ matrix.python-version }}
85+
uses: actions/setup-python@v5
86+
with:
87+
python-version: ${{ matrix.python-version }}
88+
- name: Install dependencies
89+
run: |
90+
python -Im pip install --upgrade pip flit tox tox-gh-actions
91+
92+
- name: 🏗️ Build wheel
93+
run: python -Im flit build --format wheel
94+
95+
- name: Test
96+
env:
97+
DATABASE_URL: postgres://postgres:postgres@localhost:5432/wagtail_wheelhouse_git
98+
run: tox --installpkg ./dist/*.whl
99+
100+
- name: ⬆️ Upload coverage data
101+
uses: actions/upload-artifact@v4
102+
with:
103+
name: coverage-data-${{ matrix.python-version }}-${{ matrix.django }}-${{ matrix.wagtail }}-postgres
104+
path: .coverage
105+
if-no-files-found: error
106+
include-hidden-files: true
107+
108+
coverage:
109+
runs-on: ubuntu-latest
110+
needs:
111+
- test-sqlite
112+
- test-postgres
113+
114+
steps:
115+
- uses: actions/checkout@v4
116+
- uses: actions/setup-python@v5
117+
with:
118+
# Use latest Python, so it understands all syntax.
119+
python-version: ${{env.PYTHON_LATEST}}
120+
121+
- run: python -Im pip install --upgrade coverage
122+
123+
- name: ⬇️ Download coverage data
124+
uses: actions/download-artifact@v4
125+
with:
126+
pattern: coverage-data-*
127+
merge-multiple: true
128+
129+
- name: + Combine coverage
130+
run: |
131+
python -Im coverage combine
132+
python -Im coverage html --skip-covered --skip-empty
133+
python -Im coverage report
134+
echo "## Coverage summary" >> $GITHUB_STEP_SUMMARY
135+
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
136+
- name: 📈 Upload HTML report
137+
uses: actions/upload-artifact@v4
138+
with:
139+
name: html-report
140+
path: htmlcov
141+
if-no-files-found: error
142+
include-hidden-files: true
143+
retention-days: 1

ruff.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ extend-select = [
1919
]
2020

2121
extend-ignore = [
22-
"E501", # no line lenght errors
22+
"E501", # no line length errors
2323
]
2424
fixable = ["C4", "E", "F", "I", "UP"]
2525

2626
[lint.isort]
27-
known-first-party = ["src", "mlstreamfield"]
27+
known-first-party = ["mlstreamfield"]
2828
lines-between-types = 1
2929
lines-after-imports = 2
3030

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ deps =
3939
install_command = python -Im pip install -U --pre {opts} {packages}
4040
commands =
4141
python -m coverage run {toxinidir}/testmanage.py test --deprecation all {posargs: -v 2}
42+
python -m coverage combine
4243

4344
[testenv:coverage-report]
4445
base_python = python3.12

0 commit comments

Comments
 (0)