Skip to content

Commit c172cf6

Browse files
authored
Modernize (#149)
* Move docs to root Signed-off-by: Bradley Reynolds <bradley.reynolds@tailstory.dev> * Upgrade dependencies Signed-off-by: Bradley Reynolds <bradley.reynolds@tailstory.dev> * Modernize code Signed-off-by: Bradley Reynolds <bradley.reynolds@tailstory.dev> * Modernize CI Signed-off-by: Bradley Reynolds <bradley.reynolds@tailstory.dev> * Fixup the oopses Signed-off-by: Bradley Reynolds <bradley.reynolds@tailstory.dev> * Appease Zizmor Signed-off-by: Bradley Reynolds <bradley.reynolds@tailstory.dev> * Copilot is annoying Copilot wants this to be `self` but that gets this error from Pydantic: pydantic.errors.PydanticUserError: The `@field_validator` decorator cannot be applied to instance methods Signed-off-by: Bradley Reynolds <bradley.reynolds@tailstory.dev> * Ruff is also annoying Signed-off-by: Bradley Reynolds <bradley.reynolds@tailstory.dev> --------- Signed-off-by: Bradley Reynolds <bradley.reynolds@tailstory.dev>
1 parent 0dde927 commit c172cf6

22 files changed

Lines changed: 1066 additions & 665 deletions

.github/dependabot.yaml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "devcontainers"
4-
directory: "/"
3+
- package-ecosystem: github-actions
4+
directory: /
55
schedule:
6-
interval: "monthly"
7-
8-
- package-ecosystem: "github-actions"
9-
directory: "/"
10-
schedule:
11-
interval: "monthly"
6+
interval: monthly
127
groups:
138
ci-dependencies:
149
patterns:
1510
- "*"
11+
cooldown:
12+
default-days: 7
1613

17-
- package-ecosystem: "uv"
18-
directory: "/"
14+
- package-ecosystem: uv
15+
directory: /
1916
schedule:
20-
interval: "monthly"
17+
interval: monthly
2118
groups:
2219
python-dependencies:
2320
patterns:
2421
- "*"
22+
cooldown:
23+
default-days: 7
2524

26-
- package-ecosystem: "docker"
27-
directory: "/"
25+
- package-ecosystem: pre-commit
26+
directory: /
2827
schedule:
29-
interval: "monthly"
28+
interval: monthly
3029
groups:
31-
docker-dependencies:
30+
pre-commit-dependencies:
3231
patterns:
3332
- "*"
33+
cooldown:
34+
default-days: 7
Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,77 @@
1-
name: Container Build and Deploy
1+
name: Image build and deploy
22

33
on:
44
push:
55
branches:
66
- main
77
tags:
8-
- v*
8+
- "*"
99
pull_request:
1010

1111
permissions:
1212
contents: read
13-
packages: write
14-
# Used by actions/attest-build-provenance
15-
id-token: write
16-
attestations: write
13+
14+
env:
15+
# Use docker.io for Docker Hub if empty
16+
REGISTRY: ghcr.io
17+
# github.repository as <account>/<repo>
18+
IMAGE_NAME: ${{ github.repository }}
1719

1820
jobs:
1921
build-push:
20-
uses: darbiadev/.github/.github/workflows/container-build-push.yaml@440166417b42442c6114aaa895094f0db7de9b78 # v15.2.0
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
packages: write
26+
id-token: write
27+
attestations: write
28+
outputs:
29+
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
30+
digest: ${{ steps.build-and-push.outputs.digest }}
31+
steps:
32+
- name: Setup Docker buildx
33+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
34+
35+
- name: Log into registry ${{ env.REGISTRY }}
36+
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
37+
with:
38+
registry: ${{ env.REGISTRY }}
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Extract Docker metadata
43+
id: meta
44+
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
45+
with:
46+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
47+
tags: |
48+
type=raw,value=${{ github.sha }}
49+
type=ref,event=tag
50+
type=edge
51+
env:
52+
# ghcr.io prefers index level annotations
53+
DOCKER_METADATA_ANNOTATIONS_LEVELS: index
54+
55+
- name: Build and push Docker image
56+
id: build-and-push
57+
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
58+
with:
59+
file: Dockerfile
60+
push: ${{ github.ref == 'refs/heads/main' || startswith(github.event.ref, 'refs/tags/') }}
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}
63+
annotations: ${{ steps.meta.outputs.annotations }}
64+
build-args: |
65+
git_sha=${{ github.sha }}
66+
cache-from: type=gha
67+
cache-to: type=gha,mode=max
68+
provenance: mode=max
69+
sbom: true
2170

2271
deploy:
2372
needs: build-push
2473
runs-on: ubuntu-latest
2574
if: ${{ github.ref == 'refs/heads/main' }}
2675
steps:
27-
- name: "Update deployment"
76+
- name: Update deployment
2877
run: curl -X POST '${{ secrets.DEPLOY_WEBHOOK }}'
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
name: "Dependency Review"
1+
name: Dependency Review
22

33
on:
4+
push:
5+
branches:
6+
- main
47
pull_request:
58

69
permissions:
710
contents: read
811

912
jobs:
1013
dependency-review:
11-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-slim
1215

1316
steps:
14-
- name: "Checkout Repository"
17+
- name: Checkout Repository
1518
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
19+
with:
20+
persist-credentials: false
1621

17-
- name: "Dependency Review"
22+
- name: Dependency Review
1823
uses: actions/dependency-review-action@2031cfc080254a8a887f58cffee85186f0e49e48 # v4.9.0
1924
with:
2025
config-file: darbiadev/.github/.github/dependency-review-config.yaml@main

.github/workflows/docs.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-slim
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
19+
with:
20+
persist-credentials: false
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
24+
with:
25+
enable-cache: true
26+
27+
- name: Setup Python
28+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
29+
with:
30+
python-version-file: "pyproject.toml"
31+
32+
- name: Sync dependencies
33+
run: uv sync --group docs
34+
35+
- name: Build docs
36+
run: uv run sphinx-build --builder dirhtml --nitpicky docs site
37+
38+
- name: Upload artifact
39+
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
40+
with:
41+
path: ./site
42+
43+
deploy:
44+
if: ${{ github.ref == 'refs/heads/main' }}
45+
46+
permissions:
47+
contents: read
48+
pages: write
49+
id-token: write
50+
51+
environment:
52+
name: github-pages
53+
url: ${{ steps.deployment.outputs.page_url }}
54+
55+
runs-on: ubuntu-slim
56+
57+
needs: build
58+
steps:
59+
- name: Deploy to GitHub Pages
60+
id: deployment
61+
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0

.github/workflows/python-ci.yaml

Lines changed: 87 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,34 @@ on:
66
- main
77
pull_request:
88

9-
jobs:
10-
lint-test:
11-
runs-on: ubuntu-latest
9+
permissions:
10+
contents: read
1211

12+
jobs:
13+
lint:
14+
runs-on: ubuntu-slim
1315
steps:
1416
- name: Checkout repository
1517
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
18+
with:
19+
persist-credentials: false
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
23+
with:
24+
enable-cache: true
25+
resolution-strategy: "lowest"
1626

1727
- name: Setup Python
1828
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
1929
with:
20-
python-version: 3.12
21-
allow-prereleases: true
22-
cache: pip
23-
cache-dependency-path: uv.lock
24-
25-
- name: Set up uv
26-
run: curl -LsSf https://astral.sh/uv/install.sh | sh
30+
python-version-file: "pyproject.toml"
2731

2832
- name: Sync dependencies
2933
run: uv sync --group dev --group tests
3034

31-
- name: Run pre-commit
32-
run: uv run pre-commit run --all-files
35+
- name: Run prek
36+
run: uv run prek run --all-files
3337

3438
- name: Check formatting
3539
run: uv run ruff format --check .
@@ -38,21 +42,81 @@ jobs:
3842
run: uv run ruff check --output-format=github .
3943

4044
- name: Run mypy
41-
run: uv run mypy --strict src/
45+
run: uv run mypy --strict src/ tests/
4246

43-
- name: Run tests
44-
run: uv run python -m coverage run -m pytest -v
47+
- name: Run ty
48+
run: uv run ty check .
4549

46-
- name: Upload coverage reports to Codecov
47-
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
48-
env:
49-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
50+
test:
51+
runs-on: ubuntu-slim
52+
steps:
53+
- name: Checkout repository
54+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
55+
with:
56+
persist-credentials: false
5057

51-
docs:
52-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
58+
- name: Install uv
59+
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
60+
with:
61+
enable-cache: true
62+
resolution-strategy: "lowest"
63+
64+
- name: Setup Python
65+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
66+
with:
67+
python-version: 3.14
68+
69+
- name: Sync dependencies
70+
run: uv sync --group dev --group tests
71+
72+
- name: Run tests with coverage
73+
run: uv run python -m coverage run -m pytest -v --junitxml=junit.xml
74+
75+
- name: Create coverage report
76+
run: uv run coverage xml -o coverage.xml
77+
78+
- name: Upload coverage reports
79+
if: ${{ !cancelled() }}
80+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
81+
with:
82+
name: coverage-reports
83+
path: |
84+
coverage.xml
85+
junit.xml
86+
if-no-files-found: error
87+
88+
codecov:
89+
runs-on: ubuntu-slim
90+
needs: [test]
91+
if: ${{ always() }}
5392
permissions:
5493
contents: read
55-
pages: write
5694
id-token: write
95+
steps:
96+
- name: Checkout repository
97+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
98+
with:
99+
persist-credentials: false
100+
101+
- name: Download coverage reports
102+
if: ${{ !cancelled() }}
103+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
104+
with:
105+
name: coverage-reports
106+
path: coverage
107+
108+
- name: Upload coverage to Codecov
109+
if: ${{ !cancelled() }}
110+
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
111+
with:
112+
report_type: coverage
113+
use_oidc: true
114+
files: coverage/coverage.xml
57115

58-
uses: darbiadev/.github/.github/workflows/github-pages-python-sphinx.yaml@440166417b42442c6114aaa895094f0db7de9b78 # v15.2.0
116+
- name: Upload test results to Codecov
117+
if: ${{ !cancelled() }}
118+
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0
119+
with:
120+
report_type: test_results
121+
use_oidc: true
122+
files: coverage/junit.xml

.github/workflows/sentry-release.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
name: "Sentry release"
1+
name: Sentry release
22

33
on:
44
push:
55
branches:
66
- main
77

8+
permissions:
9+
contents: read
10+
811
jobs:
912
sentry-release:
1013
runs-on: ubuntu-latest
1114

1215
steps:
13-
- name: "Checkout repository"
16+
- name: Checkout repository
1417
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
18+
with:
19+
persist-credentials: false
1520

16-
- name: "Create Sentry release"
21+
- name: Create Sentry release
1722
uses: getsentry/action-release@5657c9e888b4e2cc85f4d29143ea4131fde4a73a # v3.6.0
1823
env:
1924
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}

0 commit comments

Comments
 (0)