Skip to content

Commit 0e3f6e0

Browse files
Update test suite to work properly
1 parent aee83a8 commit 0e3f6e0

12 files changed

Lines changed: 735 additions & 684 deletions

eslint.config.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,53 @@
1-
import { defineConfig } from "eslint/config";
2-
import jest from "eslint-plugin-jest";
3-
import typescriptEslint from "@typescript-eslint/eslint-plugin";
4-
import globals from "globals";
5-
import tsParser from "@typescript-eslint/parser";
6-
import path from "node:path";
7-
import { fileURLToPath } from "node:url";
8-
import js from "@eslint/js";
9-
import { FlatCompat } from "@eslint/eslintrc";
1+
import { defineConfig } from 'eslint/config';
2+
import jest from 'eslint-plugin-jest';
3+
import typescriptEslint from '@typescript-eslint/eslint-plugin';
4+
import globals from 'globals';
5+
import tsParser from '@typescript-eslint/parser';
6+
import path from 'node:path';
7+
import { fileURLToPath } from 'node:url';
8+
import js from '@eslint/js';
9+
import { FlatCompat } from '@eslint/eslintrc';
1010

1111
const __filename = fileURLToPath(import.meta.url);
1212
const __dirname = path.dirname(__filename);
1313
const compat = new FlatCompat({
14-
baseDirectory: __dirname,
15-
recommendedConfig: js.configs.recommended,
16-
allConfig: js.configs.all
14+
baseDirectory: __dirname,
15+
recommendedConfig: js.configs.recommended,
16+
allConfig: js.configs.all,
1717
});
1818

19-
export default defineConfig([{
19+
export default defineConfig([
20+
{
2021
extends: compat.extends(
21-
"plugin:prettier/recommended",
22-
"plugin:@typescript-eslint/eslint-recommended",
23-
"plugin:@typescript-eslint/recommended",
22+
'plugin:prettier/recommended',
23+
'plugin:@typescript-eslint/eslint-recommended',
24+
'plugin:@typescript-eslint/recommended',
2425
),
2526

2627
plugins: {
27-
jest,
28-
"@typescript-eslint": typescriptEslint,
28+
jest,
29+
'@typescript-eslint': typescriptEslint,
2930
},
3031

3132
languageOptions: {
32-
globals: {
33-
...globals.node,
34-
...jest.environments.globals.globals,
35-
},
33+
globals: {
34+
...globals.node,
35+
...jest.environments.globals.globals,
36+
},
3637

37-
parser: tsParser,
38-
ecmaVersion: 2020,
39-
sourceType: "module",
38+
parser: tsParser,
39+
ecmaVersion: 2020,
40+
sourceType: 'module',
4041
},
4142

4243
rules: {
43-
"no-console": "error",
44-
"no-plusplus": "off",
45-
"no-await-in-loop": "off",
46-
"no-constant-condition": "off",
47-
"no-restricted-syntax": "off",
48-
"@typescript-eslint/ban-ts-comment": "off",
49-
"@typescript-eslint/no-explicit-any": "off",
44+
'no-console': 'error',
45+
'no-plusplus': 'off',
46+
'no-await-in-loop': 'off',
47+
'no-constant-condition': 'off',
48+
'no-restricted-syntax': 'off',
49+
'@typescript-eslint/ban-ts-comment': 'off',
50+
'@typescript-eslint/no-explicit-any': 'off',
5051
},
51-
}]);
52+
},
53+
]);

jest.config.js

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
module.exports = {
2-
"clearMocks": true,
3-
"collectCoverage": true,
4-
"coverageDirectory": "coverage",
5-
"coverageProvider": "v8",
6-
"preset": "ts-jest",
7-
"setupFiles": [
8-
"<rootDir>/test/config.ts"
9-
],
10-
"testEnvironment": "node",
11-
"transform": {
12-
".(ts|tsx)": [
13-
"ts-jest",
14-
{
15-
tsconfig: "tsconfig.tests.json",
16-
compiler: "ttypescript",
17-
}
18-
]
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
setupFiles: ['<rootDir>/test/config.ts'],
5+
clearMocks: true,
6+
collectCoverage: true,
7+
coverageDirectory: 'coverage',
8+
coverageProvider: 'v8',
9+
globals: {
10+
'ts-jest': {
11+
tsconfig: '<rootDir>/tsconfig.tests.json',
12+
},
1913
},
20-
}
14+
};

package.json

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,28 @@
2424
"@octokit/webhooks-types": "^7.6.1",
2525
"@types/node": "^22.15.21",
2626
"@vercel/ncc": "^0.38.3",
27-
"ttypescript": "^1.5.15",
28-
"typescript": "^5.8.3"
27+
"ts-node": "^10.9.2"
2928
},
3029
"devDependencies": {
31-
"@types/jest": "^29.5.0",
30+
"@types/jest": "28",
3231
"@typescript-eslint/eslint-plugin": "^8.32.1",
3332
"@typescript-eslint/parser": "^8.32.1",
3433
"eslint": "^9.27.0",
3534
"eslint-config-prettier": "^10.1.5",
3635
"eslint-plugin-import": "^2.27.5",
3736
"eslint-plugin-jest": "^28.11.0",
3837
"eslint-plugin-prettier": "^5.4.0",
39-
"jest": "^29.5.0",
40-
"jest-ts-auto-mock": "^2.1.0",
41-
"nock": "^14.0.4",
38+
"jest": "28",
39+
"jest-ts-auto-mock": "2",
40+
"nock": "15.0.0-beta.1",
4241
"prettier": "^3.5.3",
43-
"ts-auto-mock": "^3.6.4",
44-
"ts-jest": "^29.0.5"
42+
"ts-auto-mock": "3",
43+
"ts-jest": "28",
44+
"ttypescript": "^1.5.15",
45+
"typescript": "4.9.5"
46+
},
47+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
48+
"resolutions": {
49+
"glob": "^9.0.0"
4550
}
4651
}

src/autoupdater.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ export class AutoUpdater {
5454

5555
ghCore.info(`Handling pull_request event triggered by action '${action}'`);
5656

57+
if (!pull_request.head.repo) {
58+
ghCore.error('Pull request head repo is null, skipping update.');
59+
return false;
60+
}
61+
5762
const isUpdated = await this.update(
5863
pull_request.head.repo.owner.login,
5964
pull_request,

src/config-loader.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ export class ConfigLoader {
3939

4040
mergeMsg(): string {
4141
const msg = this.getValue('MERGE_MSG', false, '').toString().trim();
42-
return msg === '' ? null : msg;
42+
return msg;
4343
}
4444

4545
conflictMsg(): string {
4646
const msg = this.getValue('CONFLICT_MSG', false, '').toString().trim();
47-
return msg === '' ? null : msg;
47+
return msg;
4848
}
4949

5050
retryCount(): number {
@@ -73,7 +73,6 @@ export class ConfigLoader {
7373
return this.getValue('PR_READY_STATE', false, 'all');
7474
}
7575

76-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
7776
getValue(key: string, required = false, defaultVal?: any): any {
7877
if (
7978
key in this.env &&

0 commit comments

Comments
 (0)