test checks

pull/479/head
Frostebite 2022-12-05 23:47:15 +00:00
parent 2374bf273a
commit 3f2ccc00e8
6 changed files with 67 additions and 93 deletions

View File

@ -127,6 +127,7 @@ jobs:
targetPlatform: ${{ matrix.targetPlatform }}
cloudRunnerCluster: ${{ matrix.cloudRunnerCluster }}
customStepFiles: aws-s3-upload-build,aws-s3-pull-cache,aws-s3-upload-cache
githubChecks: true
- run: |
aws s3 cp s3://game-ci-test-storage/cloud-runner-cache/${{ steps.unity-build.outputs.CACHE_KEY }}/build/build-${{ steps.unity-build.outputs.BUILD_GUID }}.tar.lz4 build-${{ steps.unity-build.outputs.BUILD_GUID }}.tar.lz4
ls

74
dist/index.js vendored
View File

@ -719,7 +719,10 @@ class CloudRunnerOptions {
// GitHub parameters
// ### ### ###
static get githubChecksEnabled() {
return CloudRunnerOptions.getInput('githubChecksEnabled') || false;
return CloudRunnerOptions.getInput('githubChecks') || false;
}
static get githubOwner() {
return CloudRunnerOptions.githubRepo.split(`/`)[1] || false;
}
// ### ### ###
// Git syncronization parameters
@ -979,6 +982,7 @@ const local_1 = __importDefault(__nccwpck_require__(66575));
const docker_1 = __importDefault(__nccwpck_require__(42802));
const github_1 = __importDefault(__nccwpck_require__(83654));
const shared_workspace_locking_1 = __importDefault(__nccwpck_require__(87562));
const cloud_runner_options_1 = __importDefault(__nccwpck_require__(96552));
class CloudRunner {
static setup(buildParameters) {
cloud_runner_logger_1.default.setup();
@ -1024,6 +1028,9 @@ class CloudRunner {
return __awaiter(this, void 0, void 0, function* () {
CloudRunner.setup(buildParameters);
try {
if (cloud_runner_options_1.default.githubChecksEnabled) {
github_1.default.createGitHubCheck(cloud_runner_options_1.default.githubOwner, buildParameters.githubRepo, buildParameters.gitPrivateToken, 'test-check-name', buildParameters.gitSha, 'A check test', buildParameters.buildGuid);
}
if (buildParameters.retainWorkspace) {
CloudRunner.lockedWorkspace = `${CloudRunner.retainedWorkspacePrefix}-${CloudRunner.buildParameters.buildGuid}`;
const result = yield shared_workspace_locking_1.default.GetOrCreateLockedWorkspace(CloudRunner.lockedWorkspace, CloudRunner.buildParameters.buildGuid, CloudRunner.buildParameters);
@ -6063,17 +6070,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core_1 = __nccwpck_require__(76762);
class GitHub {
static updateGitHubCheck() {
static updateGitHubCheck(owner, repo, token, name, sha, nameReadable, summary, longDescription) {
return __awaiter(this, void 0, void 0, function* () {
const octokit = new core_1.Octokit({
auth: 'YOUR-TOKEN',
auth: token,
});
const data = {
owner: 'OWNER',
repo: 'REPO',
owner,
repo,
// eslint-disable-next-line camelcase
check_run_id: 0,
name: 'mighty_readme',
name,
// eslint-disable-next-line camelcase
head_sha: sha,
// eslint-disable-next-line camelcase
started_at: '2018-05-04T01:14:52Z',
status: `completed`,
@ -6081,37 +6090,10 @@ class GitHub {
// eslint-disable-next-line camelcase
completed_at: '2018-05-04T01:14:52Z',
output: {
title: 'Mighty Readme report',
summary: 'There are 0 failures, 2 warnings, and 1 notices.',
text: 'You may have some misspelled words on lines 2 and 4. You also may want to add a section in your README about how to install your app.',
annotations: [
{
path: 'README.md',
// eslint-disable-next-line camelcase
annotation_level: 'warning',
title: 'Spell Checker',
message: "Check your spelling for 'banaas'.",
// eslint-disable-next-line camelcase
raw_details: "Do you mean 'bananas' or 'banana'?",
// eslint-disable-next-line camelcase
start_line: 2,
// eslint-disable-next-line camelcase
end_line: 2,
},
{
path: 'README.md',
// eslint-disable-next-line camelcase
annotation_level: 'warning',
title: 'Spell Checker',
message: "Check your spelling for 'aples'",
// eslint-disable-next-line camelcase
raw_details: "Do you mean 'apples' or 'Naples'",
// eslint-disable-next-line camelcase
start_line: 4,
// eslint-disable-next-line camelcase
end_line: 4,
},
],
title: nameReadable,
summary,
text: longDescription,
annotations: [],
images: [
{
alt: 'Super bananas',
@ -6124,26 +6106,26 @@ class GitHub {
yield octokit.request('PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}', data);
});
}
static createGitHubCheck() {
static createGitHubCheck(owner, repo, token, name, sha, nameReadable, summary) {
return __awaiter(this, void 0, void 0, function* () {
// call github api to create a check
const octokit = new core_1.Octokit({
auth: 'YOUR-TOKEN',
auth: token,
});
yield octokit.request('POST /repos/{owner}/{repo}/check-runs', {
owner: 'OWNER',
repo: 'REPO',
name: 'mighty_readme',
yield octokit.request(`POST /repos/${owner}/${repo}/check-runs`, {
owner,
repo,
name,
// eslint-disable-next-line camelcase
head_sha: 'ce587453ced02b1526dfb4cb910479d431683101',
head_sha: sha,
status: 'in_progress',
// eslint-disable-next-line camelcase
external_id: '42',
// eslint-disable-next-line camelcase
started_at: '2018-05-04T01:14:52Z',
output: {
title: 'Mighty Readme report',
summary: '',
title: nameReadable,
summary,
text: '',
},
});

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -60,7 +60,11 @@ class CloudRunnerOptions {
// GitHub parameters
// ### ### ###
static get githubChecksEnabled() {
return CloudRunnerOptions.getInput('githubChecksEnabled') || false;
return CloudRunnerOptions.getInput('githubChecks') || false;
}
static get githubOwner() {
return CloudRunnerOptions.githubRepo.split(`/`)[1] || false;
}
// ### ### ###

View File

@ -15,6 +15,7 @@ import LocalCloudRunner from './providers/local';
import LocalDockerCloudRunner from './providers/docker';
import GitHub from '../github';
import SharedWorkspaceLocking from './services/shared-workspace-locking';
import CloudRunnerOptions from './cloud-runner-options';
class CloudRunner {
public static Provider: ProviderInterface;
@ -68,6 +69,17 @@ class CloudRunner {
static async run(buildParameters: BuildParameters, baseImage: string) {
CloudRunner.setup(buildParameters);
try {
if (CloudRunnerOptions.githubChecksEnabled) {
GitHub.createGitHubCheck(
CloudRunnerOptions.githubOwner,
buildParameters.githubRepo,
buildParameters.gitPrivateToken,
'test-check-name',
buildParameters.gitSha,
'A check test',
buildParameters.buildGuid,
);
}
if (buildParameters.retainWorkspace) {
CloudRunner.lockedWorkspace = `${CloudRunner.retainedWorkspacePrefix}-${CloudRunner.buildParameters.buildGuid}`;

View File

@ -3,17 +3,19 @@ import { Octokit } from '@octokit/core';
class GitHub {
public static githubInputEnabled: boolean = true;
public static async updateGitHubCheck() {
public static async updateGitHubCheck(owner, repo, token, name, sha, nameReadable, summary, longDescription) {
const octokit = new Octokit({
auth: 'YOUR-TOKEN',
auth: token,
});
const data: any = {
owner: 'OWNER',
repo: 'REPO',
owner,
repo,
// eslint-disable-next-line camelcase
check_run_id: 0,
name: 'mighty_readme',
name,
// eslint-disable-next-line camelcase
head_sha: sha,
// eslint-disable-next-line camelcase
started_at: '2018-05-04T01:14:52Z',
status: `completed`,
@ -21,37 +23,10 @@ class GitHub {
// eslint-disable-next-line camelcase
completed_at: '2018-05-04T01:14:52Z',
output: {
title: 'Mighty Readme report',
summary: 'There are 0 failures, 2 warnings, and 1 notices.',
text: 'You may have some misspelled words on lines 2 and 4. You also may want to add a section in your README about how to install your app.',
annotations: [
{
path: 'README.md',
// eslint-disable-next-line camelcase
annotation_level: 'warning',
title: 'Spell Checker',
message: "Check your spelling for 'banaas'.",
// eslint-disable-next-line camelcase
raw_details: "Do you mean 'bananas' or 'banana'?",
// eslint-disable-next-line camelcase
start_line: 2,
// eslint-disable-next-line camelcase
end_line: 2,
},
{
path: 'README.md',
// eslint-disable-next-line camelcase
annotation_level: 'warning',
title: 'Spell Checker',
message: "Check your spelling for 'aples'",
// eslint-disable-next-line camelcase
raw_details: "Do you mean 'apples' or 'Naples'",
// eslint-disable-next-line camelcase
start_line: 4,
// eslint-disable-next-line camelcase
end_line: 4,
},
],
title: nameReadable,
summary,
text: longDescription,
annotations: [],
images: [
{
alt: 'Super bananas',
@ -65,26 +40,26 @@ class GitHub {
await octokit.request('PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}', data);
}
public static async createGitHubCheck() {
public static async createGitHubCheck(owner, repo, token, name, sha, nameReadable, summary) {
// call github api to create a check
const octokit = new Octokit({
auth: 'YOUR-TOKEN',
auth: token,
});
await octokit.request('POST /repos/{owner}/{repo}/check-runs', {
owner: 'OWNER',
repo: 'REPO',
name: 'mighty_readme',
await octokit.request(`POST /repos/${owner}/${repo}/check-runs`, {
owner,
repo,
name,
// eslint-disable-next-line camelcase
head_sha: 'ce587453ced02b1526dfb4cb910479d431683101',
head_sha: sha,
status: 'in_progress',
// eslint-disable-next-line camelcase
external_id: '42',
// eslint-disable-next-line camelcase
started_at: '2018-05-04T01:14:52Z',
output: {
title: 'Mighty Readme report',
summary: '',
title: nameReadable,
summary,
text: '',
},
});