Skip to content

Scheduling infrastructure for absolutely everyone.

if you touch it you fix it (#967)

Alex Johanssona67813ee773a
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index b5b040de22f..e75c52cf706 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -44,3 +44,28 @@ jobs:
- run: yarn prisma migrate deploy
- run: yarn test
- run: yarn build
+
+ types:
+ name: Check types
+
+ strategy:
+ matrix:
+ node: ["14.x"]
+ os: [ubuntu-latest]
+ runs-on: ${{ matrix.os }}
+
+ steps:
+ - name: Checkout repo
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+
+ - name: Use Node ${{ matrix.node }}
+ uses: actions/setup-node@v1
+ with:
+ node-version: ${{ matrix.node }}
+
+ - name: Install deps
+ uses: bahmutov/npm-install@v1
+
+ - run: yarn check-changed-files
diff --git a/package.json b/package.json
index 4f1ae066f69..f54af3edb5d 100644
--- a/package.json
+++ b/package.json
@@ -22,7 +22,8 @@
"postinstall": "prisma generate",
"pre-commit": "lint-staged",
"lint": "eslint . --ext .ts,.js,.tsx,.jsx",
- "prepare": "husky install"
+ "prepare": "husky install",
+ "check-changed-files": "yarn ts-node scripts/ts-check-changed-files.ts"
},
"engines": {
"node": "14.x",
diff --git a/scripts/ts-check-changed-files.ts b/scripts/ts-check-changed-files.ts
new file mode 100644
index 00000000000..6612bb503d8
--- /dev/null
+++ b/scripts/ts-check-changed-files.ts
@@ -0,0 +1,37 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
+import { execSync } from "child_process";
+
+const diff = execSync(`git diff --name-only origin/main HEAD`).toString();
+
+const files = diff.trim().split("\n");
+
+console.log("ℹ️ Changed files:");
+console.log(
+ files
+ .filter(Boolean)
+ .map((str) => ` - ${str}`)
+ .join("\n")
+);
+
+try {
+ console.log("⏳ Checking type errors..");
+ execSync("yarn tsc --noEmit", {});
+
+ console.log("😻 No errors!");
+} catch (_err) {
+ const err = _err as any;
+
+ const output = err.stdout.toString() as string;
+
+ const filesWithTypeErrors = files.filter((file) => output.includes(file));
+
+ if (!filesWithTypeErrors.length) {
+ console.log(`🎉 You haven't introduced any new type errors!`);
+ process.exit(0);
+ }
+ console.log("❌ ❌ ❌ You seem to have touched files that have type errors ❌ ❌ ❌");
+ console.log("🙏 Please inspect the following files:");
+ console.log(filesWithTypeErrors.map((str) => ` - ${str}`).join("\n"));
+
+ process.exit(1);
+}