Skip to content

Commit 8b58370

Browse files
fix: auto-fix test failures from Test all (Linux) (#74)
Co-authored-by: kevinwang5658 <20214115+kevinwang5658@users.noreply.github.com>
1 parent f5279f7 commit 8b58370

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/resources/asdf/asdf.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,14 @@ export class AsdfResource extends Resource<AsdfConfig> {
9292
await CoreUtils.installViaPkgMgr('curl');
9393
}
9494

95-
const { data: latestVersion } = await $.spawn('curl -s https://api.github.com/repos/asdf-vm/asdf/releases/latest | grep \'"tag_name":\' | sed -E \'s/.*"([^"]+)".*/\\1/\'');
95+
// Extract latest version from GitHub's /releases/latest redirect — avoids API rate limits
96+
const { data: locationData } = await $.spawn(
97+
"curl -sI https://github.com/asdf-vm/asdf/releases/latest | grep -i 'location:' | sed 's|.*/tag/||' | tr -d '\\r\\n'"
98+
);
99+
const latestVersion = locationData.trim();
100+
if (!latestVersion) {
101+
throw new Error('Failed to determine the latest asdf version from GitHub. Check network connectivity.');
102+
}
96103

97104
// Create .asdf directory if it doesn't exist
98105
const asdfDir = path.join(os.homedir(), '.local', 'bin');

test/asdf/asdf-install.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ describe('Asdf install tests', async () => {
3434
validateDestroy: async () => {
3535
expect(await testSpawn('which asdf')).toMatchObject({ status: SpawnStatus.ERROR });
3636
expect(await testSpawn('which deno')).toMatchObject({ status: SpawnStatus.ERROR });
37-
expect(await testSpawn('which go')).toMatchObject({ status: SpawnStatus.ERROR });
37+
// Check the asdf shim is gone rather than `which go` — system Go may be pre-installed on the runner
38+
expect(await testSpawn('test -f ~/.asdf/shims/go')).toMatchObject({ status: SpawnStatus.ERROR });
3839
}
3940
});
4041

@@ -59,7 +60,8 @@ describe('Asdf install tests', async () => {
5960
},
6061
validateDestroy: async () => {
6162
expect(await testSpawn('which asdf')).toMatchObject({ status: SpawnStatus.ERROR });
62-
expect(await testSpawn('which go')).toMatchObject({ status: SpawnStatus.ERROR });
63+
// Check the asdf shim is gone rather than `which go` — system Go may be pre-installed on the runner
64+
expect(await testSpawn('test -f ~/.asdf/shims/go')).toMatchObject({ status: SpawnStatus.ERROR });
6365
}
6466
});
6567
})

0 commit comments

Comments
 (0)