From 2c74b56fcde8a4f32c44701b7e6452e4c526f9e6 Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Thu, 20 Aug 2026 13:54:32 +0000 Subject: [PATCH] Pass CI workflow inputs through environment variables (#39717) ## Why Embedding reusable-workflow inputs directly in shell scripts can cause their contents to be interpreted as shell syntax. ## What changed - Export the Rust nextest target, profile, and test-thread inputs as environment variables before using them in Bash commands and paths. - Pass the MSVC target and host architecture to PowerShell through environment variables. GitOrigin-RevId: f96bbeeb7b556022e4bdea9db384a88f925050bf --- .github/actions/setup-msvc-env/action.yml | 5 ++- .../rust-ci-full-nextest-platform.yml | 33 +++++++++++-------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/.github/actions/setup-msvc-env/action.yml b/.github/actions/setup-msvc-env/action.yml index 287cb7f217..ab987a052b 100644 --- a/.github/actions/setup-msvc-env/action.yml +++ b/.github/actions/setup-msvc-env/action.yml @@ -14,4 +14,7 @@ runs: steps: - name: Expose MSVC SDK environment shell: pwsh - run: '& "$env:GITHUB_ACTION_PATH/setup-msvc-env.ps1" -Target "${{ inputs.target }}" -HostArch "${{ inputs.host-arch }}"' + env: + HOST_ARCH: ${{ inputs.host-arch }} + TARGET: ${{ inputs.target }} + run: '& "$env:GITHUB_ACTION_PATH/setup-msvc-env.ps1" -Target "$env:TARGET" -HostArch "$env:HOST_ARCH"' diff --git a/.github/workflows/rust-ci-full-nextest-platform.yml b/.github/workflows/rust-ci-full-nextest-platform.yml index e86bc0bb99..8799f1ea03 100644 --- a/.github/workflows/rust-ci-full-nextest-platform.yml +++ b/.github/workflows/rust-ci-full-nextest-platform.yml @@ -62,6 +62,8 @@ jobs: # so the cross-compile build reuses the Windows x64 cache lineage. ARCHIVE_CACHE_RUNNER: ${{ inputs.archive_runner != '' && inputs.archive_runner || inputs.runner }} USE_SCCACHE: ${{ inputs.use_sccache && 'true' || 'false' }} + CODEX_CI_PROFILE: ${{ inputs.profile }} + CODEX_CI_TARGET: ${{ inputs.target }} CARGO_INCREMENTAL: "0" SCCACHE_CACHE_SIZE: 10G NEXTEST_ARCHIVE_FILE: nextest-${{ inputs.artifact_id }}.tar.zst @@ -170,8 +172,8 @@ jobs: archive_dir="${RUNNER_TEMP}/nextest-archive" mkdir -p "${archive_dir}" cargo nextest archive \ - --target ${{ inputs.target }} \ - --cargo-profile ${{ inputs.profile }} \ + --target "${CODEX_CI_TARGET}" \ + --cargo-profile "${CODEX_CI_PROFILE}" \ --timings \ --archive-file "${archive_dir}/${NEXTEST_ARCHIVE_FILE}" @@ -185,20 +187,20 @@ jobs: if [[ "${RUNNER_OS}" == "Linux" ]]; then cargo build \ - --target ${{ inputs.target }} \ - --profile ${{ inputs.profile }} \ + --target "${CODEX_CI_TARGET}" \ + --profile "${CODEX_CI_PROFILE}" \ -p codex-linux-sandbox \ --bin codex-linux-sandbox - cp "${CARGO_TARGET_DIR}/${{ inputs.target }}/${{ inputs.profile }}/codex-linux-sandbox" "${helper_dir}/" + cp "${CARGO_TARGET_DIR}/${CODEX_CI_TARGET}/${CODEX_CI_PROFILE}/codex-linux-sandbox" "${helper_dir}/" else cargo build \ - --target ${{ inputs.target }} \ - --profile ${{ inputs.profile }} \ + --target "${CODEX_CI_TARGET}" \ + --profile "${CODEX_CI_PROFILE}" \ -p codex-windows-sandbox \ --bin codex-windows-sandbox-setup \ --bin codex-command-runner - cp "${CARGO_TARGET_DIR}/${{ inputs.target }}/${{ inputs.profile }}/codex-windows-sandbox-setup.exe" "${helper_dir}/" - cp "${CARGO_TARGET_DIR}/${{ inputs.target }}/${{ inputs.profile }}/codex-command-runner.exe" "${helper_dir}/" + cp "${CARGO_TARGET_DIR}/${CODEX_CI_TARGET}/${CODEX_CI_PROFILE}/codex-windows-sandbox-setup.exe" "${helper_dir}/" + cp "${CARGO_TARGET_DIR}/${CODEX_CI_TARGET}/${CODEX_CI_PROFILE}/codex-command-runner.exe" "${helper_dir}/" fi - name: Upload Cargo timings (nextest) @@ -256,7 +258,7 @@ jobs: shell: bash run: | { - echo "### sccache stats — ${{ inputs.target }} (tests)"; + echo "### sccache stats — ${CODEX_CI_TARGET} (tests)"; echo; echo '```'; sccache --show-stats || true; @@ -272,6 +274,9 @@ jobs: run: working-directory: codex-rs env: + CODEX_CI_PROFILE: ${{ inputs.profile }} + CODEX_CI_TARGET: ${{ inputs.target }} + CODEX_CI_TEST_THREADS: ${{ inputs.test_threads }} NEXTEST_ARCHIVE_FILE: nextest-${{ inputs.artifact_id }}.tar.zst TEST_HELPERS_ARTIFACT: nextest-test-helpers-${{ inputs.artifact_id }} strategy: @@ -344,13 +349,13 @@ jobs: if [[ "${RUNNER_OS}" == "Linux" ]]; then helper_dir="${RUNNER_TEMP}/${TEST_HELPERS_ARTIFACT}" - helper_target_dir="${CARGO_TARGET_DIR}/${{ inputs.target }}/${{ inputs.profile }}" + helper_target_dir="${CARGO_TARGET_DIR}/${CODEX_CI_TARGET}/${CODEX_CI_PROFILE}" mkdir -p "${helper_target_dir}" cp "${helper_dir}/codex-linux-sandbox" "${helper_target_dir}/" chmod +x "${helper_target_dir}/codex-linux-sandbox" elif [[ "${RUNNER_OS}" == "Windows" ]]; then helper_dir="${RUNNER_TEMP}/${TEST_HELPERS_ARTIFACT}" - helper_target_dir="${CARGO_TARGET_DIR}/${{ inputs.target }}/${{ inputs.profile }}" + helper_target_dir="${CARGO_TARGET_DIR}/${CODEX_CI_TARGET}/${CODEX_CI_PROFILE}" mkdir -p "${helper_target_dir}" cp "${helper_dir}/codex-windows-sandbox-setup.exe" "${helper_target_dir}/" cp "${helper_dir}/codex-command-runner.exe" "${helper_target_dir}/" @@ -363,8 +368,8 @@ jobs: --workspace-remap "${workspace_root}" --partition "hash:${{ matrix.shard }}/4" ) - if [[ "${{ inputs.test_threads }}" != "0" ]]; then - nextest_args+=(--test-threads "${{ inputs.test_threads }}") + if [[ "${CODEX_CI_TEST_THREADS}" != "0" ]]; then + nextest_args+=(--test-threads "${CODEX_CI_TEST_THREADS}") fi test_command=(cargo nextest "${nextest_args[@]}")