From 9c915961c74c224bbe2b7a52fd4a039158a81541 Mon Sep 17 00:00:00 2001 From: Andrew Walsh Date: Thu, 5 Nov 2026 16:53:27 -0800 Subject: [PATCH] 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 * 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 --------- Co-authored-by: Claude Opus 5.5 --- package-lock.json | 86 +++++++++++++++++------------------- package.json | 6 +-- test/instrumentation.test.ts | 3 ++ 3 files changed, 47 insertions(+), 48 deletions(-) diff --git a/package-lock.json b/package-lock.json index 074623c..1139c88 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "class-transformer": "^0.5.1", "rollup": "^4.62.2", "tar": "^7.4.3", - "ts-apt": "file:../ts-apt", + "ts-apt": "git+https://github.com/awalsh128/ts-apt.git#4a0305c3fde1f42ea9a5c79ac53bf27fdf5d76c2", "winston": "^3.19.0" }, "devDependencies": { @@ -51,47 +51,6 @@ "url": "https://github.com/sponsors/awalsh128" } }, - "../ts-apt": { - "version": "0.0.0-semantically-released", - "license": "Apache-2.0", - "dependencies": { - "async-mutex": "^0.5.0", - "winston": "^3.19.0" - }, - "bin": { - "apt-fast": "scripts/dist/apt-fast.sh" - }, - "devDependencies": { - "@devcontainers/cli": "^0.87.0", - "@robingenz/zli": "^0.2.0", - "@semantic-release/changelog": "^6.0.3", - "@semantic-release/commit-analyzer": "^13.0.1", - "@semantic-release/git": "^10.0.1", - "@semantic-release/github": "^11.0.6", - "@semantic-release/npm": "^13.1.5", - "@semantic-release/release-notes-generator": "^14.1.1", - "@types/node": "^24.1.0", - "@typescript-eslint/eslint-plugin": "^8.64.0", - "@typescript-eslint/parser": "^8.64.0", - "@vitest/coverage-v8": "^4.1.9", - "eslint": "^10.6.0", - "npm-run-all": "^4.1.5", - "semantic-release": "^25.0.5", - "type-coverage": "^2.29.7", - "typedoc": "^0.28.19", - "typedoc-plugin-markdown": "^4.12.0", - "typescript": "^6.0.3", - "vitest": "^4.1.9", - "zod": "^4.4.3" - }, - "engines": { - "node": ">=24" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/awalsh128" - } - }, "node_modules/@actions/artifact": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/@actions/artifact/-/artifact-6.2.1.tgz", @@ -3277,6 +3236,15 @@ "node": ">= 0.4" } }, + "node_modules/async-mutex": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.5.0.tgz", + "integrity": "sha512-1A94B18jkJ3DYq284ohPxoXbfTA5HsQ7/Mf4DEhcyLx3Bz27Rh59iScbB6EPiP+B+joue6YCxcMXSbFC1tZKwA==", + "license": "MIT", + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/available-typed-arrays": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", @@ -12431,8 +12399,25 @@ } }, "node_modules/ts-apt": { - "resolved": "../ts-apt", - "link": true + "version": "0.0.0-semantically-released", + "resolved": "git+ssh://git@github.com/awalsh128/ts-apt.git#4a0305c3fde1f42ea9a5c79ac53bf27fdf5d76c2", + "integrity": "sha512-9pjQ88xClPTKFMLXIh6l55cWPdrG88uzIjzS5MWo0eu3K/JUqVuZgCkClVq/v/i4jQgZqUSZFPW4oLnMwnP2xw==", + "license": "Apache-2.0", + "dependencies": { + "async-mutex": "^0.5.0", + "winston": "^3.19.0", + "zodline": "^0.3.0" + }, + "bin": { + "apt-fast": "scripts/dist/apt-fast.sh" + }, + "engines": { + "node": ">=24" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/awalsh128" + } }, "node_modules/tslib": { "version": "2.8.1", @@ -13652,11 +13637,22 @@ "version": "4.4.3", "resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz", "integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==", - "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/colinhacks" } + }, + "node_modules/zodline": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/zodline/-/zodline-0.3.2.tgz", + "integrity": "sha512-HR7duP2LEGezEG2D0SOEuuVwR2hI4voyEDrZ0BTifP8euTDIjMU95STjA+Zk6FwWpPbfm32TN5GhIhkJ7SgESA==", + "license": "MIT", + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "zod": "^4.0.0" + } } } } diff --git a/package.json b/package.json index f394129..35b7abd 100644 --- a/package.json +++ b/package.json @@ -54,8 +54,8 @@ "check:pr": "node --experimental-strip-types ./scripts/ops/pr_checks.mts", "check:configs": "node --experimental-strip-types ./scripts/ops/check_configs.mts", "check": "npm run -s runall -- check:latest-action-pins check:pr check:configs", - "dev:tsapt:link": "npm link ../ts-apt --save; echo \"NOTE: npm run dev:tsapt:unlink when you are finished.\"", - "dev:tsapt:unlink": "npm unlink ts-apt && npm install ts-apt", + "dev:tsapt:link": "npm link ../ts-apt --no-save; echo \"NOTE: npm run dev:tsapt:unlink when you are finished.\"", + "dev:tsapt:unlink": "npm unlink ts-apt --no-save && npm ci", "gh:auth": "gh auth status >/dev/null 2>&1 || gh auth login --web && gh auth setup-git", "setup:dev": "node --experimental-strip-types ./scripts/dev/setup_devenv.mts", "repo:sync": "node --experimental-strip-types ./scripts/dev/gh_sync.mts", @@ -85,7 +85,7 @@ "class-transformer": "^0.5.1", "rollup": "^4.62.2", "tar": "^7.4.3", - "ts-apt": "file:../ts-apt", + "ts-apt": "git+https://github.com/awalsh128/ts-apt.git#4a0305c3fde1f42ea9a5c79ac53bf27fdf5d76c2", "winston": "^3.19.0" }, "devDependencies": { diff --git a/test/instrumentation.test.ts b/test/instrumentation.test.ts index f678cb4..e4ea0b4 100644 --- a/test/instrumentation.test.ts +++ b/test/instrumentation.test.ts @@ -4,6 +4,7 @@ import { afterEach, describe, expect, it, vi } from "vitest"; describe("instrumentation", () => { afterEach(() => { vi.restoreAllMocks(); + vi.unstubAllEnvs(); }); const ARTIFACT_FILENAMES = [ @@ -32,6 +33,8 @@ describe("instrumentation", () => { it("constructor generates a random runId when not provided", () => { const dir = "/path/to/artifacts"; const debug = false; + // GitHub Actions sets this, so clear it to test the fallback. + vi.stubEnv("GITHUB_RUN_ID", undefined); const artifacts = new Artifacts(dir, ARTIFACT_FILENAMES, debug); expect(artifacts.runId).toMatch(/^ghrunid-notfound-/);