mirror of
https://github.com/openai/codex-security.git
synced 2026-11-25 16:35:34 +08:00
ci: reuse verified native artifacts across source builds
This commit is contained in:
@@ -7,35 +7,60 @@ on:
|
||||
description: Source commit to build; defaults to the calling workflow commit.
|
||||
type: string
|
||||
default: ""
|
||||
reuse-verified:
|
||||
description: Reuse this week's verified payload when all native build and proof inputs match.
|
||||
type: boolean
|
||||
default: false
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
unix:
|
||||
uses: ./.github/workflows/native-unix.yml
|
||||
with:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
windows:
|
||||
uses: ./.github/workflows/native-windows.yml
|
||||
with:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
musl:
|
||||
uses: ./.github/workflows/native-musl.yml
|
||||
with:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
bundle:
|
||||
needs: [unix, windows, musl]
|
||||
prepare:
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
cache-key: ${{ steps.key.outputs.key }}
|
||||
cache-hit: ${{ steps.restore.outputs.cache-hit }}
|
||||
steps:
|
||||
- name: Download verified platform payloads
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
- name: Checkout native inputs
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
persist-credentials: false
|
||||
- name: Identify native build and proof inputs
|
||||
id: key
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# Include filenames and modes, not only file contents. Windows proofs
|
||||
# bundle MCP helpers, including their schema and workbench dependencies.
|
||||
source_hash="$(git ls-tree -r -z HEAD -- \
|
||||
.gitattributes .cargo .npmrc .pnpmfile.cjs package.json pnpm-workspace.yaml \
|
||||
.github/actions/setup-tools .github/scripts \
|
||||
.github/workflows/native-artifacts.yml \
|
||||
.github/workflows/native-unix.yml \
|
||||
.github/workflows/native-windows.yml \
|
||||
.github/workflows/native-musl.yml \
|
||||
sdk/typescript/.npmrc sdk/typescript/.pnpmfile.cjs \
|
||||
sdk/typescript/package.json sdk/typescript/pnpm-lock.yaml \
|
||||
sdk/typescript/pnpm-workspace.yaml \
|
||||
sdk/typescript/tsconfig.json sdk/typescript/tsconfig.ci.json \
|
||||
plugins/codex-security/native plugins/codex-security/mcp-app \
|
||||
plugins/codex-security/schemas plugins/codex-security/scripts \
|
||||
plugins/codex-security/shared | sha256sum)"
|
||||
# Hosted runner images can change without a source change.
|
||||
printf 'key=native-universal-v1-%s-%s\n' "$(date -u +%G-%V)" "${source_hash%% *}" >> "$GITHUB_OUTPUT"
|
||||
- name: Restore verified native payload
|
||||
if: inputs.reuse-verified
|
||||
id: restore
|
||||
continue-on-error: true
|
||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
pattern: native-platform-*-${{ inputs.ref || github.sha }}
|
||||
merge-multiple: true
|
||||
path: native
|
||||
- name: Upload universal native payload
|
||||
key: ${{ steps.key.outputs.key }}
|
||||
- name: Upload reused native payload for this commit
|
||||
if: steps.restore.outputs.cache-hit == 'true'
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: native-universal-${{ inputs.ref || github.sha }}
|
||||
@@ -43,3 +68,67 @@ jobs:
|
||||
if-no-files-found: error
|
||||
overwrite: true
|
||||
retention-days: 7
|
||||
unix:
|
||||
needs: prepare
|
||||
if: needs.prepare.outputs.cache-hit != 'true'
|
||||
uses: ./.github/workflows/native-unix.yml
|
||||
with:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
windows:
|
||||
needs: prepare
|
||||
if: needs.prepare.outputs.cache-hit != 'true'
|
||||
uses: ./.github/workflows/native-windows.yml
|
||||
with:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
musl:
|
||||
needs: prepare
|
||||
if: needs.prepare.outputs.cache-hit != 'true'
|
||||
uses: ./.github/workflows/native-musl.yml
|
||||
with:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
bundle:
|
||||
needs: [prepare, unix, windows, musl]
|
||||
if: ${{ !cancelled() }}
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Require a verified native payload
|
||||
shell: bash
|
||||
env:
|
||||
PREPARE_RESULT: ${{ needs.prepare.result }}
|
||||
CACHE_HIT: ${{ needs.prepare.outputs.cache-hit }}
|
||||
UNIX_RESULT: ${{ needs.unix.result }}
|
||||
WINDOWS_RESULT: ${{ needs.windows.result }}
|
||||
MUSL_RESULT: ${{ needs.musl.result }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
[[ "$PREPARE_RESULT" == success ]]
|
||||
if [[ "$CACHE_HIT" != true ]]; then
|
||||
[[ "$UNIX_RESULT" == success && "$WINDOWS_RESULT" == success && "$MUSL_RESULT" == success ]]
|
||||
fi
|
||||
- name: Download verified platform payloads
|
||||
if: needs.prepare.outputs.cache-hit != 'true'
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
pattern: native-platform-*-${{ inputs.ref || github.sha }}
|
||||
merge-multiple: true
|
||||
path: native
|
||||
- name: Upload universal native payload
|
||||
if: needs.prepare.outputs.cache-hit != 'true'
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: native-universal-${{ inputs.ref || github.sha }}
|
||||
path: native/
|
||||
if-no-files-found: error
|
||||
overwrite: true
|
||||
retention-days: 7
|
||||
- name: Save verified native payload from main
|
||||
if: >-
|
||||
needs.prepare.outputs.cache-hit != 'true' &&
|
||||
github.ref == 'refs/heads/main' &&
|
||||
(github.event_name == 'push' || github.event_name == 'schedule') &&
|
||||
(inputs.ref == '' || inputs.ref == github.sha)
|
||||
continue-on-error: true
|
||||
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: native
|
||||
key: ${{ needs.prepare.outputs.cache-key }}
|
||||
|
||||
@@ -43,6 +43,9 @@ jobs:
|
||||
with:
|
||||
architecture: ${{ matrix.arch }}
|
||||
compile: true
|
||||
cache-dependency-path: |
|
||||
sdk/typescript/pnpm-lock.yaml
|
||||
plugins/codex-security/mcp-app/pnpm-lock.yaml
|
||||
- name: Install helper dependencies
|
||||
working-directory: .
|
||||
run: pnpm --dir plugins/codex-security/mcp-app install --frozen-lockfile
|
||||
|
||||
@@ -146,6 +146,8 @@ jobs:
|
||||
native:
|
||||
needs: classify-changes
|
||||
uses: ./.github/workflows/native-artifacts.yml
|
||||
with:
|
||||
reuse-verified: true
|
||||
|
||||
container-validate:
|
||||
needs: [classify-changes, native]
|
||||
|
||||
Reference in New Issue
Block a user