test: add github check integration
parent
d6dc078d5a
commit
53e2b89833
|
@ -0,0 +1,24 @@
|
|||
name: GitHub Checks Integration
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
checks: write
|
||||
|
||||
jobs:
|
||||
integration:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUN_GITHUB_INTEGRATION_TESTS: true
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: 'yarn'
|
||||
- run: yarn install --frozen-lockfile
|
||||
- run: yarn test cloud-runner-github-checks.integration --detectOpenHandles --forceExit --runInBand
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@ -0,0 +1,38 @@
|
|||
import { BuildParameters } from '../model';
|
||||
import CloudRunner from '../model/cloud-runner/cloud-runner';
|
||||
import UnityVersioning from '../model/unity-versioning';
|
||||
import { Cli } from '../model/cli/cli';
|
||||
import GitHub from '../model/github';
|
||||
import { OptionValues } from 'commander';
|
||||
|
||||
export const TIMEOUT_INFINITE = 1e9;
|
||||
|
||||
async function createParameters(overrides?: OptionValues) {
|
||||
if (overrides) Cli.options = overrides;
|
||||
|
||||
return BuildParameters.create();
|
||||
}
|
||||
|
||||
const runIntegration = process.env.RUN_GITHUB_INTEGRATION_TESTS === 'true';
|
||||
const describeOrSkip = runIntegration ? describe : describe.skip;
|
||||
|
||||
describeOrSkip('Cloud Runner Github Checks Integration', () => {
|
||||
it(
|
||||
'creates and updates a real GitHub check',
|
||||
async () => {
|
||||
const buildParameter = await createParameters({
|
||||
versioning: 'None',
|
||||
projectPath: 'test-project',
|
||||
unityVersion: UnityVersioning.read('test-project'),
|
||||
asyncCloudRunner: `true`,
|
||||
githubChecks: `true`,
|
||||
});
|
||||
await CloudRunner.setup(buildParameter);
|
||||
const checkId = await GitHub.createGitHubCheck(`integration create`);
|
||||
expect(checkId).not.toEqual('');
|
||||
await GitHub.updateGitHubCheck(`1 ${new Date().toISOString()}`, `integration`);
|
||||
await GitHub.updateGitHubCheck(`2 ${new Date().toISOString()}`, `integration`, `success`, `completed`);
|
||||
},
|
||||
TIMEOUT_INFINITE,
|
||||
);
|
||||
});
|
|
@ -6,18 +6,9 @@ import failOnConsole from 'jest-fail-on-console';
|
|||
// implementation, so we provide one using undici's implementation.
|
||||
// This ensures tests that interact with Octokit do not throw when
|
||||
// constructing the client.
|
||||
import { fetch, Headers, Request, Response } from 'undici';
|
||||
import { fetch as undiciFetch, Headers, Request, Response } from 'undici';
|
||||
|
||||
if (!global.fetch) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(global as any).fetch = fetch;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(global as any).Headers = Headers;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(global as any).Request = Request;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(global as any).Response = Response;
|
||||
}
|
||||
Object.assign(globalThis, { fetch: undiciFetch, Headers, Request, Response });
|
||||
|
||||
// Fail when console logs something inside a test - use spyOn instead
|
||||
failOnConsole({
|
||||
|
|
Loading…
Reference in New Issue