Skip to content

Commit 03d3bd8

Browse files
committed
Run tests outside the project
1 parent 0e7c7ff commit 03d3bd8

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/constants.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
import path from "path";
22
import { context } from "@actions/github";
3+
import packageJson from "../package.json" with { type: "json" };
34

4-
const cwd = process.cwd();
5+
const PROJECT_ROOT = path.join(import.meta.dirname, "../");
6+
const IS_CI = Boolean(process.env.CI);
7+
// Create files outside the project to avoid slowing down the editor
8+
const WORKING_DIRECTORY = IS_CI
9+
? PROJECT_ROOT
10+
: path.join(PROJECT_ROOT, `../${packageJson.name}-working-directory/`);
511

612
console.log(context);
713

814
export const IS_TRIGGERED_BY_GITHUB_ISSUE_COMMENT = Boolean(
915
context.eventName === "issue_comment",
1016
);
11-
export const temporaryDirectory = path.join(cwd, "./running");
12-
export const repositoriesDirectory = path.join(cwd, "./repositories");
13-
export const reportsDirectory = path.join(cwd, "./reports");
17+
export const temporaryDirectory = path.join(WORKING_DIRECTORY, "./running/");
18+
export const repositoriesDirectory = path.join(
19+
WORKING_DIRECTORY,
20+
"./repositories/",
21+
);
22+
export const reportsDirectory = path.join(PROJECT_ROOT, "./reports/");
1423
export const MAXIMUM_GITHUB_COMMENT_LENGTH = 65536;
1524
export const GITHUB_ACTION_RUN_URL = IS_TRIGGERED_BY_GITHUB_ISSUE_COMMENT
1625
? `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`

src/install-prettier.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export async function installPrettier(
2828

2929
await spawn("yarn", ["init", "-y"], { cwd: directory });
3030
await writeFile(path.join(directory, "yarn.lock"), "");
31+
await spawn("yarn", ["config", "set", "nodeLinker", "node-modules"], {
32+
cwd: directory,
33+
});
3134
await spawn("yarn", ["add", packageToInstall], { cwd: directory });
3235

3336
const prettierBinary = path.join(

0 commit comments

Comments
 (0)