cache-apt-pkgs-action/AGENTS.md
Andrew Walsh a84878c774
ci: bundle the action with rollup and upload it for integration jobs (#233)
* ci: bundle the action with rollup and upload it for integration jobs

The integration jobs download an action-bundle-<sha> artifact that
nothing built or uploaded, so all of them failed on their first step.
v2 also had no bundle: action.yml runs dist/index.js, and an action has
no node_modules at runtime.

- Add rollup.config.mjs, which bundles the tsc output (dist/src) into a
  self-contained dist/index.js. npm run build now runs it.
- Fix the setup action, which never built: with if_no_artifact_found:
  ignore the download step always succeeds, so check found_artifact.
  Download cached builds into dist/, and overwrite the build artifact
  since several jobs in a run can build it.
- Upload action.yml and the bundle as action-bundle-<sha> from
  setup-and-cache.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chor: remove stale file

* fix: write logs under the home cache directory and await artifact upload

Instruments opened its log files at the relative path cache-apt-pkgs/
before that directory existed, so the action crashed at startup with
ENOENT. It also pointed artifact uploads there while Cache uses
~/cache-apt-pkgs. Resolve both with a shared resolveCacheDir helper and
create the directory before opening the logs.

The artifact upload was also never awaited, so a failed upload became an
unhandled rejection. Await it and report failures as a warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: ship ts-apt's apt-fast script with the bundle

On runners with aria2 installed, ts-apt uses apt-fast and spawns
scripts/dist/apt-fast.sh relative to its own module. Bundling moved that
module, so the action failed with "spawn .../scripts/dist/apt-fast.sh
ENOENT".

Write the bundle to dist/action/index.js and copy ts-apt's scripts/dist
to dist/scripts/dist, which is where ts-apt looks from there. Point
action.yml at the new entrypoint and include both in the action bundle
artifact. Workflow artifacts drop file modes, so the action marks the
script executable at startup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* build: pin ts-apt to e627c3b for install timeout and dpkg-query fixes

ts-apt killed every apt command after 30 seconds, so installs failed
with exit code 124, and listInstalledFiles passed name=version to
dpkg-query -L, which rejects it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: make diagnostic artifact names unique per step

Every job in a run uploaded capa_artifacts-<run id>, so only the first
upload succeeded. Add the run attempt, job and step IDs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: run cache restore jobs after the jobs that create the cache

The restore and add-package jobs all only needed testing, so they ran in
parallel with standard_workflow_install and raced on the same cache key.
Restore the ordering v1 uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: authenticate the action pin check to avoid API rate limits

The check called the GitHub API anonymously and hit the rate limit for
the shared runner IP. The script uses GITHUB_TOKEN when it's set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* build: pin ts-apt to 342c7d0 for native arch and stdin input

Adds PackageManager.getNativeArchitecture and CommandOptions.input, used by the version-list outputs and archive creation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: report requested and dependency package versions separately

package-version-list held every installed package and both outputs were
identical. Outputs also carried arch suffixes inconsistently and followed
install order.

- package-version-list lists only requested packages; all-package-version-list
  lists every installed package.
- Entries are name=version, with :arch only for packages installed for a
  non-native architecture (e.g. libc6:i386), so native output matches v1.
- Entries are sorted with PackageName.compareTo.
- Requested packages are matched by name, and by arch when both specify one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: archive and restore packages with system tar under sudo

The in-process tar library ran as the runner user, so archiving failed on
root-only files such as /etc/default/cacerts from ca-certificates-java
(regression #72), and extraction could skip root-owned paths without failing.

- Create and extract with sudo tar; the file list is piped NUL-separated on
  stdin so large packages don't exceed the argument size limit.
- Keep directory symlinks such as /lib on extract.
- Hand archives back to the runner user for the cache save.
- Disable the command timeout for tar and maintainer scripts.
- Record the installed (versioned) entries in manifest_main.json; it held
  unversioned names with no files.
- Return every installed package on a cache hit so outputs include deps.
- Split runInstallScripts into per-script runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: update package expectations for Ubuntu 24.04

libasound2 is libasound2t64 on 24.04 (regression #81), and gir1.2-gdkpixbuf-2.0 moved to 2.42.10+dfsg-3ubuntu3.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: add ts-apt boundary rules to AGENTS.md

APT and dpkg logic belongs in ts-apt; ts-apt changes are pushed before the action bumps its pin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: pin version-list jobs to ubuntu-24.04 and fix spaces-in-paths tests

- list_versions / list_all_versions: run on ubuntu-24.04. The expected
  versions are from 24.04, but ubuntu-latest now resolves newer ones
  (e.g. rolldice=1.16-1build4, xdot=1.6-1).
- regression_76: cache libopenal-data ("Default HRTF.mhr") instead of
  Intel oneAPI. Drops the Intel repo and the unused opencl and
  libsundials-dev installs (188 MB, 155 packages), which made the job
  take 75+ minutes when the Ubuntu mirror was slow. Cap at 15 minutes.
- regression_81: list alsa-ucm-conf explicitly so the test caches a
  package with spaces in its file paths.

Same fixes as #235 and #236 on master.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 12:39:31 -08:00

4.5 KiB

AGENT PROFILE

You are an expert developer focused on TypeScript, Bash, DevOps, Git, and GitHub Actions.

Read In Order

  1. Section 0 for always-on rules.
  2. Section 1 for code changes.
  3. Section 2 for tests.
  4. Section 3 for CI/CD and release work.
  5. Section 4 for repo-specific paths and commands.
  6. Section 5 before touching APT, dpkg, or package-name logic.

Instruction Efficiency

  • Keep core rules short and mandatory.
  • Use one rule per line.
  • Prefer MUST, NEVER, and ASK FIRST for high-priority rules.
  • Keep examples minimal.
  • Remove stale or duplicated rules when updating this file.
  • Put fast-changing details in scoped sections.
  • Optimize wording for low-context, low-capability agents.

0) Always Apply

  • Be accurate, not agreeable.
  • Push back on unsafe, incorrect, or non-compliant requests.
  • Ask clarifying questions when a change is ambiguous or risky.
  • State material assumptions before acting.
  • Prefer minimal, reversible changes.
  • Preserve existing architecture unless the user asks for a redesign.
  • Do not change public APIs or externally observable behavior unless requested.
  • Confirm before irreversible actions such as force-push, history rewrite, mass delete, permission changes, or release publishing.
  • Never claim success unless it is verified.
  • Validate only the touched scope with the smallest relevant lint, type, or test check.
  • Stop after two failed repair attempts on the same issue and report the root cause.
  • Never expose, request, or store secrets in model-visible channels.
  • Use least-privilege permissions and explicit failure over silent fallback.
  • Keep GitHub Actions pinned to full commit SHAs.

1) Code Changes

  • Keep naming consistent for semantically equivalent constructs.
  • Follow Microsoft TypeScript style guidance.
  • For Bash, require shellcheck-clean scripts and set -euo pipefail.
  • Document exported types and functions.
  • Add context where behavior is not obvious from the signature.
  • Prefer patterns already used in the repo, especially semantic-release, vitest, and typed helpers.

2) Tests

  • Use the naming pattern <method> <conditions> <expected>.
  • Test behavior, not implementation detail.
  • Keep setup tightly scoped to the condition under test.
  • Use constants when the exact value does not matter.
  • Use parameterized tests or helpers for repeated cases.
  • Do not add control flow inside test bodies.

3) CI/CD And Release

4) Repo Paths And Commands

  • Use scripts/dev/ for development tooling.
  • Use scripts/ops/ for repository checks and release-support automation.
  • Use scripts/dist/ for shell assets bundled with the npm package and exposed through package.json bin/files entries.
  • Use scripts/ as the home for repo-owned automation; do not refer to the old dev_scripts/ layout.

5) ts-apt Boundary

  • ts-apt owns APT and dpkg logic; its local clone is ../ts-apt.
  • MUST make changes in ../ts-apt when they run apt, apt-get, apt-cache, apt-fast, dpkg, or dpkg-query.
  • MUST make changes in ../ts-apt when they parse APT or dpkg output or change PackageName behavior.
  • NEVER call APT or dpkg binaries from src/; add a PackageManager method in ts-apt and call it.
  • This repo owns cache keys, manifests, archives, action inputs, and action outputs.
  • Follow ../ts-apt/AGENTS.md when editing ts-apt.
  • Add ts-apt unit tests for every new ts-apt method.
  • Use npm run dev:tsapt:link to test against local ts-apt; run npm run dev:tsapt:unlink when finished.
  • package.json pins ts-apt to a commit SHA; local ts-apt changes are not visible to CI.
  • MUST push the ts-apt change first, then bump the ts-apt SHA pin in the same change that uses it.
  • NEVER push action code that depends on an unpushed ts-apt change.

Quick Commands

npx eslint src test scripts --ext .ts,.mts
npx tsc -p tsconfig.json --noEmit
npx tsc -p tsconfig.scripts.json --noEmit
npx vitest run
npm run check:pr -- --base-ref staging --head-ref feature/example