Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

ci: clear PR caches after merge (#1997)

Michael D'Angelo869c0c178cf7
diff --git a/.github/workflows/clean-merged-pr-caches.yml b/.github/workflows/clean-merged-pr-caches.yml
new file mode 100644
index 000000000..69ee8844f
--- /dev/null
+++ b/.github/workflows/clean-merged-pr-caches.yml
@@ -0,0 +1,21 @@
+name: Clean merged PR caches
+
+on:
+ pull_request_target:
+ branches: [main]
+ types: [closed]
+
+permissions: {}
+
+jobs:
+ clean:
+ if: github.event.pull_request.merged
+ runs-on: ubuntu-latest
+ permissions:
+ actions: write
+ steps:
+ - name: Delete caches for this PR's merge ref
+ env:
+ GH_TOKEN: ${{ github.token }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ run: gh cache delete --all --ref "refs/pull/$PR_NUMBER/merge" --succeed-on-no-caches --repo "$GITHUB_REPOSITORY"
diff --git a/.github/zizmor.yml b/.github/zizmor.yml
index 3b3952927..76f9a0c27 100644
--- a/.github/zizmor.yml
+++ b/.github/zizmor.yml
@@ -1,6 +1,8 @@
rules:
dangerous-triggers:
ignore:
+ # Deletes only the merged PR's cache ref without checking out any code.
+ - clean-merged-pr-caches.yml:3
# Labels only: no checkout or execution of pull request code.
- node-release-labels.yml:3
# Reads run metadata and comments using helpers checked out from protected main.
diff --git a/docs/ci.md b/docs/ci.md
index 85b2e8766..22ba3433a 100644
--- a/docs/ci.md
+++ b/docs/ci.md
@@ -105,6 +105,9 @@ Linux coverage artifacts are review evidence, not a percentage-based merge
gate. Mutation diagnostics also measure results without enforcing a minimum
score. Ordinary report upload failures do not replace the test result.
+Only the same pull request can reuse caches saved on `refs/pull/<number>/merge`.
+After the PR merges into `main`, a maintenance job deletes those caches.
+
When measuring CI changes, separate time to required-green from summed job
execution time, prerequisite waits, runner scheduling, approval waits, and
manual retry delays. Compare matching revisions and test configurations, and