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
This commit is contained in:
William Woodruff
2026-08-20 13:54:32 +00:00
committed by copyberry
parent 4a942885c8
commit 2c74b56fcd
2 changed files with 23 additions and 15 deletions

View File

@@ -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"'

View File

@@ -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[@]}")