ci: HF_HOME cannot be set from the job-level env block

195d60b never ran: GitHub rejected the workflow file itself, before any job
started, so the whole matrix reported failure with no logs.

Cause: `HF_HOME: ${{ runner.temp }}/hf-cache` sat in jobs.test.env, and the
`runner` context is not available there — only github / inputs / matrix /
needs / secrets / strategy / vars are. PyYAML parses such a file happily, which
is why local validation passed it.

Moved to a first step that writes HF_HOME into $GITHUB_ENV via $RUNNER_TEMP
(same value, and `runner` IS allowed inside steps, which is where the two
cache steps already reference it).

Verified with actionlint, which flags the old file at the exact line and passes
the new one — a real workflow validator rather than a YAML parse. Worth wiring
into the lint job so this class cannot recur; not done here to keep this commit
to the regression.
This commit is contained in:
Alpamys 2026-08-05 01:27:27 +05:00
parent 195d60b8c7
commit 7d3be55d66
1 changed files with 12 additions and 6 deletions

View File

@ -49,17 +49,23 @@ jobs:
# (seen with trl.trainer.grpo_trainer on windows-latest / py3.11).
PYTHONUTF8: "1"
PYTHONIOENCODING: "utf-8"
# Pin the HF cache to a deterministic path so actions/cache restores it
# identically on ubuntu / windows / macos — the default
# ~/.cache/huggingface sits under a different user on each runner. Kept
# OUTSIDE the checkout on purpose: this lands ~0.5 GB on disk, and inside
# the repo it would be walked by the tests that scan cwd for containment.
HF_HOME: ${{ runner.temp }}/hf-cache
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Pin the HF cache to a deterministic path
# Set here and not in the job-level `env:` block: the `runner` context
# is not available there (only github / needs / strategy / matrix /
# vars / secrets / inputs are), and referencing it makes GitHub reject
# the whole workflow file before any job starts.
#
# Why a fixed path at all: the default ~/.cache/huggingface sits under
# a different user on each runner OS, so actions/cache cannot restore
# it by one key. Kept OUTSIDE the checkout because it lands ~0.5 GB,
# which the tests that walk cwd for containment would otherwise scan.
shell: bash
run: echo "HF_HOME=$RUNNER_TEMP/hf-cache" >> "$GITHUB_ENV"
- name: Restore HF Hub cache
id: hf-cache
uses: actions/cache/restore@v4