Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
frostebite committed Mar 30, 2023
1 parent 3032a4a commit 22d282c
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

- [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
- [ ] Docs (If new inputs or outputs have been added or changes to behavior that should be documented. Please make
a PR in the [documentation repo](https://github.com/game-ci/documentation))
- [ ] Docs (If new inputs or outputs have been added or changes to behavior that should be documented. Please make a PR
in the [documentation repo](https://github.com/game-ci/documentation))
- [ ] Readme (updated or not needed)
- [ ] Tests (added, updated or not needed)
4 changes: 4 additions & 0 deletions .github/workflows/cloud-runner-ci-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
name: Smoke Tests
if: github.event.event_type != 'pull_request_target'
runs-on: ubuntu-latest
env:
GIT_PRIVATE_TOKEN: ${{ secrets.GIT_PRIVATE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -111,6 +114,7 @@ jobs:
- 'cloud-runner-environment'
#- 'cloud-runner-hooks'
- 'cloud-runner-s3-steps'
- 'cloud-runner-github-checks'
#- 'cloud-runner-local-persistence'
#- 'cloud-runner-locking-core'
#- 'cloud-runner-locking-get-locked'
Expand Down
30 changes: 20 additions & 10 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions src/model/cloud-runner/cloud-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ class CloudRunner {
CloudRunner.lockedWorkspace = ``;
}
}
const content = { ...CloudRunner.buildParameters };
content.gitPrivateToken = ``;
content.unitySerial = ``;
const jsonContent = JSON.stringify(content, undefined, 4);
await GitHub.updateGitHubCheck(jsonContent, CloudRunner.buildParameters.buildGuid);
await CloudRunner.updateStatusWithBuildParameters();
const output = await new WorkflowCompositionRoot().run(
new CloudRunnerStepParameters(
baseImage,
Expand All @@ -135,7 +131,9 @@ class CloudRunner {
);
CloudRunnerLogger.log(`Cleanup complete`);
if (!CloudRunner.buildParameters.isCliMode) core.endGroup();
await GitHub.updateGitHubCheck(CloudRunner.buildParameters.buildGuid, `success`, `success`, `completed`);
if ((buildParameters.asyncWorkflow && this.isCloudRunnerEnvironment) || !buildParameters.asyncWorkflow) {
await GitHub.updateGitHubCheck(CloudRunner.buildParameters.buildGuid, `success`, `success`, `completed`);
}

if (BuildParameters.shouldUseRetainedWorkspaceMode(buildParameters)) {
const workspace = CloudRunner.lockedWorkspace || ``;
Expand Down Expand Up @@ -176,5 +174,15 @@ class CloudRunner {
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;
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ class KubernetesJobSpecFactory {
preStop: {
exec: {
command: [
'bin/bash',
'-c',
`cd /data/builder/action/steps;
chmod +x /return_license.sh;
/return_license.sh;`,
Expand Down
2 changes: 1 addition & 1 deletion src/model/cloud-runner/remote-client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class RemoteClient {
if (!(await RemoteClient.handleRetainedWorkspace())) {
await RemoteClient.bootstrapRepository();
}
await RemoteClient.replaceLargePackageReferencesWithSharedReferences();
await RemoteClient.runCustomHookFiles(`before-build`);
}
static async runCustomHookFiles(hookLifecycle: string) {
Expand Down Expand Up @@ -47,7 +48,6 @@ export class RemoteClient {
`mkdir -p ${CloudRunnerFolders.ToLinuxFolder(CloudRunnerFolders.cacheFolderForCacheKeyFull)}`,
);
await RemoteClient.cloneRepoWithoutLFSFiles();
await RemoteClient.replaceLargePackageReferencesWithSharedReferences();
await RemoteClient.sizeOfFolder(
'repo before lfs cache pull',
CloudRunnerFolders.ToLinuxFolder(CloudRunnerFolders.repoPathAbsolute),
Expand Down
49 changes: 49 additions & 0 deletions src/model/cloud-runner/tests/cloud-runner-github-checks.test.ts
Original file line number Diff line number Diff line change
@@ -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);
}
});
5 changes: 5 additions & 0 deletions src/model/cloud-runner/workflows/async-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ node /builder/dist/index.js -m async-workflow`,
[
...secrets,
...[
{
ParameterKey: `GITHUB_TOKEN`,
EnvironmentVariable: `GITHUB_TOKEN`,
ParameterValue: process.env.GITHUB_TOKEN || ``,
},
{
ParameterKey: `AWS_ACCESS_KEY_ID`,
EnvironmentVariable: `AWS_ACCESS_KEY_ID`,
Expand Down
3 changes: 2 additions & 1 deletion src/model/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class GitHub {
private static startedDate: string;
private static endedDate: string;
static result: string = ``;
static asyncWorkflows: boolean;
private static get octokitDefaultToken() {
return new Octokit({
auth: process.env.GITHUB_TOKEN,
Expand Down Expand Up @@ -127,7 +128,7 @@ class GitHub {
data.conclusion = result;
}

await (CloudRunner.isCloudRunnerAsyncEnvironment
await (CloudRunner.isCloudRunnerAsyncEnvironment || GitHub.asyncWorkflows
? GitHub.runUpdateAsyncChecksWorkflow(data, `update`)
: GitHub.updateGitHubCheckRequest(data));
}
Expand Down

0 comments on commit 22d282c

Please sign in to comment.