This commit is contained in:
Frostebite 2025-06-11 15:56:27 +01:00
parent b662a6fa0e
commit 92eaa73a2d
8 changed files with 29 additions and 14 deletions

View File

@ -77,5 +77,13 @@
"unicorn/prefer-spread": "off", "unicorn/prefer-spread": "off",
// Temp disable to prevent mixing changes with other PRs // Temp disable to prevent mixing changes with other PRs
"i18n-text/no-en": "off" "i18n-text/no-en": "off"
},
"overrides": [
{
"files": ["jest.setup.js"],
"rules": {
"import/no-commonjs": "off"
} }
}
]
} }

BIN
dist/index.js generated vendored

Binary file not shown.

BIN
dist/index.js.map generated vendored

Binary file not shown.

View File

@ -25,6 +25,6 @@ module.exports = {
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
modulePathIgnorePatterns: ['<rootDir>/lib/', '<rootDir>/dist/'], modulePathIgnorePatterns: ['<rootDir>/lib/', '<rootDir>/dist/'],
// A list of paths to modules that run some code to configure or set up the testing framework before each test // Use jest.setup.js to polyfill fetch for all tests
setupFilesAfterEnv: ['<rootDir>/src/jest.setup.ts'], setupFiles: ['<rootDir>/jest.setup.js'],
}; };

2
jest.setup.js Normal file
View File

@ -0,0 +1,2 @@
const fetch = require('node-fetch');
global.fetch = fetch;

View File

@ -74,6 +74,7 @@
"jest-fail-on-console": "^3.0.2", "jest-fail-on-console": "^3.0.2",
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
"lefthook": "^1.6.1", "lefthook": "^1.6.1",
"node-fetch": "2",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"ts-jest": "^27.1.3", "ts-jest": "^27.1.3",
"ts-node": "10.8.1", "ts-node": "10.8.1",

View File

@ -3,6 +3,7 @@ import CloudRunner from './cloud-runner/cloud-runner';
import CloudRunnerOptions from './cloud-runner/options/cloud-runner-options'; import CloudRunnerOptions from './cloud-runner/options/cloud-runner-options';
import * as core from '@actions/core'; import * as core from '@actions/core';
import { Octokit } from '@octokit/core'; import { Octokit } from '@octokit/core';
import fetch from 'node-fetch';
class GitHub { class GitHub {
private static readonly asyncChecksApiWorkflowName = `Async Checks API`; private static readonly asyncChecksApiWorkflowName = `Async Checks API`;
@ -15,11 +16,13 @@ class GitHub {
private static get octokitDefaultToken() { private static get octokitDefaultToken() {
return new Octokit({ return new Octokit({
auth: process.env.GITHUB_TOKEN, auth: process.env.GITHUB_TOKEN,
request: { fetch },
}); });
} }
private static get octokitPAT() { private static get octokitPAT() {
return new Octokit({ return new Octokit({
auth: CloudRunner.buildParameters.gitPrivateToken, auth: CloudRunner.buildParameters.gitPrivateToken,
request: { fetch },
}); });
} }
private static get sha() { private static get sha() {
@ -163,11 +166,10 @@ class GitHub {
core.info(JSON.stringify(workflows)); core.info(JSON.stringify(workflows));
throw new Error(`no workflow with name "${GitHub.asyncChecksApiWorkflowName}"`); throw new Error(`no workflow with name "${GitHub.asyncChecksApiWorkflowName}"`);
} }
await GitHub.octokitPAT.request(`POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches`, { await GitHub.octokitPAT.request(`POST /repos/{owner}/{repo}/actions/workflows/{workflowId}/dispatches`, {
owner: GitHub.owner, owner: GitHub.owner,
repo: GitHub.repo, repo: GitHub.repo,
// eslint-disable-next-line camelcase workflowId: selectedId,
workflow_id: selectedId,
ref: CloudRunnerOptions.branch, ref: CloudRunnerOptions.branch,
inputs: { inputs: {
checksObject: JSON.stringify({ data, mode }), checksObject: JSON.stringify({ data, mode }),
@ -198,11 +200,10 @@ class GitHub {
core.info(JSON.stringify(workflows)); core.info(JSON.stringify(workflows));
throw new Error(`no workflow with name "${GitHub.asyncChecksApiWorkflowName}"`); throw new Error(`no workflow with name "${GitHub.asyncChecksApiWorkflowName}"`);
} }
await GitHub.octokitPAT.request(`POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches`, { await GitHub.octokitPAT.request(`POST /repos/{owner}/{repo}/actions/workflows/{workflowId}/dispatches`, {
owner: GitHub.owner, owner: GitHub.owner,
repo: GitHub.repo, repo: GitHub.repo,
// eslint-disable-next-line camelcase workflowId: selectedId,
workflow_id: selectedId,
ref: CloudRunnerOptions.branch, ref: CloudRunnerOptions.branch,
inputs: { inputs: {
buildGuid: CloudRunner.buildParameters.buildGuid, buildGuid: CloudRunner.buildParameters.buildGuid,
@ -213,10 +214,6 @@ class GitHub {
core.info(`github workflow complete hook not found`); core.info(`github workflow complete hook not found`);
} }
} }
public static async getCheckStatus() {
return await GitHub.octokitDefaultToken.request(`GET /repos/{owner}/{repo}/check-runs/{check_run_id}`);
}
} }
export default GitHub; export default GitHub;

View File

@ -6242,6 +6242,13 @@ no-case@^3.0.4:
lower-case "^2.0.2" lower-case "^2.0.2"
tslib "^2.0.3" tslib "^2.0.3"
node-fetch@2:
version "2.7.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d"
integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==
dependencies:
whatwg-url "^5.0.0"
node-fetch@^2.6.7: node-fetch@^2.6.7:
version "2.6.12" version "2.6.12"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.12.tgz#02eb8e22074018e3d5a83016649d04df0e348fba" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.12.tgz#02eb8e22074018e3d5a83016649d04df0e348fba"