mirror of
https://github.com/openai/codex-security.git
synced 2026-11-25 02:58:16 +08:00
178 lines
7.0 KiB
YAML
178 lines
7.0 KiB
YAML
name: native-unix
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
ref:
|
|
description: Source commit to build; defaults to the calling workflow commit.
|
|
type: string
|
|
default: ""
|
|
outputs:
|
|
darwin-arm64-artifact-id:
|
|
description: Artifact ID of the verified macOS arm64 build.
|
|
value: ${{ jobs.primitives.outputs.darwin-arm64-artifact-id }}
|
|
darwin-arm64-sha256:
|
|
description: SHA-256 of the addon of the verified macOS arm64 build.
|
|
value: ${{ jobs.primitives.outputs.darwin-arm64-sha256 }}
|
|
darwin-x64-artifact-id:
|
|
description: Artifact ID of the verified macOS x64 build.
|
|
value: ${{ jobs.primitives.outputs.darwin-x64-artifact-id }}
|
|
darwin-x64-sha256:
|
|
description: SHA-256 of the addon of the verified macOS x64 build.
|
|
value: ${{ jobs.primitives.outputs.darwin-x64-sha256 }}
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
primitives:
|
|
name: primitives / ${{ matrix.artifact }}
|
|
runs-on: ${{ matrix.runner }}
|
|
timeout-minutes: 30
|
|
outputs:
|
|
darwin-arm64-artifact-id: ${{ steps.darwin.outputs.darwin-arm64-artifact-id }}
|
|
darwin-arm64-sha256: ${{ steps.darwin.outputs.darwin-arm64-sha256 }}
|
|
darwin-x64-artifact-id: ${{ steps.darwin.outputs.darwin-x64-artifact-id }}
|
|
darwin-x64-sha256: ${{ steps.darwin.outputs.darwin-x64-sha256 }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- runner: ubuntu-24.04
|
|
platform: linux
|
|
arch: x64
|
|
artifact: linux-x64-gnu
|
|
image: quay.io/pypa/manylinux_2_28_x86_64@sha256:0536c364004fa2a3c5041120b6fe35d84fc5bfe31f04c6a6304f13eac4a67b63
|
|
- runner: ubuntu-24.04-arm
|
|
platform: linux
|
|
arch: arm64
|
|
artifact: linux-arm64-gnu
|
|
image: quay.io/pypa/manylinux_2_28_aarch64@sha256:1676a4f178dc6cf8a1d1e3b7e1d71fca891a466ebde72a33880ccda8af3383d8
|
|
- runner: macos-15-intel
|
|
platform: darwin
|
|
arch: x64
|
|
artifact: darwin-x64
|
|
- runner: macos-15
|
|
platform: darwin
|
|
arch: arm64
|
|
artifact: darwin-arm64
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
working-directory: plugins/codex-security/native
|
|
env:
|
|
NATIVE_IMAGE: ${{ matrix.image }}
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
ref: ${{ inputs.ref || github.sha }}
|
|
persist-credentials: false
|
|
- name: Set up TypeScript tools
|
|
uses: ./.github/actions/setup-tools
|
|
with:
|
|
compile: true
|
|
cache-dependency-path: plugins/codex-security/mcp-app/pnpm-lock.yaml
|
|
- name: Set up Rust
|
|
run: |
|
|
# Rustup 1.29 retries component downloads, but not manifest checksums.
|
|
for attempt in 1 2 3; do
|
|
if rustup toolchain install 1.97.1 --profile minimal --component rustfmt --component clippy; then
|
|
break
|
|
fi
|
|
if [ "$attempt" -eq 3 ]; then
|
|
exit 1
|
|
fi
|
|
sleep "$((attempt * 10))"
|
|
done
|
|
- name: Check Rust source and fetch locked dependencies
|
|
run: |
|
|
cargo fmt --check
|
|
cargo test --locked --lib
|
|
cargo clippy --locked -- -D warnings
|
|
cargo fetch --locked
|
|
- name: Prepare shared native notices
|
|
if: matrix.platform == 'linux' && matrix.arch == 'x64'
|
|
run: node notices.mjs
|
|
- name: Pull pinned glibc image
|
|
if: matrix.platform == 'linux'
|
|
run: |
|
|
if ! docker pull "$NATIVE_IMAGE"; then
|
|
sleep 5
|
|
docker pull "$NATIVE_IMAGE"
|
|
fi
|
|
- name: Build and verify Linux on glibc 2.28 with Node.js 22
|
|
if: matrix.platform == 'linux'
|
|
run: |
|
|
mkdir -p "$RUNNER_TEMP/native-cargo" "$RUNNER_TEMP/native-no-python"
|
|
printf '#!/bin/sh\nexit 99\n' > "$RUNNER_TEMP/native-no-python/python"
|
|
cp "$RUNNER_TEMP/native-no-python/python" "$RUNNER_TEMP/native-no-python/python3"
|
|
chmod +x "$RUNNER_TEMP/native-no-python/"*
|
|
docker run --pull=never --rm \
|
|
--volume "$PWD:/source" \
|
|
--volume "$RUNNER_TEMP/native-cargo:/cargo" \
|
|
--volume "${CARGO_HOME:-$HOME/.cargo}/registry:/cargo/registry:ro" \
|
|
--volume "$(rustc --print sysroot):/toolchain:ro" \
|
|
--volume "$(dirname "$(dirname "$(command -v node)")"):/node:ro" \
|
|
--volume "$RUNNER_TEMP/native-no-python:/no-python:ro" \
|
|
--env CARGO_HOME=/cargo \
|
|
--env CARGO_NET_OFFLINE=true \
|
|
--env PATH=/no-python:/toolchain/bin:/opt/rh/gcc-toolset-14/root/usr/bin:/usr/local/bin:/usr/bin:/bin \
|
|
--workdir /source "$NATIVE_IMAGE" /bin/bash -euc '
|
|
/node/bin/node build.mjs
|
|
/node/bin/node check.mjs
|
|
PATH= /node/bin/node proof.mjs
|
|
'
|
|
- name: Build and verify macOS with Node.js 22
|
|
if: matrix.platform == 'darwin'
|
|
run: |
|
|
node build.mjs
|
|
node check.mjs
|
|
native_node="$(command -v node)"
|
|
PATH='' "$native_node" proof.mjs
|
|
- name: Set up Node.js 20
|
|
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
|
with:
|
|
node-version: "20.0.0"
|
|
- name: Verify the same Linux artifact with Node.js 20
|
|
if: matrix.platform == 'linux'
|
|
run: |
|
|
docker run --pull=never --rm \
|
|
--volume "$PWD:/source:ro" \
|
|
--volume "$(dirname "$(dirname "$(command -v node)")"):/node:ro" \
|
|
--workdir /source "$NATIVE_IMAGE" /bin/bash -euc '
|
|
/node/bin/node check.mjs
|
|
PATH= /node/bin/node proof.mjs
|
|
'
|
|
- name: Verify the same macOS artifact with Node.js 20
|
|
if: matrix.platform == 'darwin'
|
|
run: |
|
|
node check.mjs
|
|
native_node="$(command -v node)"
|
|
PATH='' "$native_node" proof.mjs
|
|
- name: Upload verified native artifact
|
|
id: upload
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
with:
|
|
name: native-platform-${{ matrix.artifact }}-${{ inputs.ref || github.sha }}
|
|
path: |
|
|
plugins/codex-security/native/dist/*/*.node
|
|
plugins/codex-security/native/dist/THIRD_PARTY_NOTICES.txt
|
|
plugins/codex-security/native/dist/COPYRIGHT-library.html
|
|
plugins/codex-security/native/dist/licenses/*.txt
|
|
if-no-files-found: error
|
|
overwrite: true
|
|
retention-days: 7
|
|
- name: Record Darwin build outputs
|
|
if: matrix.platform == 'darwin'
|
|
id: darwin
|
|
env:
|
|
DARWIN_TARGET: ${{ matrix.artifact }}
|
|
ARTIFACT_ID: ${{ steps.upload.outputs.artifact-id }}
|
|
run: |
|
|
digest="$(shasum -a 256 "dist/$DARWIN_TARGET/unix.node")"
|
|
{
|
|
echo "$DARWIN_TARGET-artifact-id=$ARTIFACT_ID"
|
|
echo "$DARWIN_TARGET-sha256=${digest%% *}"
|
|
} >> "$GITHUB_OUTPUT"
|