Skip to content

Commit af49a8f

Browse files
committed
πŸ› fix(ci): harden GitHub Actions workflows for production readiness
Files Modified 1. main.yaml.jinja β€” 7 changes: - Added top-level permissions: contents: read (change 5) - Added timeout-minutes: 15 to all 5 jobs (change 6) - Fixed prerelease detection with a proper regex step instead of contains() (change 2) - Removed noisy echo ${{ github.ref }} from release notes step (change 3) - Fixed secrets.PYPI_TOKEN check β€” now uses shell $UV_PUBLISH_TOKEN test (change 1) - Added coverage artifact upload from default Python version (change 10) 2. pr-thank-you.yaml β€” Added name: PR Thank You and continue-on-error: true (change 8) 3. setup-env/action.yaml β€” Pinned jdx/mise-action to SHA, enabled uv caching (changes 4 & 7) Files Created 4. dependabot.yml β€” Weekly GitHub Actions auto-updates (change 9) 5. PULL_REQUEST_TEMPLATE.md β€” Minimal PR checklist (change 11)
1 parent ee2f27f commit af49a8f

5 files changed

Lines changed: 54 additions & 5 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Description
2+
<!-- What does this PR do? -->
3+
4+
## Checklist
5+
- [ ] Tests pass (`make test`)
6+
- [ ] Linting passes (`make check-quality`)
7+
- [ ] Type checking passes (`make check-types`)

β€Žtemplate/{% if repository_provider == 'github' %}.github{% endif %}/actions/setup-env/action.yamlβ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ runs:
1313
steps:
1414
- name: Setup uv
1515
uses: astral-sh/setup-uv@eb1897b8dc4b5d5bfe39a428a8f2304605e0983c # v7
16+
with:
17+
enable-cache: true
1618

1719
- name: Setup mise
18-
uses: jdx/mise-action@v2
20+
uses: jdx/mise-action@c37c93293d6b742fc901e1406b8f764f6fb19dac # v2
1921
with:
2022
install_only: true
2123

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

β€Žtemplate/{% if repository_provider == 'github' %}.github{% endif %}/workflows/main.yaml.jinjaβ€Ž

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ on:
1414
types: [opened, synchronize, reopened, ready_for_review]
1515
workflow_dispatch:
1616

17+
permissions:
18+
contents: read
19+
1720
jobs:
1821
checks:
1922
runs-on: ubuntu-latest
23+
timeout-minutes: 15
2024
steps:
2125
- name: Checkout repository
2226
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
@@ -40,6 +44,7 @@ jobs:
4044

4145
tests:
4246
runs-on: ubuntu-latest
47+
timeout-minutes: 15
4348
strategy:
4449
matrix:
4550
python-version:
@@ -64,8 +69,18 @@ jobs:
6469
- name: Run tests
6570
run: make test
6671

72+
- name: Upload coverage report
73+
if: {% raw %}matrix.python-version == '{{ python_version }}'{% endraw %}
74+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
75+
with:
76+
name: coverage-report
77+
path: |
78+
htmlcov/
79+
coverage.xml
80+
6781
release:
6882
runs-on: ubuntu-latest
83+
timeout-minutes: 15
6984
if: |
7085
github.event_name == 'push' &&
7186
startsWith(github.ref, 'refs/tags/')
@@ -87,20 +102,31 @@ jobs:
87102
python-version-file: ".python-version"
88103

89104
- name: Prepare release notes
90-
run: {% raw %}uvx --from commitizen --with cz-conventional-gitmoji cz changelog ${{ github.ref_name }} --file-name release-notes.md && echo ${{ github.ref }}{% endraw %}
105+
run: {% raw %}uvx --from commitizen --with cz-conventional-gitmoji cz changelog ${{ github.ref_name }} --file-name release-notes.md{% endraw %}
106+
107+
- name: Check if prerelease
108+
id: check_prerelease
109+
run: |
110+
TAG="{% raw %}${{ github.ref_name }}{% endraw %}"
111+
if echo "$TAG" | grep -qP '\d+\.\d+\.\d+(a|b|rc)\d+'; then
112+
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
113+
else
114+
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
115+
fi
91116

92117
- name: Create release
93118
uses: softprops/action-gh-release@aec2ec56f94eb8180ceec724245f64ef008b89f5 # v2
94119
with:
95120
body_path: release-notes.md
96-
prerelease: {% raw %}${{ contains(github.ref_name, 'rc') || contains(github.ref_name, 'b') || contains(github.ref_name, 'a') }}{% endraw %}
121+
prerelease: {% raw %}${{ steps.check_prerelease.outputs.is_prerelease }}{% endraw %}
97122

98123
deploy-docs:
99124
if: |
100125
github.event_name == 'workflow_dispatch' ||
101126
(github.event_name == 'push' &&
102127
startsWith(github.ref, 'refs/tags/'))
103128
runs-on: ubuntu-latest
129+
timeout-minutes: 15
104130
needs:
105131
- checks
106132
- tests
@@ -136,6 +162,7 @@ jobs:
136162
(github.event_name == 'push' &&
137163
startsWith(github.ref, 'refs/tags/'))
138164
runs-on: ubuntu-latest
165+
timeout-minutes: 15
139166
needs:
140167
- checks
141168
- tests
@@ -155,8 +182,12 @@ jobs:
155182
run: uv build
156183

157184
- name: Publish package
158-
if: secrets.PYPI_TOKEN != ''
159185
env:
160186
UV_PUBLISH_TOKEN: {% raw %}${{ secrets.PYPI_TOKEN }}{% endraw %}
161-
run: uv publish
187+
run: |
188+
if [ -n "$UV_PUBLISH_TOKEN" ]; then
189+
uv publish
190+
else
191+
echo "::warning::PYPI_TOKEN secret not set, skipping publish"
192+
fi
162193
{%- endif %}

β€Žtemplate/{% if repository_provider == 'github' %}.github{% endif %}/workflows/pr-thank-you.yamlβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: PR Thank You
2+
13
on:
24
pull_request:
35
types:
@@ -6,6 +8,7 @@ on:
68
jobs:
79
pr-action:
810
runs-on: ubuntu-latest
11+
continue-on-error: true
912
permissions:
1013
issues: write
1114
pull-requests: write

0 commit comments

Comments
Β (0)