Skip to content

Commit 6c890b8

Browse files
committed
Add Actions Workflows
- Add a ci.yml workflow for running tests and coverage reports - Add a release.yml workflow for generating releases from pushed tags
1 parent 7632185 commit 6c890b8

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-0
lines changed

.github/workflows/ci.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
types: [opened, synchronize, reopened]
7+
push:
8+
branches: [main]
9+
10+
jobs:
11+
test:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, windows-latest, macos-latest]
17+
python-version: ["3.11", "3.12", "3.13"]
18+
defaults:
19+
run:
20+
shell: bash
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
31+
- name: Install Poetry
32+
uses: snok/install-poetry@v1
33+
with:
34+
version: latest
35+
virtualenvs-create: true
36+
virtualenvs-in-project: true
37+
38+
- name: Load cached venv
39+
id: cached-poetry-dependencies
40+
uses: actions/cache@v4
41+
with:
42+
path: ~/.cache
43+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
44+
45+
- name: Install dependencies
46+
run: poetry install --no-interaction --no-root
47+
48+
- name: Install project
49+
run: poetry install --no-interaction
50+
51+
- name: Run tests with coverage
52+
run: |
53+
source $VENV
54+
pytest --cov=prevent_dangling_todos --cov-report=xml --cov-report=term-missing
55+
56+
- name: Run linting
57+
run: |
58+
source $VENV
59+
ruff check .
60+
61+
- name: Run type checking
62+
run: |
63+
source $VENV
64+
mypy prevent_dangling_todos
65+
66+
- name: Upload coverage to Codecov
67+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
68+
uses: codecov/codecov-action@v5
69+
with:
70+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/release.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.12'
24+
25+
- name: Install Poetry
26+
uses: snok/install-poetry@v1
27+
with:
28+
version: latest
29+
virtualenvs-create: true
30+
virtualenvs-in-project: true
31+
32+
- name: Extract tag information
33+
id: tag_info
34+
run: |
35+
TAG_NAME=${GITHUB_REF_NAME}
36+
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
37+
38+
# Check if tag matches semantic version pattern (v?X.Y.Z)
39+
if [[ $TAG_NAME =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
40+
echo "is_prerelease=false" >> $GITHUB_OUTPUT
41+
echo "Release type: Full release"
42+
else
43+
echo "is_prerelease=true" >> $GITHUB_OUTPUT
44+
echo "Release type: Pre-release"
45+
fi
46+
47+
- name: Install dependencies
48+
run: poetry install --no-interaction
49+
50+
- name: Build package
51+
run: poetry build
52+
53+
- name: Create Release
54+
env:
55+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
run: |
57+
# Create release with automatic release notes generation
58+
if [ "${{ steps.tag_info.outputs.is_prerelease }}" = "true" ]; then
59+
gh release create ${{ steps.tag_info.outputs.tag_name }} \
60+
--title "Release ${{ steps.tag_info.outputs.tag_name }}" \
61+
--generate-notes \
62+
--prerelease
63+
else
64+
gh release create ${{ steps.tag_info.outputs.tag_name }} \
65+
--title "Release ${{ steps.tag_info.outputs.tag_name }}" \
66+
--generate-notes
67+
fi
68+
69+
- name: Upload release artifacts
70+
env:
71+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
run: |
73+
# Upload all built artifacts to the release
74+
gh release upload ${{ steps.tag_info.outputs.tag_name }} dist/*.whl dist/*.tar.gz

0 commit comments

Comments
 (0)