Skip to content

Commit 423d3d9

Browse files
authored
Merge branch 'main' into list-files-command
2 parents 8cc01a5 + 32a17b8 commit 423d3d9

28 files changed

Lines changed: 1154 additions & 210 deletions

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ updates:
55
directory: "/"
66
schedule:
77
interval: "daily"
8+
cooldown:
9+
default-days: 7
810
commit-message:
911
prefix:
1012
labels: [dependencies, internal]
@@ -13,6 +15,18 @@ updates:
1315
directory: "/"
1416
schedule:
1517
interval: "daily"
18+
cooldown:
19+
default-days: 7
20+
commit-message:
21+
prefix:
22+
labels: [dependencies, internal]
23+
# pre-commit
24+
- package-ecosystem: "pre-commit"
25+
directory: "/"
26+
schedule:
27+
interval: "daily"
28+
cooldown:
29+
default-days: 7
1630
commit-message:
1731
prefix:
1832
labels: [dependencies, internal]
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Guard Dependencies
2+
3+
on:
4+
pull_request_target: # zizmor: ignore[dangerous-triggers] -- This workflow only reads context.payload metadata, never checks out PR code
5+
branches: [main]
6+
paths:
7+
- pyproject.toml
8+
- uv.lock
9+
10+
permissions:
11+
contents: read
12+
issues: write
13+
pull-requests: write
14+
15+
jobs:
16+
check-author:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Check if author is org member or allowed bot
20+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
21+
with:
22+
script: |
23+
const pr = context.payload.pull_request;
24+
const author = pr.user.login;
25+
const assoc = pr.author_association;
26+
27+
const botAllowlist = new Set(['dependabot[bot]']);
28+
const orgAuthorAssociations = new Set(['MEMBER', 'OWNER']);
29+
30+
const allowed =
31+
botAllowlist.has(author) ||
32+
(assoc != null && orgAuthorAssociations.has(assoc));
33+
34+
if (!allowed) {
35+
await github.rest.issues.createComment({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
issue_number: context.payload.pull_request.number,
39+
body: `This PR modifies dependency files (\`pyproject.toml\` or \`uv.lock\`), which is restricted to members of the **${context.repo.owner}** organization on GitHub.\n\nIf you need a dependency change, please [open a discussion](https://github.com/${context.repo.owner}/${context.repo.repo}/discussions/new) describing what you need and why.\n\nClosing this PR automatically.`
40+
});
41+
42+
await github.rest.pulls.update({
43+
owner: context.repo.owner,
44+
repo: context.repo.repo,
45+
pull_number: context.payload.pull_request.number,
46+
state: 'closed'
47+
});
48+
49+
core.setFailed('Dependency changes are restricted to organization members.');
50+
} else {
51+
console.log(`Author ${author} (author_association=${assoc}) is allowed to make dependency changes.`);
52+
}

.github/workflows/issue-manager.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,21 @@ on:
99
issues:
1010
types:
1111
- labeled
12-
pull_request_target:
12+
pull_request_target: # zizmor: ignore[dangerous-triggers]
1313
types:
1414
- labeled
1515
workflow_dispatch:
1616

17-
permissions:
18-
issues: write
19-
pull-requests: write
17+
permissions: {}
2018

2119
jobs:
2220
issue-manager:
2321
if: github.repository_owner == 'fastapilabs'
2422
runs-on: ubuntu-latest
23+
permissions:
24+
issues: write
25+
pull-requests: write
26+
timeout-minutes: 5
2527
steps:
2628
- name: Dump GitHub context
2729
env:

.github/workflows/labeler.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Labels
22
on:
3-
pull_request_target:
3+
pull_request_target: # zizmor: ignore[dangerous-triggers]
44
types:
55
- opened
66
- synchronize
@@ -9,21 +9,25 @@ on:
99
- labeled
1010
- unlabeled
1111

12+
permissions: {}
13+
1214
jobs:
1315
labeler:
1416
permissions:
1517
contents: read
1618
pull-requests: write
1719
runs-on: ubuntu-latest
20+
timeout-minutes: 5
1821
steps:
19-
- uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b # v6.0.1
22+
- uses: actions/labeler@f27b608878404679385c85cfa523b85ccb86e213 # v6.1.0
2023
# Run this after labeler applied labels
2124
check-labels:
2225
needs:
2326
- labeler
2427
permissions:
2528
pull-requests: read
2629
runs-on: ubuntu-latest
30+
timeout-minutes: 5
2731
steps:
2832
- uses: agilepathway/label-checker@c3d16ad512e7cea5961df85ff2486bb774caf3c5 # v1.6.65
2933
with:

.github/workflows/latest-changes.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Latest Changes
22

33
on:
4-
pull_request_target:
4+
pull_request_target: # zizmor: ignore[dangerous-triggers]
55
branches:
66
- main
77
types:
@@ -16,9 +16,13 @@ on:
1616
required: false
1717
default: 'false'
1818

19+
permissions: {}
20+
1921
jobs:
2022
latest-changes:
2123
runs-on: ubuntu-latest
24+
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true
25+
timeout-minutes: 5
2226
steps:
2327
- name: Dump GitHub context
2428
env:
@@ -27,7 +31,8 @@ jobs:
2731
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2832
with:
2933
# To allow latest-changes to commit to the main branch
30-
token: ${{ secrets.LATEST_CHANGES }}
34+
token: ${{ secrets.LATEST_CHANGES }} # zizmor: ignore[secrets-outside-env]
35+
persist-credentials: true # required by tiangolo/latest-changes
3136
# Allow debugging with tmate
3237
- name: Setup tmate session
3338
uses: mxschmitt/action-tmate@c0afd6f790e3a5564914980036ebf83216678101 # v3.23

.github/workflows/pre-commit.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ on:
66
- opened
77
- synchronize
88

9+
permissions: {}
10+
911
env:
1012
# Forks and Dependabot don't have access to secrets
1113
HAS_SECRETS: ${{ secrets.PRE_COMMIT != '' }}
1214

1315
jobs:
1416
pre-commit:
1517
runs-on: ubuntu-latest
18+
timeout-minutes: 5
1619
steps:
1720
- name: Dump GitHub context
1821
env:
@@ -28,7 +31,8 @@ jobs:
2831
# And it needs the full history to be able to compute diffs
2932
fetch-depth: 0
3033
# A token other than the default GITHUB_TOKEN is needed to be able to trigger CI
31-
token: ${{ secrets.PRE_COMMIT }}
34+
token: ${{ secrets.PRE_COMMIT }} # zizmor: ignore[secrets-outside-env]
35+
persist-credentials: true # Required for `git push` command
3236
# pre-commit lite ci needs the default checkout configs to work
3337
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3438
name: Checkout PR for fork
@@ -37,19 +41,23 @@ jobs:
3741
# To be able to commit it needs the head branch of the PR, the remote one
3842
ref: ${{ github.event.pull_request.head.sha }}
3943
fetch-depth: 0
44+
persist-credentials: false
4045
- name: Set up Python
4146
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
4247
with:
4348
python-version: "3.14"
4449
- name: Setup uv
4550
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
4651
with:
52+
# Before upgrading uv version, make sure astral-sh/setup-uv knows its checksum.
53+
# See: https://github.com/astral-sh/setup-uv/issues/851#issuecomment-4282017837
54+
version: "0.11.4"
4755
cache-dependency-glob: |
4856
pyproject.toml
4957
uv.lock
5058
- name: Run prek - pre-commit
5159
id: precommit
52-
run: uvx prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure
60+
run: uv run prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure
5361
continue-on-error: true
5462
- name: Commit and push changes
5563
if: env.HAS_SECRETS == 'true'
@@ -77,6 +85,7 @@ jobs:
7785
needs:
7886
- pre-commit
7987
runs-on: ubuntu-latest
88+
timeout-minutes: 5
8089
steps:
8190
- name: Dump GitHub context
8291
env:

.github/workflows/publish.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,33 @@ on:
55
types:
66
- created
77

8+
permissions: {}
9+
810
jobs:
911
publish:
1012
runs-on: ubuntu-latest
1113
permissions:
1214
id-token: write
1315
contents: read
16+
timeout-minutes: 5
1417
steps:
1518
- name: Dump GitHub context
1619
env:
1720
GITHUB_CONTEXT: ${{ toJson(github) }}
1821
run: echo "$GITHUB_CONTEXT"
1922
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
23+
with:
24+
persist-credentials: false
2025
- name: Set up Python
2126
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
2227
with:
2328
python-version-file: "pyproject.toml"
2429
- name: Install uv
2530
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
31+
with:
32+
# Before upgrading uv version, make sure astral-sh/setup-uv knows its checksum.
33+
# See: https://github.com/astral-sh/setup-uv/issues/851#issuecomment-4282017837
34+
version: "0.11.4"
2635
- name: Build distribution
2736
run: uv build
2837
- name: Publish

.github/workflows/smokeshow.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,51 @@
11
name: Smokeshow
22

33
on:
4-
workflow_run:
4+
workflow_run: # zizmor: ignore[dangerous-triggers]
55
workflows: [Test]
66
types: [completed]
77

8-
permissions:
9-
statuses: write
8+
permissions: {}
109

1110
jobs:
1211
smokeshow:
1312
runs-on: ubuntu-latest
13+
permissions:
14+
statuses: write
15+
timeout-minutes: 5
1416

1517
steps:
1618
- name: Dump GitHub context
1719
env:
1820
GITHUB_CONTEXT: ${{ toJson(github) }}
1921
run: echo "$GITHUB_CONTEXT"
22+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
23+
with:
24+
persist-credentials: false
2025
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
2126
with:
22-
python-version: '3.13'
23-
24-
- run: pip install smokeshow
25-
27+
python-version-file: ".python-version"
28+
- name: Setup uv
29+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
30+
with:
31+
# Before upgrading uv version, make sure astral-sh/setup-uv knows its checksum.
32+
# See: https://github.com/astral-sh/setup-uv/issues/851#issuecomment-4282017837
33+
version: "0.11.4"
34+
cache-dependency-glob: |
35+
pyproject.toml
36+
uv.lock
37+
- run: uv sync --locked --no-dev --group github-actions
2638
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
2739
with:
2840
name: coverage-html
2941
path: htmlcov
3042
github-token: ${{ secrets.GITHUB_TOKEN }}
3143
run-id: ${{ github.event.workflow_run.id }}
32-
33-
- run: smokeshow upload htmlcov
44+
- run: uv run smokeshow upload htmlcov
3445
env:
3546
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
3647
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 100
3748
SMOKESHOW_GITHUB_CONTEXT: coverage
3849
SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3950
SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
40-
SMOKESHOW_AUTH_KEY: ${{ secrets.SMOKESHOW_AUTH_KEY }}
51+
SMOKESHOW_AUTH_KEY: ${{ secrets.SMOKESHOW_AUTH_KEY }} # zizmor: ignore[secrets-outside-env]

.github/workflows/test-redistribute.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@ on:
99
- opened
1010
- synchronize
1111

12+
permissions: {}
13+
1214
jobs:
1315
test-redistribute:
1416
runs-on: ubuntu-latest
17+
timeout-minutes: 5
1518
steps:
1619
- name: Dump GitHub context
1720
env:
1821
GITHUB_CONTEXT: ${{ toJson(github) }}
1922
run: echo "$GITHUB_CONTEXT"
2023
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24+
with:
25+
persist-credentials: false
2126
- name: Set up Python
2227
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
2328
with:

0 commit comments

Comments
 (0)