Skip to content

Commit b917b66

Browse files
authored
fix: drift detection and safe pr gate (#5458)
1 parent 3399153 commit b917b66

File tree

5 files changed

+57
-56
lines changed

5 files changed

+57
-56
lines changed

.github/scripts/buildkitd.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ sudo mkdir -p /etc/buildkit
7979
CONFIG_PATH="/etc/buildkit/buildkitd.toml"
8080

8181
TMP_CONFIG=$(mktemp)
82+
sudo chmod 644 "$TMP_CONFIG"
8283
cat <<EOF > "$TMP_CONFIG"
8384
[worker.oci]
8485
enabled = true
@@ -90,7 +91,6 @@ cat <<EOF > "$TMP_CONFIG"
9091
defaultKeepStorage = "$KEEP_HUMAN"
9192
[[gc.policy]]
9293
keepDuration = "720h" # 30 days
93-
keepBytes = "$KEEP_BYTES"
9494
filters = ["type==regular"]
9595
EOF
9696

.github/workflows/example.yml renamed to .github/workflows/pr-example.yml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
name: Example Workflow
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
branches:
9-
- main
4+
workflow_run:
5+
workflows: ["PR Permission Gate"]
6+
types:
7+
- completed
108

119
permissions:
1210
contents: read
1311

1412
jobs:
15-
gatekeeper:
13+
pre-commit:
14+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1615
runs-on: ubuntu-latest
1716
steps:
1817
- uses: actions/checkout@v5
19-
- uses: astral-sh/ruff-action@v3
20-
- run: ruff check --line-length 100 .
21-
- uses: ./.github/actions/pr-permission-gate
18+
- uses: actions/setup-python@v6
19+
with:
20+
python-version: "3.12"
21+
- uses: pre-commit/action@v3.0.1
22+
with:
23+
extra_args: --all-files
2224

2325
example-on-default-runner:
24-
needs: [gatekeeper]
26+
needs: [pre-commit]
2527
runs-on:
2628
- codebuild-runner-${{ github.run_id }}-${{ github.run_attempt }}
2729
steps:
@@ -45,9 +47,6 @@ jobs:
4547
fleet:x86-g6xl-runner
4648
steps:
4749
- uses: actions/checkout@v5
48-
- uses: ./.github/actions/pr-permission-gate
49-
with:
50-
required-level: admin
5150
- run: .github/scripts/runner_setup.sh
5251
- run: |
5352
nvidia-smi
@@ -59,9 +58,6 @@ jobs:
5958
fleet:x86-g6xl-runner
6059
steps:
6160
- uses: actions/checkout@v5
62-
- uses: ./.github/actions/pr-permission-gate
63-
with:
64-
required-level: admin
6561
- run: .github/scripts/runner_setup.sh
6662
- run: |
6763
nvidia-smi

.github/workflows/pr-gate.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: PR Permission Gate
2+
on:
3+
pull_request_target:
4+
branches: [main]
5+
types: [opened, reopened, synchronize]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: read
10+
11+
concurrency:
12+
group: pr-gate-${{ github.event.pull_request.number }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
gatekeeper:
17+
name: gatekeeper
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout base branch (safe)
21+
uses: actions/checkout@v5
22+
with:
23+
# checkout the workflow's commit (base branch), not the PR head
24+
ref: ${{ github.event.pull_request.base.sha }}
25+
fetch-depth: 1
26+
27+
- name: Run permission gate (from base)
28+
uses: ./.github/actions/pr-permission-gate

.github/workflows/pre-commit.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@ default_stages:
77
- manual
88

99
repos:
10-
# - repo: https://github.com/reteps/dockerfmt
11-
# # run `pre-commit autoupdate` to pin the version
12-
# rev: main
13-
# hooks:
14-
# - id: dockerfmt
15-
# args:
16-
# # optional: add additional arguments here
17-
# - --indent=2
18-
# - --write
19-
# - repo: https://github.com/rhysd/actionlint
20-
# rev: v1.7.7
21-
# hooks:
22-
# - id: actionlint
10+
- repo: https://github.com/reteps/dockerfmt
11+
# run `pre-commit autoupdate` to pin the version
12+
rev: main
13+
hooks:
14+
- id: dockerfmt
15+
args:
16+
# optional: add additional arguments here
17+
- --indent=2
18+
- --write
19+
stages: [manual] # run in CI
20+
- repo: https://github.com/rhysd/actionlint
21+
rev: v1.7.7
22+
hooks:
23+
- id: actionlint
24+
stages: [manual] # run in CI
2325
- repo: https://github.com/scop/pre-commit-shfmt
2426
rev: v3.12.0-2 # Use the latest stable revision
2527
hooks:

0 commit comments

Comments
 (0)