This commit is contained in:
Frostebite 2023-03-30 22:34:17 +01:00
parent 3032a4ab97
commit e580beeabe
10 changed files with 77 additions and 12 deletions

View File

@ -8,7 +8,7 @@
- [x] Read the contribution [guide](https://github.com/game-ci/unity-builder/blob/main/CONTRIBUTING.md) and accept the - [x] Read the contribution [guide](https://github.com/game-ci/unity-builder/blob/main/CONTRIBUTING.md) and accept the
[code](https://github.com/game-ci/unity-builder/blob/main/CODE_OF_CONDUCT.md) of conduct [code](https://github.com/game-ci/unity-builder/blob/main/CODE_OF_CONDUCT.md) of conduct
- [ ] Docs (If new inputs or outputs have been added or changes to behavior that should be documented. Please make - [ ] Docs (If new inputs or outputs have been added or changes to behavior that should be documented. Please make a PR
a PR in the [documentation repo](https://github.com/game-ci/documentation)) in the [documentation repo](https://github.com/game-ci/documentation))
- [ ] Readme (updated or not needed) - [ ] Readme (updated or not needed)
- [ ] Tests (added, updated or not needed) - [ ] Tests (added, updated or not needed)

View File

@ -37,6 +37,9 @@ jobs:
name: Smoke Tests name: Smoke Tests
if: github.event.event_type != 'pull_request_target' if: github.event.event_type != 'pull_request_target'
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -111,6 +114,7 @@ jobs:
- 'cloud-runner-environment' - 'cloud-runner-environment'
#- 'cloud-runner-hooks' #- 'cloud-runner-hooks'
- 'cloud-runner-s3-steps' - 'cloud-runner-s3-steps'
- 'cloud-runner-github-checks'
#- 'cloud-runner-local-persistence' #- 'cloud-runner-local-persistence'
#- 'cloud-runner-locking-core' #- 'cloud-runner-locking-core'
#- 'cloud-runner-locking-get-locked' #- 'cloud-runner-locking-get-locked'

BIN
dist/index.js generated vendored

Binary file not shown.

BIN
dist/index.js.map generated vendored

Binary file not shown.

View File

@ -114,11 +114,7 @@ class CloudRunner {
CloudRunner.lockedWorkspace = ``; CloudRunner.lockedWorkspace = ``;
} }
} }
const content = { ...CloudRunner.buildParameters }; await CloudRunner.updateStatusWithBuildParameters();
content.gitPrivateToken = ``;
content.unitySerial = ``;
const jsonContent = JSON.stringify(content, undefined, 4);
await GitHub.updateGitHubCheck(jsonContent, CloudRunner.buildParameters.buildGuid);
const output = await new WorkflowCompositionRoot().run( const output = await new WorkflowCompositionRoot().run(
new CloudRunnerStepParameters( new CloudRunnerStepParameters(
baseImage, baseImage,
@ -135,7 +131,9 @@ class CloudRunner {
); );
CloudRunnerLogger.log(`Cleanup complete`); CloudRunnerLogger.log(`Cleanup complete`);
if (!CloudRunner.buildParameters.isCliMode) core.endGroup(); if (!CloudRunner.buildParameters.isCliMode) core.endGroup();
if ((buildParameters.asyncWorkflow && this.isCloudRunnerEnvironment) || !buildParameters.asyncWorkflow) {
await GitHub.updateGitHubCheck(CloudRunner.buildParameters.buildGuid, `success`, `success`, `completed`); await GitHub.updateGitHubCheck(CloudRunner.buildParameters.buildGuid, `success`, `success`, `completed`);
}
if (BuildParameters.shouldUseRetainedWorkspaceMode(buildParameters)) { if (BuildParameters.shouldUseRetainedWorkspaceMode(buildParameters)) {
const workspace = CloudRunner.lockedWorkspace || ``; const workspace = CloudRunner.lockedWorkspace || ``;
@ -176,5 +174,15 @@ class CloudRunner {
throw error; throw error;
} }
} }
private static async updateStatusWithBuildParameters() {
const content = { ...CloudRunner.buildParameters };
content.gitPrivateToken = ``;
content.unitySerial = ``;
content.unityEmail = ``;
content.unityPassword = ``;
const jsonContent = JSON.stringify(content, undefined, 4);
await GitHub.updateGitHubCheck(jsonContent, CloudRunner.buildParameters.buildGuid);
}
} }
export default CloudRunner; export default CloudRunner;

View File

@ -92,8 +92,6 @@ class KubernetesJobSpecFactory {
preStop: { preStop: {
exec: { exec: {
command: [ command: [
'bin/bash',
'-c',
`cd /data/builder/action/steps; `cd /data/builder/action/steps;
chmod +x /return_license.sh; chmod +x /return_license.sh;
/return_license.sh;`, /return_license.sh;`,

View File

@ -20,6 +20,7 @@ export class RemoteClient {
if (!(await RemoteClient.handleRetainedWorkspace())) { if (!(await RemoteClient.handleRetainedWorkspace())) {
await RemoteClient.bootstrapRepository(); await RemoteClient.bootstrapRepository();
} }
await RemoteClient.replaceLargePackageReferencesWithSharedReferences();
await RemoteClient.runCustomHookFiles(`before-build`); await RemoteClient.runCustomHookFiles(`before-build`);
} }
static async runCustomHookFiles(hookLifecycle: string) { static async runCustomHookFiles(hookLifecycle: string) {
@ -47,7 +48,6 @@ export class RemoteClient {
`mkdir -p ${CloudRunnerFolders.ToLinuxFolder(CloudRunnerFolders.cacheFolderForCacheKeyFull)}`, `mkdir -p ${CloudRunnerFolders.ToLinuxFolder(CloudRunnerFolders.cacheFolderForCacheKeyFull)}`,
); );
await RemoteClient.cloneRepoWithoutLFSFiles(); await RemoteClient.cloneRepoWithoutLFSFiles();
await RemoteClient.replaceLargePackageReferencesWithSharedReferences();
await RemoteClient.sizeOfFolder( await RemoteClient.sizeOfFolder(
'repo before lfs cache pull', 'repo before lfs cache pull',
CloudRunnerFolders.ToLinuxFolder(CloudRunnerFolders.repoPathAbsolute), CloudRunnerFolders.ToLinuxFolder(CloudRunnerFolders.repoPathAbsolute),

View File

@ -0,0 +1,49 @@
import { BuildParameters } from '../..';
import CloudRunner from '../cloud-runner';
import UnityVersioning from '../../unity-versioning';
import { Cli } from '../../cli/cli';
import CloudRunnerOptions from '../options/cloud-runner-options';
import setups from './cloud-runner-suite.test';
import { OptionValues } from 'commander';
import GitHub from '../../github';
async function CreateParameters(overrides: OptionValues | undefined) {
if (overrides) Cli.options = overrides;
return BuildParameters.create();
}
describe('Cloud Runner Github Checks', () => {
setups();
it('Responds', () => {});
if (CloudRunnerOptions.cloudRunnerDebug && CloudRunnerOptions.providerStrategy === `local-docker`) {
it('Check Handling Direct', async () => {
// Setup parameters
const buildParameter = await CreateParameters({
versioning: 'None',
projectPath: 'test-project',
unityVersion: UnityVersioning.read('test-project'),
asyncCloudRunner: `true`,
githubChecks: `true`,
});
await CloudRunner.setup(buildParameter);
CloudRunner.buildParameters.githubCheckId = await GitHub.createGitHubCheck(`t`);
await GitHub.updateGitHubCheck(`t`, `t2`);
}, 1_000_000_000);
it('Check Handling Via Async Workflow', async () => {
// Setup parameters
const buildParameter = await CreateParameters({
versioning: 'None',
projectPath: 'test-project',
unityVersion: UnityVersioning.read('test-project'),
asyncCloudRunner: `true`,
githubChecks: `true`,
});
GitHub.asyncWorkflows = true;
await CloudRunner.setup(buildParameter);
CloudRunner.buildParameters.githubCheckId = await GitHub.createGitHubCheck(`t`);
await GitHub.updateGitHubCheck(`t`, `t2`);
GitHub.asyncWorkflows = false;
}, 1_000_000_000);
}
});

View File

@ -41,6 +41,11 @@ node /builder/dist/index.js -m async-workflow`,
[ [
...secrets, ...secrets,
...[ ...[
{
ParameterKey: `GITHUB_TOKEN`,
EnvironmentVariable: `GITHUB_TOKEN`,
ParameterValue: process.env.GITHUB_TOKEN || ``,
},
{ {
ParameterKey: `AWS_ACCESS_KEY_ID`, ParameterKey: `AWS_ACCESS_KEY_ID`,
EnvironmentVariable: `AWS_ACCESS_KEY_ID`, EnvironmentVariable: `AWS_ACCESS_KEY_ID`,

View File

@ -11,6 +11,7 @@ class GitHub {
private static startedDate: string; private static startedDate: string;
private static endedDate: string; private static endedDate: string;
static result: string = ``; static result: string = ``;
static asyncWorkflows: boolean;
private static get octokitDefaultToken() { private static get octokitDefaultToken() {
return new Octokit({ return new Octokit({
auth: process.env.GITHUB_TOKEN, auth: process.env.GITHUB_TOKEN,
@ -127,7 +128,7 @@ class GitHub {
data.conclusion = result; data.conclusion = result;
} }
await (CloudRunner.isCloudRunnerAsyncEnvironment await (CloudRunner.isCloudRunnerAsyncEnvironment || GitHub.asyncWorkflows
? GitHub.runUpdateAsyncChecksWorkflow(data, `update`) ? GitHub.runUpdateAsyncChecksWorkflow(data, `update`)
: GitHub.updateGitHubCheckRequest(data)); : GitHub.updateGitHubCheckRequest(data));
} }