-
Notifications
You must be signed in to change notification settings - Fork 36
Stop the nightly translation re-translating everything, most days #685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a05bab4
dcfa1c5
b20ebad
d960a1d
bd3c110
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,12 +80,32 @@ jobs: | |
| # hook, which builds the full Next.js application once per language. | ||
| run: bun install --frozen-lockfile --ignore-scripts | ||
|
|
||
| # The old primary key was | ||
| # `translation-cache-${{ hashFiles('scripts/translate-docs/.translation-cache.json') }}`, | ||
| # which ALWAYS evaluated to the bare literal `translation-cache-`: the file | ||
| # is gitignored (.gitignore:68), so it is absent at checkout and | ||
| # `hashFiles` returns "". Every restore that ever worked was a | ||
| # `restore-keys` prefix match, and a total miss is indistinguishable from a | ||
| # hit — nothing fails, nothing warns, the job just spends nine minutes and | ||
| # a full LLM pass. Hence the explicit warning step below: a miss is the | ||
| # expensive case and it should say so in the run summary. | ||
| - name: Restore translation cache | ||
| id: restore-cache | ||
| uses: actions/cache/restore@v6 | ||
| with: | ||
| path: scripts/translate-docs/.translation-cache.json | ||
| key: translation-cache-${{ hashFiles('scripts/translate-docs/.translation-cache.json') }} | ||
| restore-keys: translation-cache- | ||
| # Per language, newest-first, falling back to the merged entry that | ||
| # `consolidate` still writes. `github.run_id` is monotonic, so the | ||
| # prefix match returns this language's most recent fragment. | ||
| key: translation-cache-${{ matrix.lang }}-${{ github.run_id }} | ||
| restore-keys: | | ||
| translation-cache-${{ matrix.lang }}- | ||
| translation-cache- | ||
|
|
||
| - name: Warn on translation cache miss | ||
| if: steps.restore-cache.outputs.cache-matched-key == '' | ||
| run: | | ||
| echo "::warning title=Translation cache MISS::${{ matrix.lang }} will re-translate every page (~9 runner-minutes and one full LLM pass)" | ||
|
|
||
| - name: Translate ${{ matrix.lang }} | ||
| run: bun run translate --languages ${{ matrix.lang }} ${{ inputs.force == true && '--force' || '' }} | ||
|
|
@@ -99,22 +119,45 @@ jobs: | |
| - name: Validate translated pages parse and images resolve | ||
| run: bun run validate:mdx | ||
|
|
||
| # Save HERE, per language, in the job that produced the work and directly | ||
| # after the step that proved it good. | ||
| # | ||
| # The only save used to be `consolidate`'s, downstream of BOTH the matrix | ||
| # gate (`if: needs.translate.result == 'success'`) and `mintlify validate`. | ||
| # So one page failing validation in one language threw away the cache for | ||
| # all fourteen — Aug 6 lost ~110 minutes of completed translation to a | ||
| # single `ko` page — and a nav mismatch in consolidate did the same on | ||
| # Aug 12. Each fragment is already authoritative for its own language, so | ||
| # there is nothing a merge has to happen first for. | ||
| # | ||
| # The `cache-hit` guard is the same one `build-daemon.yml:137` carries, and | ||
| # it is load-bearing here for a specific reason: the key embeds | ||
| # `github.run_id`, which is REUSED when someone re-runs a failed job. On | ||
| # that second attempt the primary key already exists, so the restore above | ||
| # scores an exact hit and this save would collide with itself. | ||
| - name: Save translation cache fragment | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hermes — High/High ( The matrix job saves the new per-language source-hash cache at Required change: Only mark an entry cached once the exact translated bytes are durable on the branch future runs check out, or store a target-content hash in cache entries and require the on-disk output to match it. If preserving per-language work across consolidation failures is required, persist and restore the corresponding output artifact atomically with its cache entry rather than relying on file existence alone. |
||
| if: steps.restore-cache.outputs.cache-hit != 'true' | ||
| uses: actions/cache/save@v6 | ||
| with: | ||
| path: scripts/translate-docs/.translation-cache.json | ||
| key: translation-cache-${{ matrix.lang }}-${{ github.run_id }} | ||
|
|
||
| - name: Upload translated files | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: translations-${{ matrix.lang }} | ||
| path: | | ||
| docs/${{ matrix.lang }}/ | ||
| docs/i18n/README.${{ matrix.lang }}.md | ||
| retention-days: 1 | ||
| retention-days: 7 | ||
| if-no-files-found: error | ||
|
|
||
| - name: Upload cache fragment | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: cache-${{ matrix.lang }} | ||
| path: scripts/translate-docs/.translation-cache.json | ||
| retention-days: 1 | ||
| retention-days: 7 | ||
| if-no-files-found: error | ||
| include-hidden-files: true | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: FailproofAI/failproofai
Length of output: 9116
🏁 Script executed:
Repository: FailproofAI/failproofai
Length of output: 50379
🏁 Script executed:
Repository: FailproofAI/failproofai
Length of output: 1652
Validate and quote
inputs.languagesbefore shell useA
workflow_dispatchuser can setinputs.languages. The value reachesprepareshell source and the unquoted translation command. For example,en;idrunsidas a separate command whileANTHROPIC_API_KEYis set. Validate each language against the supported allowlist inprepare, then pass the validated value through a quoted environment variable.🧰 Tools
🪛 zizmor (1.29.0)
[warning] 108-108: code injection via template expansion (template-injection): may expand into attacker-controllable code
(template-injection)
🤖 Prompt for AI Agents
Source: Linters/SAST tools