Skip to content

ci: install the apt packages of the Linux test jobs from a cache - #346371

Merged
Ladislau Szomoru (lszomoru) merged 1 commit into
mainfrom
lszomoru/agents/linux-apt-package-cache
Nov 5, 2026
Merged

Ladislau Szomoru (lszomoru) merged 1 commit into
mainfrom
lszomoru/agents/linux-apt-package-cache

Conversation

@lszomoru

Copy link
Copy Markdown
Member

The Linux test jobs spend from 17 s to almost 2 minutes in "Setup system services". All of them download the same 18 packages (about 2.4 MB: libkrb5-dev and libxkbfile-dev with their -dev dependencies, bubblewrap and socat; the rest of the list is already on the runner), and some get an Ubuntu mirror that sends them at about 30 kB/s. In two jobs of #346362 and #346270 the download alone took 1 min 10 s and 1 min 26 s; in others it took 1 s.

This caches the .deb files the same way as the WSL distribution of the Windows smoke tests. It is independent of #346362 (the workspace images) and works with or without an image.

What changed

  • New install-linux-packages action. The package list moves to its packages.txt (unchanged). The action:
    • restores the newest cache entry for the runner image (ImageOS, ImageVersion), the runner arch and a hash of the list;
    • installs the .deb files with dpkg -i, without apt-get update, and checks with dpkg --audit that dpkg left nothing half-installed;
    • falls back to today's apt-get update and apt-get install without an entry for the runner image (for example while a new runner image rolls out), or when dpkg fails. The fallback adds --fix-broken to repair what dpkg left, and warns when the cached files didn't install.
  • pr-workspace-images.yml: new linux-packages job, which runs on the daily schedule and on manual runs only, like wsl-distro. It downloads the .deb files the runner lacks (apt-get install --download-only), installs them with the same action, and checks that apt-get has nothing left to install. Only then does it save a new cache entry (key …-<run_id>-<run_attempt>). If the check fails, the job fails and saves nothing. The check matters because apt-retry.sh never returns apt-get's exit code, so a failed download would otherwise go unnoticed.
  • pr-linux-test.yml: "Setup system services" keeps the sysctl and Xvfb setup. The packages come from a new "Install system packages" step before it.
  • build/ripple/vscode.jsonc: the action is part of the "test job definition".

The key holds the exact runner image, since the set of missing packages depends on it. The files are those apt itself chose for that image, so dpkg -i needs nothing else. Runner images change about weekly. Until the next daily run after an image update, jobs on the new image use apt-get as before; a manual run of the workflow fills the cache right away.

What to look for

  • In this PR's Linux jobs: nothing is cached on main yet, so "Install system packages" prints "No cached packages for the image of the runner" and installs with apt-get as before. The jobs should pass as they do today.
  • After the first daily or manual run on main: the Linux (apt packages) job lists the .deb files, installs them and saves the cache. Linux test jobs on the same runner image then print "Installing N .deb files of apt-packages-v1-…", and the step takes a few seconds, with no apt-get lines.

Validation:

  • cd build && node --test lib/test/detectMissingCaches.test.ts lib/test/detectChanges.test.ts lib/test/workspaceImage.test.ts lib/test/agentHostTestSelection.test.ts: 35 passed
  • go run github.com/rhysd/actionlint/cmd/actionlint@latest -shellcheck= .github/workflows/pr-linux-test.yml .github/workflows/pr-workspace-images.yml .github/workflows/pr.yml: only unknown custom runner labels
  • bash -n on the action's scripts: passed. The install script was also run against stubbed sudo, dpkg, apt-get and apt-retry.sh, covering a cache hit (with and without files), dpkg failing, dpkg --audit reporting a problem, a missing or mismatched key, and the producer saving a complete set or refusing an incomplete one or one dpkg can't install: all behaved as intended.
  • Not run: the producer on a real runner, since only runs on main save caches that pull requests can read. Its first daily or manual run on main exercises it.

The Linux test jobs spent from 17 s to almost 2 minutes in "Setup system
services": all of them download the same few MB of packages, and some get
a mirror that sends them at about 30 kB/s.

Like the WSL distribution of the Windows smoke tests, the daily and manual
runs of pr-workspace-images.yml now cache what the jobs would download:
the new linux-packages job downloads the .deb files of the packages that
the runner lacks, checks that they install, and saves them under a key of
the runner image (ImageOS and ImageVersion) and the package list. The new
install-linux-packages action, which the Linux test jobs use, restores the
newest entry of its key and installs the files with dpkg, without apt-get
update. Without an entry for the image of the runner, for example during
the rollout of a new runner image, or when dpkg fails, apt-get installs
the packages as before and repairs what dpkg left.

The package list moves to .github/actions/install-linux-packages/
packages.txt, which both jobs read, and which ripple counts as part of the
definition of the test jobs.

Co-authored-by: Alex Dima <alexdima@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The new producer and cache-hit dpkg installation have only stubbed validation, so package completeness and cache save/restore interoperability need a real target-runner round trip before use across all Linux test jobs.

No open issues 🎉

What changed in this PR

This PR reduces Linux test setup time by caching system package downloads independently of workspace images, while retaining apt-get installation as a fallback.

Changes:

  • Adds a composite action and shared package list to install cached .deb files keyed by runner image, architecture, and package list.
  • Adds a daily/manual cache producer that validates installation before saving packages.
  • Integrates the action into Linux test jobs and Ripple’s test-job change detection.
File Description
build/​ripple/​vscode.jsonc Includes the new action in test-job change detection.
.github/​workflows/​pr-workspace-images.yml Adds the daily/manual Linux package cache producer.
.github/​workflows/​pr-linux-test.yml Moves package installation into the new action, retaining service setup.
.github/​actions/​install-linux-packages/​packages.txt Centralizes the unchanged system package list.
.github/​actions/​install-linux-packages/​action.yml Implements cache restore, installation, fallback, validation, and saving.

Review effort: Balanced

@lszomoru
Ladislau Szomoru (lszomoru) merged commit f4f6da3 into main Nov 5, 2026
60 checks passed
@lszomoru
Ladislau Szomoru (lszomoru) deleted the lszomoru/agents/linux-apt-package-cache branch November 5, 2026 21:10
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 5, 2026
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.

3 participants