Lightweight coding agent that runs in your terminal
Rust
Refactor Bazel CI job setup (#17704)
Michael Bolin440597c7e754
diff --git a/.github/actions/prepare-bazel-ci/action.yml b/.github/actions/prepare-bazel-ci/action.ymlnew file mode 100644index 0000000000..bf07545e4c--- /dev/null+++ b/.github/actions/prepare-bazel-ci/action.yml@@ -0,0 +1,47 @@+name: prepare-bazel-ci+description: Prepare a Bazel CI job with shared setup, repository cache restore, and execution logs.+inputs:+ target:+ description: Target triple used for setup and cache namespacing.+ required: true+ install-test-prereqs:+ description: Install Node.js and DotSlash for Bazel-backed test jobs.+ required: false+ default: "false"+outputs:+ repository-cache-hit:+ description: Whether the Bazel repository cache restore hit.+ value: ${{ steps.cache_bazel_repository_restore.outputs.cache-hit }}+ repository-cache-path:+ description: Filesystem path used for the Bazel repository cache.+ value: ${{ steps.setup_bazel.outputs.repository-cache-path }}++runs:+ using: composite+ steps:+ - name: Set up Bazel CI+ id: setup_bazel+ uses: ./.github/actions/setup-bazel-ci+ with:+ target: ${{ inputs.target }}+ install-test-prereqs: ${{ inputs.install-test-prereqs }}++ # Restore the Bazel repository cache explicitly so external dependencies+ # do not need to be re-downloaded on every CI run. Keep restore failures+ # non-fatal so transient cache-service errors degrade to a cold build+ # instead of failing the job.+ - name: Restore bazel repository cache+ id: cache_bazel_repository_restore+ continue-on-error: true+ uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5+ with:+ path: ${{ steps.setup_bazel.outputs.repository-cache-path }}+ key: bazel-cache-${{ inputs.target }}-${{ hashFiles('MODULE.bazel', 'codex-rs/Cargo.lock', 'codex-rs/Cargo.toml') }}+ restore-keys: |+ bazel-cache-${{ inputs.target }}++ - name: Set up Bazel execution logs+ shell: bash+ run: |+ mkdir -p "${RUNNER_TEMP}/bazel-execution-logs"+ echo "CODEX_BAZEL_EXECUTION_LOG_COMPACT_DIR=${RUNNER_TEMP}/bazel-execution-logs" >> "${GITHUB_ENV}"diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.ymlindex ee277a13e6..41d76f8468 100644--- a/.github/workflows/bazel.yml+++ b/.github/workflows/bazel.yml@@ -58,38 +58,17 @@ jobs:python3 .github/scripts/rusty_v8_bazel.py check-module-bazelpython3 -m unittest discover -s .github/scripts -p test_rusty_v8_bazel.py- - name: Set up Bazel CI- id: setup_bazel- uses: ./.github/actions/setup-bazel-ci+ - name: Prepare Bazel CI+ id: prepare_bazel+ uses: ./.github/actions/prepare-bazel-ciwith:target: ${{ matrix.target }}install-test-prereqs: "true"-- # Restore the Bazel repository cache explicitly so external dependencies- # do not need to be re-downloaded on every CI run. Keep restore failures- # non-fatal so transient cache-service errors degrade to a cold build- # instead of failing the job.- - name: Restore bazel repository cache- id: cache_bazel_repository_restore- continue-on-error: true- uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5- with:- path: ${{ steps.setup_bazel.outputs.repository-cache-path }}- key: bazel-cache-${{ matrix.target }}-${{ hashFiles('MODULE.bazel', 'codex-rs/Cargo.lock', 'codex-rs/Cargo.toml') }}- restore-keys: |- bazel-cache-${{ matrix.target }}-- name: Check MODULE.bazel.lock is up to dateif: matrix.os == 'ubuntu-24.04' && matrix.target == 'x86_64-unknown-linux-gnu'shell: bashrun: ./scripts/check-module-bazel-lock.sh- - name: Set up Bazel execution logs- shell: bash- run: |- mkdir -p "${RUNNER_TEMP}/bazel-execution-logs"- echo "CODEX_BAZEL_EXECUTION_LOG_COMPACT_DIR=${RUNNER_TEMP}/bazel-execution-logs" >> "${GITHUB_ENV}"-- name: bazel test //...env:BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}@@ -133,11 +112,11 @@ jobs:# Save bazel repository cache explicitly; make non-fatal so cache uploading# never fails the overall job. Only save when key wasn't hit.- name: Save bazel repository cache- if: always() && !cancelled() && steps.cache_bazel_repository_restore.outputs.cache-hit != 'true'+ if: always() && !cancelled() && steps.prepare_bazel.outputs.repository-cache-hit != 'true'continue-on-error: trueuses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5with:- path: ${{ steps.setup_bazel.outputs.repository-cache-path }}+ path: ${{ steps.prepare_bazel.outputs.repository-cache-path }}key: bazel-cache-${{ matrix.target }}-${{ hashFiles('MODULE.bazel', 'codex-rs/Cargo.lock', 'codex-rs/Cargo.toml') }}clippy:@@ -162,32 +141,12 @@ jobs:steps:- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6- - name: Set up Bazel CI- id: setup_bazel- uses: ./.github/actions/setup-bazel-ci+ - name: Prepare Bazel CI+ id: prepare_bazel+ uses: ./.github/actions/prepare-bazel-ciwith:target: ${{ matrix.target }}- # Restore the Bazel repository cache explicitly so external dependencies- # do not need to be re-downloaded on every CI run. Keep restore failures- # non-fatal so transient cache-service errors degrade to a cold build- # instead of failing the job.- - name: Restore bazel repository cache- id: cache_bazel_repository_restore- continue-on-error: true- uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5- with:- path: ${{ steps.setup_bazel.outputs.repository-cache-path }}- key: bazel-cache-${{ matrix.target }}-${{ hashFiles('MODULE.bazel', 'codex-rs/Cargo.lock', 'codex-rs/Cargo.toml') }}- restore-keys: |- bazel-cache-${{ matrix.target }}-- - name: Set up Bazel execution logs- shell: bash- run: |- mkdir -p "${RUNNER_TEMP}/bazel-execution-logs"- echo "CODEX_BAZEL_EXECUTION_LOG_COMPACT_DIR=${RUNNER_TEMP}/bazel-execution-logs" >> "${GITHUB_ENV}"-- name: bazel build --config=clippy lint targetsenv:BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }}@@ -230,9 +189,9 @@ jobs:# Save bazel repository cache explicitly; make non-fatal so cache uploading# never fails the overall job. Only save when key wasn't hit.- name: Save bazel repository cache- if: always() && !cancelled()+ if: always() && !cancelled() && steps.prepare_bazel.outputs.repository-cache-hit != 'true'continue-on-error: trueuses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5with:- path: ${{ steps.setup_bazel.outputs.repository-cache-path }}+ path: ${{ steps.prepare_bazel.outputs.repository-cache-path }}key: bazel-cache-${{ matrix.target }}-${{ hashFiles('MODULE.bazel', 'codex-rs/Cargo.lock', 'codex-rs/Cargo.toml') }}