Skip to content

Gave install_riscv.sh the network hardening install.sh already had, and shared it between them - #721

Merged
fdesbiens merged 2 commits into
devfrom
harden-riscv-ci-install
Sep 10, 2026
Merged

Gave install_riscv.sh the network hardening install.sh already had, and shared it between them#721
fdesbiens merged 2 commits into
devfrom
harden-riscv-ci-install

Conversation

@fdesbiens

Copy link
Copy Markdown
Contributor

Follow-up to #717, which enables the RISC-V regression suite in CI and so puts scripts/install_riscv.sh on every pull request's critical path. That script did not have the hardening scripts/install.sh grew for exactly these conditions.

The gap

install.sh carries a retry loop, per-command timeouts and an apt-get update that deliberately warns rather than gates. Its comments record why: a mirror going silent for over two hours, and a Hash Sum mismatch from a third-party repository this project does not use turning builds red. All of that was local to that one file.

install_riscv.sh had none of it. Under set -e, its bare apt-get update was a single point of failure for the whole suite — the precise case install.sh downgrades to a warning on purpose — and its two wget calls, about 500 MB each, had no retry and no timeout.

The change

Rather than copy the helpers and let the two drift again, they move to scripts/tx_ci_common.sh and both scripts source it. This follows the arrangement scripts/tx_windows_common.ps1 already uses on the Windows side.

install.sh keeps its behaviour exactly — same APT_OPTIONS, same 120-second TIMEOUT, same three-attempt retry — and the comments explaining each of them travel with the code they explain.

Two things are new:

  • TIMEOUT_LONG, 180 seconds, for a single large download. Sized against the 39 seconds each tarball took on 10 Sep 2026, and deliberately not larger: the install step is capped at ten minutes, and a per-attempt timeout able to swallow that cap would leave the retry loop no turn to take — which is the failure mode the existing apt comment already records. Three attempts still do not fit inside ten minutes, so the step timeout stays the outer backstop for a server that is genuinely down; what the retries buy is the transient case, which is the common one.
  • fetch(), which verifies a SHA-256 before anything is unpacked. Worth being straight about what this is and is not: expected value and file come from the same host, so it is not an independent trust root and does not prove the release was not tampered with at source. What it buys is that the bytes are pinned — a deleted and re-pushed tag, or a replaced asset, stops the build instead of being picked up silently.

Also verifies qemu-system-riscv32 alongside riscv64. run.sh selects one per architecture, so both are worth failing on in the install step rather than at the first test.

Verification

CI here will not exercise install_riscv.sh until #717 merges, so this was checked locally instead:

  • retry returns 0 on success and 1 after three attempts, with the 10/20/30-second backoff.
  • fetch accepts a correct digest; on a wrong one it fails and removes the partial file, so a bad download cannot be unpacked.
  • The source line resolves from the repository root (how CI invokes it), from an absolute path, and through a symlink.
  • Both recorded digests were checked against the bytes the CDN actually serves for the pinned tag — riscv32-elf 73c9a5ad… and riscv64-elf 4a66a329…, both matching.

Not included

install.sh starts with rm -rf /opt/hostedtoolcache to free space; install_riscv.sh extracts roughly 2.5 GB into /opt without it. That has not caused a failure — the run on #717 was comfortable — so I have left it out rather than change behaviour on a guess. Worth revisiting if disk ever bites.

…nd shared it between them

install.sh grew a retry loop, per-command timeouts and a deliberately
non-gating apt-get update after this runner pool cost several whole runs: a
mirror going silent for two hours, and a Hash Sum mismatch from a third-party
repository the project does not even use turning builds red. Those lessons were
local to that one file.

install_riscv.sh had none of them, and #717 puts it on every pull request's
critical path. Under set -e its bare apt-get update was a single point of
failure for the whole suite -- the precise case install.sh downgrades to a
warning on purpose -- and its two wget calls, each fetching about 500 MB, had
no retry and no timeout.

Rather than copy the helpers and let them drift again, they move to
tx_ci_common.sh and both scripts source it, following the arrangement
scripts/tx_windows_common.ps1 already uses on the Windows side. install.sh
keeps its behaviour exactly: same APT_OPTIONS, same 120-second TIMEOUT, same
three-attempt retry, and the comments explaining each of them travel with the
code they explain.

Two things are new:

  - TIMEOUT_LONG, 180 seconds, for a single large download. Sized against the
    39 seconds each tarball took on 10 Sep 2026 and deliberately not larger:
    the install step is capped at ten minutes, and a per-attempt timeout able
    to swallow that cap would leave the retry loop no turn to take, which is
    the failure mode the apt comment already records.

  - fetch(), which verifies a SHA-256 before anything is unpacked. Both digests
    were taken from the releases API and then checked against the bytes the CDN
    actually serves. This is not an independent trust root -- expected value and
    file come from the same host -- but it pins the bytes, so a deleted and
    re-pushed tag or a replaced asset stops the build instead of being picked up
    silently.

Also verifies qemu-system-riscv32 alongside riscv64. run.sh selects one per
architecture, so both are worth failing on here rather than at the first test.

Verified locally: retry returns 0 on success and 1 after three attempts;
fetch accepts a correct digest and, on a wrong one, fails and removes the
partial file; the source line resolves from the repository root, from an
absolute path and through a symlink; and both recorded digests match the
bytes served for the pinned tag.

Assisted-by: Claude Code (Opus 5) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

Test Results FreeRTOS

3 tests   3 ✅  0s ⏱️
1 suites  0 💤
1 files    0 ❌

Results for commit 2fdb171.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

Test Results ThreadX

490 tests  ±0   490 ✅ ±0   12m 58s ⏱️ + 7m 54s
  5 suites ±0     0 💤 ±0 
  5 files   ±0     0 ❌ ±0 

Results for commit 2fdb171. ± Comparison against base commit 18abe10.

♻️ This comment has been updated with latest results.

@github-actions

Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Health
common.src 100% 78%
Summary 100% (4503 / 4503) 78% (2557 / 3292)

Minimum allowed line rate is 99%

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

Test Results SMP

570 tests   570 ✅  4m 48s ⏱️
  5 suites    0 💤
  5 files      0 ❌

Results for commit 2fdb171.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Health
common_smp.src 100% 81%
Summary 100% (5436 / 5447) 81% (3041 / 3770)

Minimum allowed line rate is 99%

@github-actions

Copy link
Copy Markdown

Test Results RISC-V

955 tests  ±0   955 ✅ ±0   5m 18s ⏱️ -6s
 10 suites ±0     0 💤 ±0 
 10 files   ±0     0 ❌ ±0 

Results for commit 2fdb171. ± Comparison against base commit 18abe10.

@fdesbiens
fdesbiens merged commit 6c84e61 into dev Sep 10, 2026
16 checks passed
@fdesbiens
fdesbiens deleted the harden-riscv-ci-install branch September 10, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant