Skip to content

Commit df5e5e8

Browse files
committed
update
1 parent 8a16313 commit df5e5e8

File tree

2 files changed

+41
-13
lines changed

2 files changed

+41
-13
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25610,7 +25610,7 @@ function parseBool(input, flag) {
2561025610
}
2561125611
async function downloadRelease(owner, repo, version, bin) {
2561225612
// Get the GitHub token from the environment
25613-
const token = process.env.GITHUB_TOKEN;
25613+
const token = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput("github-token");
2561425614
if (!token) {
2561525615
throw new Error("GITHUB_TOKEN is not set. Please ensure the job has the necessary permissions.");
2561625616
}

tests/arguments.test.ts

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,24 @@ const createEchoCli = async (tmpdir: string) => {
1717
);
1818
};
1919

20-
// This is a sanity check test that validates the CLI is called correctly.
21-
// TODO(Tyler) that we may want to have these tests in python instead for simplicity
22-
test("Forwards inputs", async () => {
20+
test("Forwards inputs - upload", async () => {
2321
const tmpdir = await fs.mkdtemp(
2422
path.resolve(os.tmpdir(), "trunk-analytics-uploader-test-"),
2523
);
2624
await createEchoCli(tmpdir);
2725

28-
const env = {
26+
const env: Record<string, string> = {
2927
"INPUT_JUNIT-PATHS": "junit.xml",
3028
"INPUT_ORG-SLUG": "org",
3129
INPUT_TOKEN: "token",
32-
"INPUT_REPO-HEAD-BRANCH": "",
33-
"INPUT_REPO-ROOT": "",
3430
"INPUT_CLI-VERSION": "0.0.0",
35-
INPUT_TEAM: "",
36-
INPUT_QUARANTINE: "",
37-
"INPUT_XCRESULT-PATH": "",
38-
"INPUT_ALLOW-MISSING-JUNIT-FILES": "",
39-
"INPUT_BAZEL-BEP-PATH": "",
40-
"INPUT_HIDE-BANNER": "",
4131
};
4232

4333
const scriptPath = path.resolve(repoRoot, "dist/index.js");
4434
let stdout = "";
4535
let stderr = "";
4636
let exit_code: number;
37+
console.log(process.env);
4738
try {
4839
({ stdout, stderr } = await execPromise(`node ${scriptPath}`, {
4940
env: { ...process.env, ...env },
@@ -62,3 +53,40 @@ test("Forwards inputs", async () => {
6253
expect(exit_code).toBe(0);
6354
await fs.rm(tmpdir, { recursive: true, force: true });
6455
});
56+
57+
test("Forwards inputs - test", async () => {
58+
const tmpdir = await fs.mkdtemp(
59+
path.resolve(os.tmpdir(), "trunk-analytics-uploader-test-"),
60+
);
61+
await createEchoCli(tmpdir);
62+
63+
const env = {
64+
"INPUT_JUNIT-PATHS": "junit.xml",
65+
"INPUT_ORG-SLUG": "org",
66+
INPUT_TOKEN: "token",
67+
"INPUT_CLI-VERSION": "0.0.0",
68+
INPUT_RUN: "exit 0",
69+
};
70+
71+
const scriptPath = path.resolve(repoRoot, "dist/index.js");
72+
let stdout = "";
73+
let stderr = "";
74+
let exit_code: number;
75+
try {
76+
({ stdout, stderr } = await execPromise(`node ${scriptPath}`, {
77+
env: { ...process.env, ...env },
78+
cwd: tmpdir,
79+
}));
80+
exit_code = 0;
81+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
82+
} catch (err: any) {
83+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */
84+
({ stdout, stderr, code: exit_code } = err);
85+
}
86+
expect(stdout).toMatch(
87+
"test --junit-paths junit.xml --org-url-slug org --token token --repo-root . -- exit 0",
88+
);
89+
expect(stderr).toMatch("");
90+
expect(exit_code).toBe(0);
91+
await fs.rm(tmpdir, { recursive: true, force: true });
92+
});

0 commit comments

Comments
 (0)