Skip to content

Commit 52c3666

Browse files
committed
Resolve GMAT root by exact wrapper path
- locateGmatRoot now checks exactly <staging>/GMAT/<version>/api/BuildApiStartupFile.py and returns <staging>/GMAT/<version>. The R2026a Linux tarball wraps the install in two levels (GMAT/R2026a/...); R2022a and R2025a use the same shape (verified against the live SourceForge tarballs). The previous depth-0/1 search overgeneralized from a single tarball and missed R2026a. - extract(archivePath, version) now takes version; install.ts threads inputs.version through the orchestrator. - Loud failure on layout drift: if the expected path is missing, the error names exactly which path was expected so the next bisect is one step. - No discovery, no BFS, no scan. The supported-version matrix (R2022a, R2025a, R2026a — note R2023a/R2024a were never released) all match this layout; if a future release ever changes shape, we'll hear about it loudly and adapt with the actual evidence in hand. - dist/index.js regenerated. Closes #27
1 parent 7c9997c commit 52c3666

3 files changed

Lines changed: 14 additions & 18 deletions

File tree

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/extract.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { existsSync } from 'node:fs';
2-
import { readdir } from 'node:fs/promises';
32
import * as os from 'node:os';
43
import * as path from 'node:path';
54
import * as core from '@actions/core';
65
import * as io from '@actions/io';
76
import * as tc from '@actions/tool-cache';
7+
import type { GmatVersion } from './inputs';
88

99
const API_STARTUP_FILE = path.join('api', 'BuildApiStartupFile.py');
1010

11-
export async function extract(archivePath: string): Promise<string> {
11+
export async function extract(archivePath: string, version: GmatVersion): Promise<string> {
1212
core.info(`Extracting GMAT installer ${archivePath}`);
1313
const stagingDir = await tc.extractTar(archivePath);
1414
core.debug(`Extracted to ${stagingDir}`);
1515

16-
const stagedRoot = await locateGmatRoot(stagingDir);
16+
const stagedRoot = locateGmatRoot(stagingDir, version);
1717
core.debug(`Resolved staged GMAT_ROOT: ${stagedRoot}`);
1818

1919
const finalRoot = path.join(runnerTemp(), 'gmat');
@@ -26,21 +26,15 @@ export async function extract(archivePath: string): Promise<string> {
2626
return finalRoot;
2727
}
2828

29-
async function locateGmatRoot(stagingDir: string): Promise<string> {
30-
if (existsSync(path.join(stagingDir, API_STARTUP_FILE))) {
31-
return stagingDir;
32-
}
33-
const entries = await readdir(stagingDir, { withFileTypes: true });
34-
for (const entry of entries) {
35-
if (!entry.isDirectory()) continue;
36-
const candidate = path.join(stagingDir, entry.name);
37-
if (existsSync(path.join(candidate, API_STARTUP_FILE))) {
38-
return candidate;
39-
}
29+
function locateGmatRoot(stagingDir: string, version: GmatVersion): string {
30+
const expectedRoot = path.join(stagingDir, 'GMAT', version);
31+
if (existsSync(path.join(expectedRoot, API_STARTUP_FILE))) {
32+
return expectedRoot;
4033
}
4134
throw new Error(
42-
`Could not locate ${API_STARTUP_FILE} under ${stagingDir}. ` +
43-
`The installer archive layout may have changed.`,
35+
`Expected GMAT/${version}/${API_STARTUP_FILE} inside the installer, ` +
36+
`but ${path.join(expectedRoot, API_STARTUP_FILE)} is missing. ` +
37+
`Did the upstream archive layout change?`,
4438
);
4539
}
4640

src/install.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ async function resolveInstall(inputs: Inputs): Promise<{ gmatRoot: string; cache
3535
const archive = await core.group(`Download GMAT ${inputs.version}`, () =>
3636
download(inputs.version),
3737
);
38-
const gmatRoot = await core.group('Extract GMAT installer', () => extract(archive));
38+
const gmatRoot = await core.group('Extract GMAT installer', () =>
39+
extract(archive, inputs.version),
40+
);
3941

4042
if (inputs.cache) {
4143
await core.group('Save GMAT cache', () => saveCache(inputs.version, gmatRoot));

0 commit comments

Comments
 (0)