From 2004007f804495bc11937d912f46d60b7aad4d68 Mon Sep 17 00:00:00 2001 From: kevinwang5658 <20214115+kevinwang5658@users.noreply.github.com> Date: Tue, 30 Jun 2026 03:43:14 +0000 Subject: [PATCH] fix: auto-fix test failures from Test all (Linux) --- src/resources/asdf/asdf.ts | 9 ++++++++- test/asdf/asdf-install.test.ts | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/resources/asdf/asdf.ts b/src/resources/asdf/asdf.ts index 0e14f2d6..d1342607 100644 --- a/src/resources/asdf/asdf.ts +++ b/src/resources/asdf/asdf.ts @@ -92,7 +92,14 @@ export class AsdfResource extends Resource { await CoreUtils.installViaPkgMgr('curl'); } - const { data: latestVersion } = await $.spawn('curl -s https://api.github.com/repos/asdf-vm/asdf/releases/latest | grep \'"tag_name":\' | sed -E \'s/.*"([^"]+)".*/\\1/\''); + // Extract latest version from GitHub's /releases/latest redirect — avoids API rate limits + const { data: locationData } = await $.spawn( + "curl -sI https://github.com/asdf-vm/asdf/releases/latest | grep -i 'location:' | sed 's|.*/tag/||' | tr -d '\\r\\n'" + ); + const latestVersion = locationData.trim(); + if (!latestVersion) { + throw new Error('Failed to determine the latest asdf version from GitHub. Check network connectivity.'); + } // Create .asdf directory if it doesn't exist const asdfDir = path.join(os.homedir(), '.local', 'bin'); diff --git a/test/asdf/asdf-install.test.ts b/test/asdf/asdf-install.test.ts index 52909c18..2a0c17e2 100644 --- a/test/asdf/asdf-install.test.ts +++ b/test/asdf/asdf-install.test.ts @@ -34,7 +34,8 @@ describe('Asdf install tests', async () => { validateDestroy: async () => { expect(await testSpawn('which asdf')).toMatchObject({ status: SpawnStatus.ERROR }); expect(await testSpawn('which deno')).toMatchObject({ status: SpawnStatus.ERROR }); - expect(await testSpawn('which go')).toMatchObject({ status: SpawnStatus.ERROR }); + // Check the asdf shim is gone rather than `which go` — system Go may be pre-installed on the runner + expect(await testSpawn('test -f ~/.asdf/shims/go')).toMatchObject({ status: SpawnStatus.ERROR }); } }); @@ -59,7 +60,8 @@ describe('Asdf install tests', async () => { }, validateDestroy: async () => { expect(await testSpawn('which asdf')).toMatchObject({ status: SpawnStatus.ERROR }); - expect(await testSpawn('which go')).toMatchObject({ status: SpawnStatus.ERROR }); + // Check the asdf shim is gone rather than `which go` — system Go may be pre-installed on the runner + expect(await testSpawn('test -f ~/.asdf/shims/go')).toMatchObject({ status: SpawnStatus.ERROR }); } }); })