Skip to content

Commit 92eaa73

Browse files
committed
fix
1 parent b662a6f commit 92eaa73

File tree

8 files changed

+24991
-23183
lines changed

8 files changed

+24991
-23183
lines changed

.eslintrc.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,13 @@
7777
"unicorn/prefer-spread": "off",
7878
// Temp disable to prevent mixing changes with other PRs
7979
"i18n-text/no-en": "off"
80-
}
80+
},
81+
"overrides": [
82+
{
83+
"files": ["jest.setup.js"],
84+
"rules": {
85+
"import/no-commonjs": "off"
86+
}
87+
}
88+
]
8189
}

dist/index.js

Lines changed: 24961 additions & 23168 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ module.exports = {
2525
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
2626
modulePathIgnorePatterns: ['<rootDir>/lib/', '<rootDir>/dist/'],
2727

28-
// A list of paths to modules that run some code to configure or set up the testing framework before each test
29-
setupFilesAfterEnv: ['<rootDir>/src/jest.setup.ts'],
28+
// Use jest.setup.js to polyfill fetch for all tests
29+
setupFiles: ['<rootDir>/jest.setup.js'],
3030
};

jest.setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const fetch = require('node-fetch');
2+
global.fetch = fetch;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"jest-fail-on-console": "^3.0.2",
7575
"js-yaml": "^4.1.0",
7676
"lefthook": "^1.6.1",
77+
"node-fetch": "2",
7778
"prettier": "^2.5.1",
7879
"ts-jest": "^27.1.3",
7980
"ts-node": "10.8.1",
@@ -84,4 +85,4 @@
8485
"node": "20.5.1",
8586
"yarn": "1.22.19"
8687
}
87-
}
88+
}

src/model/github.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import CloudRunner from './cloud-runner/cloud-runner';
33
import CloudRunnerOptions from './cloud-runner/options/cloud-runner-options';
44
import * as core from '@actions/core';
55
import { Octokit } from '@octokit/core';
6+
import fetch from 'node-fetch';
67

78
class GitHub {
89
private static readonly asyncChecksApiWorkflowName = `Async Checks API`;
@@ -15,11 +16,13 @@ class GitHub {
1516
private static get octokitDefaultToken() {
1617
return new Octokit({
1718
auth: process.env.GITHUB_TOKEN,
19+
request: { fetch },
1820
});
1921
}
2022
private static get octokitPAT() {
2123
return new Octokit({
2224
auth: CloudRunner.buildParameters.gitPrivateToken,
25+
request: { fetch },
2326
});
2427
}
2528
private static get sha() {
@@ -163,11 +166,10 @@ class GitHub {
163166
core.info(JSON.stringify(workflows));
164167
throw new Error(`no workflow with name "${GitHub.asyncChecksApiWorkflowName}"`);
165168
}
166-
await GitHub.octokitPAT.request(`POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches`, {
169+
await GitHub.octokitPAT.request(`POST /repos/{owner}/{repo}/actions/workflows/{workflowId}/dispatches`, {
167170
owner: GitHub.owner,
168171
repo: GitHub.repo,
169-
// eslint-disable-next-line camelcase
170-
workflow_id: selectedId,
172+
workflowId: selectedId,
171173
ref: CloudRunnerOptions.branch,
172174
inputs: {
173175
checksObject: JSON.stringify({ data, mode }),
@@ -198,11 +200,10 @@ class GitHub {
198200
core.info(JSON.stringify(workflows));
199201
throw new Error(`no workflow with name "${GitHub.asyncChecksApiWorkflowName}"`);
200202
}
201-
await GitHub.octokitPAT.request(`POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches`, {
203+
await GitHub.octokitPAT.request(`POST /repos/{owner}/{repo}/actions/workflows/{workflowId}/dispatches`, {
202204
owner: GitHub.owner,
203205
repo: GitHub.repo,
204-
// eslint-disable-next-line camelcase
205-
workflow_id: selectedId,
206+
workflowId: selectedId,
206207
ref: CloudRunnerOptions.branch,
207208
inputs: {
208209
buildGuid: CloudRunner.buildParameters.buildGuid,
@@ -213,10 +214,6 @@ class GitHub {
213214
core.info(`github workflow complete hook not found`);
214215
}
215216
}
216-
217-
public static async getCheckStatus() {
218-
return await GitHub.octokitDefaultToken.request(`GET /repos/{owner}/{repo}/check-runs/{check_run_id}`);
219-
}
220217
}
221218

222219
export default GitHub;

yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6242,6 +6242,13 @@ no-case@^3.0.4:
62426242
lower-case "^2.0.2"
62436243
tslib "^2.0.3"
62446244

6245+
node-fetch@2:
6246+
version "2.7.0"
6247+
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d"
6248+
integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==
6249+
dependencies:
6250+
whatwg-url "^5.0.0"
6251+
62456252
node-fetch@^2.6.7:
62466253
version "2.6.12"
62476254
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.12.tgz#02eb8e22074018e3d5a83016649d04df0e348fba"

0 commit comments

Comments
 (0)