Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Run tests on PRs

on:
pull_request:
types: [opened, synchronize]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up everything
uses: ./.github/workflows/set-up-everything

# Yarn constraints are kinda like tests.
- name: Check Yarn constraints
run: yarn constraints
# TODO: Maybe write up a job summary per https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary

- name: Run tests
run: yarn test
# TODO: Annotations of test files that fail?
# TODO: Maybe write up a job summary per https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary
6 changes: 3 additions & 3 deletions workspaces/adventure-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
"@code-chronicles/eslint-config": "workspace:*",
"@code-chronicles/util": "workspace:*",
"@jest/globals": "29.7.0",
"@types/node": "22.7.0",
"@types/react": "18.3.9",
"@types/node": "22.7.4",
"@types/react": "18.3.10",
"@types/react-dom": "18.3.0",
"@types/react-syntax-highlighter": "15.5.13",
"cross-env": "7.0.3",
Expand All @@ -84,7 +84,7 @@
"tsx": "4.19.1",
"type-fest": "4.26.1",
"typescript": "5.6.2",
"webpack": "5.94.0",
"webpack": "5.95.0",
"webpack-cli": "5.1.4",
"zod": "3.23.8"
}
Expand Down
4 changes: 2 additions & 2 deletions workspaces/chrome-extension-hello-world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
},
"devDependencies": {
"@code-chronicles/eslint-config": "workspace:*",
"@types/node": "22.7.0",
"@types/node": "22.7.4",
"cross-env": "7.0.3",
"prettier": "3.3.3",
"ts-loader": "9.5.1",
"tsx": "4.19.1",
"typescript": "5.6.2",
"webpack": "5.94.0",
"webpack": "5.95.0",
"webpack-cli": "5.1.4"
}
}
4 changes: 2 additions & 2 deletions workspaces/download-leetcode-submissions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
},
"devDependencies": {
"@code-chronicles/eslint-config": "workspace:*",
"@types/node": "22.7.0",
"@types/node": "22.7.4",
"cross-env": "7.0.3",
"eslint": "9.11.1",
"prettier": "3.3.3",
"ts-loader": "9.5.1",
"tsx": "4.19.1",
"typescript": "5.6.2",
"webpack": "5.94.0",
"webpack": "5.95.0",
"webpack-cli": "5.1.4"
}
}
4 changes: 2 additions & 2 deletions workspaces/fetch-leetcode-problem-list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
},
"devDependencies": {
"@code-chronicles/eslint-config": "workspace:*",
"@types/node": "22.7.0",
"@types/node": "22.7.4",
"cross-env": "7.0.3",
"eslint": "9.11.1",
"prettier": "3.3.3",
"ts-loader": "9.5.1",
"tsx": "4.19.1",
"typescript": "5.6.2",
"webpack": "5.94.0",
"webpack": "5.95.0",
"webpack-cli": "5.1.4"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
},
"devDependencies": {
"@code-chronicles/eslint-config": "workspace:*",
"@types/node": "22.7.0",
"@types/node": "22.7.4",
"cross-env": "7.0.3",
"eslint": "9.11.1",
"prettier": "3.3.3",
"ts-loader": "9.5.1",
"tsx": "4.19.1",
"typescript": "5.6.2",
"webpack": "5.94.0",
"webpack": "5.95.0",
"webpack-cli": "5.1.4"
}
}
2 changes: 1 addition & 1 deletion workspaces/generate-health-report/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"devDependencies": {
"@code-chronicles/eslint-config": "workspace:*",
"@types/node": "22.7.0",
"@types/node": "22.7.4",
"eslint": "9.11.1",
"prettier": "3.3.3",
"typescript": "5.6.2"
Expand Down
3 changes: 0 additions & 3 deletions workspaces/generate-health-report/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ import { maybeThrow } from "@code-chronicles/util/maybeThrow";
import { spawnWithSafeStdio } from "@code-chronicles/util/spawnWithSafeStdio";

const COMMANDS = [
"yarn constraints",
"yarn test",
"yarn workspace @code-chronicles/adventure-pack build-app",
"yarn workspace @code-chronicles/adventure-pack build-chrome-extension",
"yarn workspace @code-chronicles/chrome-extension-hello-world build",
"yarn workspace @code-chronicles/fetch-leetcode-problem-list build",
"yarn workspace @code-chronicles/fetch-recent-accepted-leetcode-submissions build",
"yarn workspace @code-chronicles/leetcode-api validate-graphql-schema",
"yarn workspace @code-chronicles/leetcode-zen-mode build",
"yarn workspace @code-chronicles/post-leetcode-potd-to-discord build",
];
Expand Down
2 changes: 1 addition & 1 deletion workspaces/javascript-leetcode-month/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@code-chronicles/eslint-config": "workspace:*",
"@code-chronicles/util": "workspace:*",
"@types/mdast": "4.0.4",
"@types/node": "22.7.0",
"@types/node": "22.7.4",
"eslint": "9.11.1",
"mdast": "3.0.0",
"prettier": "3.3.3",
Expand Down
44 changes: 44 additions & 0 deletions workspaces/leetcode-api/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type { Config } from "jest";

const config: Config = {
preset: "ts-jest",
testEnvironment: "node",
};

export default config;

// Hack to make this config runnable as a script, since the combination of
// Jest, ESM, and a TypeScript config has been painful to get working otherwise.
import("node:process").then(async ({ default: process }) => {
if (import.meta.filename !== process.argv[1]) {
return;
}

try {
const { spawnWithSafeStdio } = await import(
"@code-chronicles/util/spawnWithSafeStdio"
);
await spawnWithSafeStdio(
"jest",
["--color", "-c", JSON.stringify(config), ...process.argv.slice(2)],
{
stdio: "inherit",
env: {
...process.env,
NODE_OPTIONS: [
"--experimental-vm-modules",
process.env.NODE_OPTIONS?.trim(),
]
.filter(Boolean)
.join(" "),
},
},
);
} catch (err) {
console.error(
(err as Record<string, unknown> | null | undefined)?.message ?? err,
);
// eslint-disable-next-line require-atomic-updates -- Updating `process.exitCode` on error is logical.
process.exitCode = 1;
}
});
10 changes: 6 additions & 4 deletions workspaces/leetcode-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
"format": "prettier --color --write .",
"lint": "eslint --color --max-warnings=0 .",
"scrape-graphql-schema": "tsx src/scripts/scrape-graphql-schema/main.ts",
"typecheck": "tsc --pretty --project .",
"foo": "tsx src/fetchCommunitySolution.mts",
"validate-graphql-schema": "tsx src/scripts/validate-graphql-schema/main.ts"
"test": "tsx ./jest.config.ts",
"typecheck": "tsc --pretty --project ."
},
"dependencies": {
"@code-chronicles/util": "workspace:*",
Expand All @@ -32,9 +31,12 @@
},
"devDependencies": {
"@code-chronicles/eslint-config": "workspace:*",
"@types/node": "22.7.0",
"@types/node": "22.7.4",
"eslint": "9.11.1",
"graphql": "16.9.0",
"jest": "29.7.0",
"prettier": "3.3.3",
"ts-jest": "29.2.5",
"tsx": "4.19.1",
"typescript": "5.6.2"
}
Expand Down
13 changes: 13 additions & 0 deletions workspaces/leetcode-api/src/__tests__/validSchema-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { readFile } from "node:fs/promises";

import { describe, expect, it } from "@jest/globals";
import { buildSchema, validateSchema } from "graphql";

import { SCHEMA_FILE } from "../scripts/scrape-graphql-schema/constants.ts";

describe("GraphQL schema", () => {
it("validates", async () => {
const schema = buildSchema(await readFile(SCHEMA_FILE, "utf8"));
expect(validateSchema(schema)).toStrictEqual([]);
});
});

This file was deleted.

4 changes: 2 additions & 2 deletions workspaces/leetcode-zen-mode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
},
"devDependencies": {
"@code-chronicles/eslint-config": "workspace:*",
"@types/node": "22.7.0",
"@types/node": "22.7.4",
"cross-env": "7.0.3",
"eslint": "9.11.1",
"prettier": "3.3.3",
"ts-loader": "9.5.1",
"tsx": "4.19.1",
"type-fest": "4.26.1",
"typescript": "5.6.2",
"webpack": "5.94.0",
"webpack": "5.95.0",
"webpack-cli": "5.1.4"
}
}
4 changes: 2 additions & 2 deletions workspaces/post-leetcode-potd-to-discord/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
"devDependencies": {
"@code-chronicles/eslint-config": "workspace:*",
"@types/invariant": "2.2.37",
"@types/node": "22.7.0",
"@types/node": "22.7.4",
"cross-env": "7.0.3",
"eslint": "9.11.1",
"prettier": "3.3.3",
"tsx": "4.19.1",
"typescript": "5.6.2",
"webpack": "5.94.0",
"webpack": "5.95.0",
"webpack-cli": "5.1.4"
}
}
2 changes: 1 addition & 1 deletion workspaces/repository-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"devDependencies": {
"@code-chronicles/eslint-config": "workspace:*",
"@types/node": "22.7.0",
"@types/node": "22.7.4",
"eslint": "9.11.1",
"prettier": "3.3.3",
"type-fest": "4.26.1",
Expand Down
1 change: 0 additions & 1 deletion workspaces/repository-scripts/src/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export const SCRIPTS_TO_SKIP_BY_WORKSPACE: Readonly<
"fetch-recent-accepted-leetcode-submissions": new Set(["test"]),
"generate-health-report": new Set(["test"]),
"javascript-leetcode-month": new Set(["test"]),
"leetcode-api": new Set(["test"]),
"leetcode-zen-mode": new Set(["test"]),
"post-leetcode-potd-to-discord": new Set(["test"]),
"repository-scripts": new Set(["test"]),
Expand Down
2 changes: 1 addition & 1 deletion workspaces/util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@code-chronicles/eslint-config": "workspace:*",
"@code-chronicles/util": "workspace:*",
"@jest/globals": "29.7.0",
"@types/node": "22.7.0",
"@types/node": "22.7.4",
"eslint": "9.11.1",
"jest": "29.7.0",
"prettier": "3.3.3",
Expand Down
Loading
Loading