Skip to content

Commit 31b887a

Browse files
add github workflows
1 parent f813220 commit 31b887a

File tree

6 files changed

+264
-0
lines changed

6 files changed

+264
-0
lines changed

.github/dependabot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
- package-ecosystem: "devcontainers"
8+
directory: "/"
9+
schedule:
10+
interval: "daily"
11+
- package-ecosystem: "docker"
12+
directory: "/.devcontainer"
13+
schedule:
14+
interval: "daily"
15+
- package-ecosystem: "github-actions"
16+
directory: "/"
17+
schedule:
18+
interval: "daily"

.github/workflows/check-coverage.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Check & Publish Coverage
2+
on:
3+
pull_request:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- '.github/workflows/check-coverage.yml'
8+
- 'codecov.yml'
9+
10+
env:
11+
python-version: '3.13'
12+
13+
permissions:
14+
id-token: write
15+
16+
jobs:
17+
python:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ env.python-version }}
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v5
27+
with:
28+
python-version: ${{ env.python-version }}
29+
- name: Test with pytest
30+
run: |
31+
uv run --no-default-groups --group cov pytest --cov --cov-report=xml --cov-context=test # Context info not yet supported in cobertura (or any other common format between pytest-cov and codecov.io)
32+
- name: Upload coverage reports to Codecov
33+
uses: codecov/codecov-action@v5
34+
with:
35+
use_oidc: true

.github/workflows/check-python.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Check Python
2+
3+
on:
4+
push:
5+
paths:
6+
- "**.py"
7+
- "**pyproject.toml"
8+
- ".github/workflows/check-python.yml"
9+
pull_request:
10+
workflow_call:
11+
12+
jobs:
13+
test:
14+
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: [
20+
"3.9",
21+
"3.10",
22+
"3.11",
23+
"3.12",
24+
"3.13"
25+
]
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
- name: Set up Python ${{ matrix.python-version }}
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: ${{ matrix.python-version }}
33+
- name: Install uv
34+
uses: astral-sh/setup-uv@v5
35+
with:
36+
python-version: ${{ matrix.python-version }}
37+
- name: Test with pytest
38+
run: |
39+
uv run --no-default-groups --group test pytest
40+
41+
lint:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v4
45+
- name: Ruff
46+
uses: chartboost/ruff-action@v1
47+
48+
type-check:
49+
env:
50+
python-version: '3.12'
51+
continue-on-error: false # explicitly make typing mandatory as pytype is lenient by design
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
- name: Set up Python ${{ env.python-version }} (Latest which pytype supports)
56+
uses: actions/setup-python@v5
57+
with:
58+
python-version: ${{ env.python-version }}
59+
- name: Install uv
60+
uses: astral-sh/setup-uv@v5
61+
with:
62+
python-version: ${{ env.python-version }}
63+
- name: Run pytype
64+
run: |
65+
uv run --no-default-groups --group typing pytype

.github/workflows/publish-docs.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Publish mkdocs site to Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
19+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
20+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
21+
concurrency:
22+
group: "pages"
23+
cancel-in-progress: false
24+
25+
26+
jobs:
27+
# Build job
28+
build:
29+
env:
30+
python-version: '3.13'
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
submodules: true
36+
- name: Set up Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: ${{ env.python-version }}
40+
- name: Install uv
41+
uses: astral-sh/setup-uv@v5
42+
with:
43+
python-version: ${{ env.python-version }}
44+
- name: Setup Pages
45+
id: pages
46+
uses: actions/configure-pages@v5
47+
- name: Build with mkdocs
48+
run: uv run --no-default-groups --group doc mkdocs build
49+
- name: Upload artifact
50+
uses: actions/upload-pages-artifact@v3
51+
with:
52+
path: ./site
53+
54+
# Deployment job
55+
deploy:
56+
environment:
57+
name: github-pages
58+
url: ${{ steps.deployment.outputs.page_url }}
59+
runs-on: ubuntu-latest
60+
needs: build
61+
steps:
62+
- name: Deploy to GitHub Pages
63+
id: deployment
64+
uses: actions/deploy-pages@v4

.github/workflows/publish-python.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish Python
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags: "v*"
7+
8+
env:
9+
python-version: '3.13'
10+
11+
jobs:
12+
python-checks:
13+
uses: ./.github/workflows/check-python.yml
14+
15+
build:
16+
name: Build package
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ env.python-version }}
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v5
26+
with:
27+
python-version: ${{ env.python-version }}
28+
- name: Build
29+
run: uv build
30+
- uses: actions/upload-artifact@v4
31+
with:
32+
name: pkg
33+
path: dist/
34+
35+
publish:
36+
environment:
37+
name: pypi
38+
url: https://pypi.org/p/ttrpg-dice
39+
permissions:
40+
id-token: write
41+
needs: [python-checks, build]
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/download-artifact@v4
45+
with:
46+
pattern: pkg
47+
path: dist
48+
merge-multiple: true
49+
- name: Upload to PyPi
50+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/tag-pr.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Tag PR
2+
3+
on:
4+
pull_request:
5+
types: closed
6+
7+
jobs:
8+
tag:
9+
# This could be flaky for forks - need to check both repos are the same but PR11 skipped with that check and YAGNI right now
10+
if: github.event.pull_request.merged
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- name: create tag git ref
16+
uses: actions/github-script@v7
17+
with:
18+
script: |
19+
github.rest.git.createRef({
20+
owner: context.repo.owner,
21+
repo: context.repo.repo,
22+
ref: 'refs/tags/PR${{ github.event.number }}',
23+
sha: '${{ github.event.pull_request.head.sha }}'
24+
}).catch(err => {
25+
if (err.status !== 409) throw err;
26+
github.rest.git.updateRef({
27+
owner: context.repo.owner,
28+
repo: context.repo.repo,
29+
ref: 'refs/tags/PR${{ github.event.number }}',
30+
sha: '${{ github.event.pull_request.head.sha }}'
31+
});
32+
})

0 commit comments

Comments
 (0)