Commit graph

219 commits

Author SHA1 Message Date
Andrew Walsh 9792dbe32f
style: set Prettier print width to 110 and reformat (#246)
* style: set Prettier print width to 110 and reformat

Without a repo config, the Prettier CLI and Trunk used the default
width of 80, while editors with a user printWidth reflowed files on
save, producing formatting-only diffs. Pin the width in .prettierrc.json
and reformat source, tests, scripts and JS/TS config files to match.

Files that already failed Prettier at width 80 for unrelated reasons
(tsconfig*.json, .trunk/*, V2_FAQ.MD) are left untouched.

No code changes.

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

* test: cover cache restore and save failure paths

Codecov flagged lines in #246 as uncovered patch lines; they were
untested before the reformat touched them. Add behavior tests for:

- Cache: cache miss, missing or empty manifests, unreadable cache dir,
  metapackage-only restore, install scripts running after their archive
  with dpkg actions, existing archives, unavailable cache service, and
  save failures.
- ManifestEntry.fromJSON round trip.
- buildFileList dropping missing files, updateAptLists skipping update
  for populated lists and searching only to max depth, and fromInput
  ignoring a version without a package name.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 11:45:29 -08:00
Andrew Walsh e02349423d
docs(action): clarify version and execute_install_scripts inputs (#245)
Describe version as a user defined value and link the README caveats by
URL, since the bare README.md reference doesn't resolve from the
Marketplace or the workflow editor.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 11:33:11 -08:00
Andrew Walsh e8bec41895
build(deps): install ts-apt 1.1.1 from the npm registry (#244)
ts-apt is now published to npm, so depend on the exact release instead
of a git commit SHA. check_deps_pin accepts an exact registry version
whose lockfile entry resolves from registry.npmjs.org with a sha512
integrity hash, and still accepts a full SHA pin for unreleased ts-apt
changes. Ranges, tags and branch refs are still rejected.

1.1.1 keeps the 1.1.0 public API; the dpkg-query listInstalled output
format change does not affect the action, which doesn't call it.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 16:44:59 -08:00
Andrew Walsh 5905c29b85
perf: speed up cache restores (#243)
* fix: find install scripts for package names with regex metacharacters

findInstallScript built a regex from the raw package name, so names like
g++ or libstdc++6 threw "Nothing to repeat" on cache save and on restore
with install scripts, and a '.' in a name could match another package's
script. Compare file names as plain strings instead.

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

* perf: speed up cache restores

- Upload the diagnostic artifact only when debug is on or the action
  fails. The upload took ~1.4s of a ~3.7s restore in CI.
- Extract all package archives in one sudo shell when install scripts
  are off, instead of a sudo and tar process per package. Per-package
  extraction stays when scripts run, to keep install ordering (#196).
- Skip the apt-fast availability probe on a cache hit, where nothing is
  installed.

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

* docs: document Manifest and ManifestEntry public members

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 16:44:39 -08:00
awalsh128 9ff16f8ab9 chore(workflows) update runner image to use versioned (latest deprecated) 2026-11-08 15:10:20 -08:00
Andrew Walsh 2217e7b9af
Fix README.md badges 2026-11-08 15:06:43 -08:00
Andrew Walsh f187c18217
Update README.md header 2026-11-08 15:05:34 -08:00
Andrew Walsh 803f615529
build: manage git hooks with husky (#242)
Replace the hand-rolled .githooks/ directory and core.hooksPath prepare
script with husky, matching ts-apt. The pre-push hook moves to
.husky/pre-push and still runs npm run check:deps-pin.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 14:24:46 -08:00
Andrew Walsh cd2c2582b9
build(deps): pin ts-apt to v1.1.0 (#240)
* build(deps): pin ts-apt to v1.1.0-rc.1

The previous pin, 342c7d0, was the ts-apt v2-support head before that
branch was rewritten, so no ts-apt branch or tag contains it anymore.
Pin 67d450e, the commit released as ts-apt v1.1.0-rc.1 on staging.

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

* build(deps): pin ts-apt to v1.1.0

Merging main-2 into this branch restored the unreachable 342c7d0 pin in
package.json while package-lock.json kept 67d450e. Pin both to 64aaab8,
the commit released as ts-apt v1.1.0.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 14:24:23 -08:00
Andrew Walsh 07b3b62213
ci: generalize ts-apt pin check into check_deps_pin.mts (#238)
Replace scripts/ops/check_tsapt_pin.sh with scripts/ops/check_deps_pin.mts,
which takes dependency names as arguments and checks each one for a
local symlink, a full commit SHA pin in package.json, and a matching,
non-link package-lock.json entry.

Rename the npm script to check:deps-pin (run with ts-apt) and use it from
the pre-push hook, the CI action-deps-pinned job and AGENTS.md.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 14:26:37 -08:00
Andrew Walsh 728251154e
build: remove unused dependencies and address npm audit findings (#239)
* chore: remove unused dist directory

* build: remove unused dependencies and address npm audit findings

Remove dependencies nothing imports or runs: class-transformer, tar and
@types/tar (archives use system tar), internet-message,
@devcontainers/cli, @typescript-eslint/eslint-plugin, typedoc and
typedoc-plugin-markdown (with the dead docs:api script). Move rollup to
devDependencies since it is only used to build the bundle.

Update dependencies within their declared ranges and add scoped
overrides: glob 9.0.0 - 14.0.1 to ^14.0.4, and minimatch ^11.0.5 for
eslint, @typescript-eslint/parser and type-coverage only. minimatch is
not overridden for @actions/glob because minimatch 11 removed matchOne,
which @actions/glob calls (breaking cache hashFiles).

npm audit goes from 66 (2 critical, 10 high) to 39 (0 critical, 0 high).
Remaining: minimatch inside @actions/glob (production), npm's bundled
dependencies under @semantic-release/npm, and deepmerge (no fix).

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 14:22:32 -08:00
Andrew Walsh 06c1af1b1c
ci: guard against shipping a locally linked ts-apt (#237)
Add scripts/ops/check_tsapt_pin.sh, which fails when node_modules/ts-apt
is a symlink, package.json does not pin ts-apt to a full commit SHA, or
package-lock.json resolves ts-apt to a link or a different SHA.

Run it from a .githooks/pre-push hook (installed by the npm prepare
script via core.hooksPath) and from the CI action-deps-pinned job, and
document the rule in AGENTS.md.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 12:57:15 -08:00
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
Andrew Walsh 16d0f3489d
ci: fix linters, action pin check and npm audit failures (#232)
- eslint: parse scripts/**/*.{ts,mts} with the TypeScript parser.
  Only src and test were configured, so the scripts failed to parse.
- action-deps-pinned: run the --scan check over .github. The step passed
  ./action.yml, which the script doesn't accept, and action.yml has no
  uses: dependencies to check anyway.
- npm audit fix for the high severity advisories in production
  dependencies (undici, brace-expansion) and @actions/artifact 6.3.1.
  The remaining moderate glob/minimatch advisories need a breaking
  @actions/artifact downgrade, and the audit step only fails on high.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 17:26:06 -08:00
Andrew Walsh 9c915961c7
build: install ts-apt from GitHub instead of a local path (#231)
* build: install ts-apt from GitHub instead of a local path

package.json pointed ts-apt at file:../ts-apt, which only exists on a
dev machine, so every test suite in CI failed with "Cannot find package
'ts-apt'". ts-apt isn't on npm, so pin it to a commit on GitHub. Its
prepare script builds dist on install.

The dev:tsapt:link script used --save, which is how the local path got
committed. Use --no-save so linking a local ts-apt doesn't change
package.json, and restore with npm ci on unlink.

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

* test: clear GITHUB_RUN_ID when testing the run ID fallback

GitHub Actions always sets GITHUB_RUN_ID, so the fallback test failed
once CI could run the tests at all.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 16:53:27 -08:00
Andrew Walsh 1008cb540c
fix: archive installed package files on cache miss (#229)
Manifest.from built every entry with an empty file list and buildFileList
was never called, so tar.create was handed no paths. node-tar throws "no
paths specified to add to archive" for that, so every cache miss failed
before saving.

The runner now builds each manifest entry from buildFileList and passes
the manifest to archiveAndSave. Packages with no files (e.g.
metapackages) are skipped on archive and on restore since tar can't
create an empty archive. Manifest.from is removed.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 16:34:09 -08:00
Andrew Walsh 79721099c8
fix: restore cached packages in apt install order (#228)
Restore extracted archives sorted by filename, so packages whose install
scripts depend on files from other packages could break. Restore now
follows the entry order in manifest_all.json, which comes from the apt
install output, and fails explicitly when an archive is missing.

Refs #196

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 16:26:07 -08:00
awalsh128 0bada9deed Add local act CI runner and document @latest-v2
Add an .actrc, runner Dockerfile, push event payload, and
scripts/dev/act_ci.sh to run ci.yml jobs locally with nektos/act.
The script refuses --bind/--reuse in .actrc, since a bound checkout
runs as root and rewrites ownership and modes in the working tree.

Document the @latest-v2 version label in the README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 09:16:44 -07:00
awalsh128 fd8f3d3fd1 stuff 2026-08-01 12:33:44 -07:00
awalsh128 c2de292527 stuff 2026-07-25 16:08:50 -07:00
awalsh128 55278329ef fix dev dependencies 2026-07-03 20:52:21 -07:00
awalsh128 b3e03779c4 remove docs, add best practices scripts and fix CI with v1 action tests 2026-07-03 20:43:59 -07:00
awalsh128 3f70aca939 do stuff 2026-06-30 00:17:51 -07:00
awalsh128 1d921eeba9 fixed errors and restoring as a pure port from v1 2026-06-28 15:56:51 -07:00
awalsh128 42b6b9694b Draft of v2 2026-06-28 13:27:41 -07:00
Takahiro Ueda a605dbde2a
Add empty_packages_behavior option to handle empty package list (#154)
Available options: 'error' (default), 'warn' and 'ignore'.
2025-08-16 19:34:34 -07:00
awalsh128 2c09a5e66d Binary for https://github.com/awalsh128/cache-apt-pkgs-action/pull/160 2025-08-10 17:15:27 -07:00
Sébastien Morais 9a146f43d1
fix: skip invalid lines (#160) 2025-08-10 17:11:12 -07:00
Mike Tesch cbdbab28e6
Automatically append the OS architecture to the cache key (#150) 2025-08-10 13:24:23 -07:00
Andrew Walsh 23ccb675d9
Update README.md 2025-07-07 20:37:29 -07:00
Andrew Walsh db548ecc55
Update README.md 2025-07-07 20:35:48 -07:00
Khyber Sen 4c82c3ccdc
Remove GitHub URL shorteners (git.io) as they no longer work. (#164)
Fixes #163.
2025-07-07 20:15:12 -07:00
awalsh128 7ca5f46d06 Fix exec error. 2025-03-16 14:39:03 -07:00
Andrew Walsh 2330cb6dfb
Add support for virtual packages and break out APT logic into common library. (#155)
* Add support for virtual packages and break out APT logic into common library.
* Update binaries from commit 128de25ccb
2025-03-16 13:05:35 -07:00
Andrew Walsh 128de25ccb
Add support for virtual packages and break out APT logic into common library. (#153) 2025-03-16 12:35:38 -07:00
Bradley Scott 13d2226e13
Avoid using xargs when creating package tarballs (#136) 2025-02-04 10:08:04 -08:00
Ülgen Sarıkavak d1a184e480
Update actions/checkout versions in README (#148) 2025-02-03 11:42:51 -08:00
Jacco Broeren dfe9c8af34
fix: remove timestamps from loglines (#146) 2025-01-23 20:00:46 -08:00
Max Schwenk 5902b33ae2
Upgrade to cache v4 (#140) 2025-01-09 11:16:31 -08:00
Andrew Walsh f2fc6d1af4 Explicitly don't fail on error in library calls (required for conditonals) 2024-03-03 14:39:27 -08:00
Oliver Kopp a6c3917cc9
Add arm64 binary (#127)
* Add support for arm64 APT in Go apt-query binary.
2024-03-01 12:59:14 -08:00
Andrew Walsh 2555a377df
Bump force reload to accommodate update on cache action save version. #122 2024-02-13 21:42:01 -08:00
Hadrien G 75ab37ec52
Use matching versions of actions/cache actions (#123)
Needed to finish migration to node20 + probably wiser overall to use matching versions of the caching actions.
2024-02-13 21:38:36 -08:00
Andrew Walsh a9d925863b
Bump global version of cache.
Force cache reload for new version of cache action.
2024-02-13 11:36:57 -08:00
Daniel Possenriede 5c74a020dc
Bump actions/cache/restore to v4 (#120) 2024-02-01 13:13:10 -08:00
Andrew Walsh 6460a33c29
First version of a Golang version for APT package querying. (#118) (#119)
* Pull dev upstream to staging. (#112)

* Use awk to enclose filename in single quotes tar #99

* Add null field separator so filenames don't get broken up.

* Move upload logs up in the action sequence so it captures data before it gets deleted.

* Fix awk (#109)

---------

Co-authored-by: sn-o-w <cristian.silaghi@mozilla.ro>

* Fix awk delimiter.

Pull in fix by @sn-o-w in d0ee83b497 mentioned in issue #99

* Swap out Bash based APT query logic for Golang version. (#117)

* First version of a Golang version of command handling in general. (#118)

---------

Co-authored-by: sn-o-w <cristian.silaghi@mozilla.ro>
2023-12-22 10:28:03 -08:00
Andrew Walsh 44c33b32f8
Pull staging changes upstream. (#113)
* Pull dev upstream to staging. (#112)

* Use awk to enclose filename in single quotes tar #99

* Add null field separator so filenames don't get broken up.

* Move upload logs up in the action sequence so it captures data before it gets deleted.

* Fix awk (#109)

---------

Co-authored-by: sn-o-w <cristian.silaghi@mozilla.ro>

* Fix awk delimiter.

Pull in fix by @sn-o-w in d0ee83b497 mentioned in issue #99

---------

Co-authored-by: sn-o-w <cristian.silaghi@mozilla.ro>
2023-10-30 11:12:50 -07:00
Andrew Walsh 6f9e6a86db
Update README.md 2023-10-11 08:11:43 -07:00
Steven Hartland 641f947ac2
fix: apt cache performance (#104)
* fix: apt cache performance

Use a single call to apt-cache to reduce the time needed to lookup
package versions.

Also:
* Added millisecond details to log timing so slow operations can be more
  easily identified.
* Perform apt update before determining package versions.

Fixes #103

* chore: descriptive variable names and use log_err

Added the review feedback, updating variable names to be more
descriptive and using log_err where appropriate.
2023-10-11 08:07:11 -07:00
awalsh128 1850ee53f6 Documentation for versioning support. 2023-03-24 04:50:32 -07:00