Update github check with aws log
parent
1490be2bd7
commit
f304f427e4
|
|
@ -985,7 +985,6 @@ const local_1 = __importDefault(__nccwpck_require__(66575));
|
||||||
const docker_1 = __importDefault(__nccwpck_require__(42802));
|
const docker_1 = __importDefault(__nccwpck_require__(42802));
|
||||||
const github_1 = __importDefault(__nccwpck_require__(83654));
|
const github_1 = __importDefault(__nccwpck_require__(83654));
|
||||||
const shared_workspace_locking_1 = __importDefault(__nccwpck_require__(87562));
|
const shared_workspace_locking_1 = __importDefault(__nccwpck_require__(87562));
|
||||||
const cloud_runner_options_1 = __importDefault(__nccwpck_require__(96552));
|
|
||||||
class CloudRunner {
|
class CloudRunner {
|
||||||
static setup(buildParameters) {
|
static setup(buildParameters) {
|
||||||
cloud_runner_logger_1.default.setup();
|
cloud_runner_logger_1.default.setup();
|
||||||
|
|
@ -1032,9 +1031,7 @@ class CloudRunner {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
CloudRunner.setup(buildParameters);
|
CloudRunner.setup(buildParameters);
|
||||||
try {
|
try {
|
||||||
if (cloud_runner_options_1.default.githubChecksEnabled) {
|
CloudRunner.githubCheckId = yield github_1.default.createGitHubCheck(CloudRunner.buildParameters.buildGuid);
|
||||||
CloudRunner.githubCheckId = yield github_1.default.createGitHubCheck(cloud_runner_options_1.default.githubOwner, cloud_runner_options_1.default.githubRepoName, CloudRunner.buildParameters.gitPrivateToken, `Cloud Runner (${CloudRunner.buildParameters.buildGuid})`, CloudRunner.buildParameters.gitSha, `Cloud Runner (${CloudRunner.buildParameters.buildGuid})`, CloudRunner.buildParameters.buildGuid);
|
|
||||||
}
|
|
||||||
if (buildParameters.retainWorkspace) {
|
if (buildParameters.retainWorkspace) {
|
||||||
CloudRunner.lockedWorkspace = `${CloudRunner.retainedWorkspacePrefix}-${CloudRunner.buildParameters.buildGuid}`;
|
CloudRunner.lockedWorkspace = `${CloudRunner.retainedWorkspacePrefix}-${CloudRunner.buildParameters.buildGuid}`;
|
||||||
const result = yield shared_workspace_locking_1.default.GetOrCreateLockedWorkspace(CloudRunner.lockedWorkspace, CloudRunner.buildParameters.buildGuid, CloudRunner.buildParameters);
|
const result = yield shared_workspace_locking_1.default.GetOrCreateLockedWorkspace(CloudRunner.lockedWorkspace, CloudRunner.buildParameters.buildGuid, CloudRunner.buildParameters);
|
||||||
|
|
@ -1070,15 +1067,11 @@ class CloudRunner {
|
||||||
if (buildParameters.constantGarbageCollection) {
|
if (buildParameters.constantGarbageCollection) {
|
||||||
CloudRunner.Provider.garbageCollect(``, true, buildParameters.garbageCollectionMaxAge, true, true);
|
CloudRunner.Provider.garbageCollect(``, true, buildParameters.garbageCollectionMaxAge, true, true);
|
||||||
}
|
}
|
||||||
if (cloud_runner_options_1.default.githubChecksEnabled) {
|
yield github_1.default.updateGitHubCheck(CloudRunner.buildParameters.buildGuid, `success`, `completed`);
|
||||||
yield github_1.default.updateGitHubCheck(CloudRunner.githubCheckId, cloud_runner_options_1.default.githubOwner, cloud_runner_options_1.default.githubRepoName, CloudRunner.buildParameters.gitPrivateToken, `Cloud Runner (${CloudRunner.buildParameters.buildGuid})`, CloudRunner.buildParameters.gitSha, `Cloud Runner (${CloudRunner.buildParameters.buildGuid})`, CloudRunner.buildParameters.buildGuid, `success`);
|
|
||||||
}
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
if (cloud_runner_options_1.default.githubChecksEnabled) {
|
yield github_1.default.updateGitHubCheck(CloudRunner.buildParameters.buildGuid, error, `failed`, `completed`);
|
||||||
yield github_1.default.updateGitHubCheck(CloudRunner.githubCheckId, cloud_runner_options_1.default.githubOwner, cloud_runner_options_1.default.githubRepoName, CloudRunner.buildParameters.gitPrivateToken, `Cloud Runner (${CloudRunner.buildParameters.buildGuid})`, CloudRunner.buildParameters.gitSha, `Cloud Runner (${CloudRunner.buildParameters.buildGuid})`, CloudRunner.buildParameters.buildGuid, error);
|
|
||||||
}
|
|
||||||
if (!CloudRunner.buildParameters.isCliMode)
|
if (!CloudRunner.buildParameters.isCliMode)
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
yield cloud_runner_error_1.CloudRunnerError.handleException(error, CloudRunner.buildParameters, CloudRunner.defaultSecrets);
|
yield cloud_runner_error_1.CloudRunnerError.handleException(error, CloudRunner.buildParameters, CloudRunner.defaultSecrets);
|
||||||
|
|
@ -1584,6 +1577,7 @@ const cloud_runner_1 = __importDefault(__nccwpck_require__(79144));
|
||||||
const cloud_runner_custom_hooks_1 = __nccwpck_require__(58873);
|
const cloud_runner_custom_hooks_1 = __nccwpck_require__(58873);
|
||||||
const follow_log_stream_service_1 = __nccwpck_require__(64121);
|
const follow_log_stream_service_1 = __nccwpck_require__(64121);
|
||||||
const cloud_runner_options_1 = __importDefault(__nccwpck_require__(96552));
|
const cloud_runner_options_1 = __importDefault(__nccwpck_require__(96552));
|
||||||
|
const github_1 = __importDefault(__nccwpck_require__(83654));
|
||||||
class AWSTaskRunner {
|
class AWSTaskRunner {
|
||||||
static runTask(taskDef, environment, commands) {
|
static runTask(taskDef, environment, commands) {
|
||||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
||||||
|
|
@ -1688,6 +1682,7 @@ class AWSTaskRunner {
|
||||||
let iterator = yield AWSTaskRunner.getLogIterator(stream);
|
let iterator = yield AWSTaskRunner.getLogIterator(stream);
|
||||||
const logBaseUrl = `https://${__1.Input.region}.console.aws.amazon.com/cloudwatch/home?region=${__1.Input.region}#logsV2:log-groups/log-group/${cloud_runner_1.default.buildParameters.awsBaseStackName}-${cloud_runner_1.default.buildParameters.buildGuid}`;
|
const logBaseUrl = `https://${__1.Input.region}.console.aws.amazon.com/cloudwatch/home?region=${__1.Input.region}#logsV2:log-groups/log-group/${cloud_runner_1.default.buildParameters.awsBaseStackName}-${cloud_runner_1.default.buildParameters.buildGuid}`;
|
||||||
cloud_runner_logger_1.default.log(`You view the log stream on AWS Cloud Watch: ${logBaseUrl}`);
|
cloud_runner_logger_1.default.log(`You view the log stream on AWS Cloud Watch: ${logBaseUrl}`);
|
||||||
|
github_1.default.updateGitHubCheck(`You view the log stream on AWS Cloud Watch: ${logBaseUrl}`, ``);
|
||||||
let shouldReadLogs = true;
|
let shouldReadLogs = true;
|
||||||
let shouldCleanup = true;
|
let shouldCleanup = true;
|
||||||
let timestamp = 0;
|
let timestamp = 0;
|
||||||
|
|
@ -5110,6 +5105,7 @@ const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
|
||||||
const core = __importStar(__nccwpck_require__(42186));
|
const core = __importStar(__nccwpck_require__(42186));
|
||||||
const cloud_runner_1 = __importDefault(__nccwpck_require__(79144));
|
const cloud_runner_1 = __importDefault(__nccwpck_require__(79144));
|
||||||
const cloud_runner_statics_1 = __nccwpck_require__(90828);
|
const cloud_runner_statics_1 = __nccwpck_require__(90828);
|
||||||
|
const github_1 = __importDefault(__nccwpck_require__(83654));
|
||||||
class FollowLogStreamService {
|
class FollowLogStreamService {
|
||||||
static handleIteration(message, shouldReadLogs, shouldCleanup, output) {
|
static handleIteration(message, shouldReadLogs, shouldCleanup, output) {
|
||||||
if (message.includes(`---${cloud_runner_1.default.buildParameters.logId}`)) {
|
if (message.includes(`---${cloud_runner_1.default.buildParameters.logId}`)) {
|
||||||
|
|
@ -5117,13 +5113,16 @@ class FollowLogStreamService {
|
||||||
shouldReadLogs = false;
|
shouldReadLogs = false;
|
||||||
}
|
}
|
||||||
else if (message.includes('Rebuilding Library because the asset database could not be found!')) {
|
else if (message.includes('Rebuilding Library because the asset database could not be found!')) {
|
||||||
|
github_1.default.updateGitHubCheck(`Library was not found, importing new Library`, ``);
|
||||||
core.warning('LIBRARY NOT FOUND!');
|
core.warning('LIBRARY NOT FOUND!');
|
||||||
core.setOutput('library-found', 'false');
|
core.setOutput('library-found', 'false');
|
||||||
}
|
}
|
||||||
else if (message.includes('Build succeeded')) {
|
else if (message.includes('Build succeeded')) {
|
||||||
|
github_1.default.updateGitHubCheck(`Build succeeded`, `Build succeeded`);
|
||||||
core.setOutput('build-result', 'success');
|
core.setOutput('build-result', 'success');
|
||||||
}
|
}
|
||||||
else if (message.includes('Build fail')) {
|
else if (message.includes('Build fail')) {
|
||||||
|
github_1.default.updateGitHubCheck(`Build failed`, `Build failed`);
|
||||||
core.setOutput('build-result', 'failed');
|
core.setOutput('build-result', 'failed');
|
||||||
core.setFailed('unity build failed');
|
core.setFailed('unity build failed');
|
||||||
core.error('BUILD FAILED!');
|
core.error('BUILD FAILED!');
|
||||||
|
|
@ -6108,9 +6107,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const core_1 = __nccwpck_require__(76762);
|
const core_1 = __nccwpck_require__(76762);
|
||||||
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
|
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
|
||||||
|
const cloud_runner_1 = __importDefault(__nccwpck_require__(79144));
|
||||||
|
const cloud_runner_options_1 = __importDefault(__nccwpck_require__(96552));
|
||||||
class GitHub {
|
class GitHub {
|
||||||
static updateGitHubCheck(checkRunId, owner, repo, token, name, sha, nameReadable, summary, longDescription) {
|
static updateGitHubCheck(summary, longDescription, result = `in_progress`, status = `completed`) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (!cloud_runner_options_1.default.githubChecksEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GitHub.longDescriptionContent += `\n${longDescription}`;
|
||||||
|
const sha = cloud_runner_1.default.buildParameters.gitSha;
|
||||||
|
const name = `Cloud Runner (${cloud_runner_1.default.buildParameters.buildGuid})`;
|
||||||
|
const nameReadable = name;
|
||||||
|
const token = cloud_runner_1.default.buildParameters.gitPrivateToken;
|
||||||
|
const checkRunId = cloud_runner_1.default.githubCheckId;
|
||||||
|
const owner = cloud_runner_options_1.default.githubOwner;
|
||||||
|
const repo = cloud_runner_options_1.default.githubRepoName;
|
||||||
const octokit = new core_1.Octokit({
|
const octokit = new core_1.Octokit({
|
||||||
auth: process.env.GITHUB_CHECK_TOKEN || token,
|
auth: process.env.GITHUB_CHECK_TOKEN || token,
|
||||||
});
|
});
|
||||||
|
|
@ -6123,21 +6135,21 @@ class GitHub {
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
head_sha: sha,
|
head_sha: sha,
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
started_at: '2018-05-04T01:14:52Z',
|
started_at: GitHub.startedDate,
|
||||||
status: `completed`,
|
status,
|
||||||
conclusion: 'success',
|
conclusion: result,
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
completed_at: '2018-05-04T01:14:52Z',
|
completed_at: '2018-05-04T01:14:52Z',
|
||||||
output: {
|
output: {
|
||||||
title: nameReadable,
|
title: nameReadable,
|
||||||
summary,
|
summary,
|
||||||
text: longDescription,
|
text: GitHub.longDescriptionContent,
|
||||||
annotations: [],
|
annotations: [],
|
||||||
images: [
|
images: [
|
||||||
{
|
{
|
||||||
alt: 'Super bananas',
|
alt: 'Game-CI',
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
image_url: 'http://example.com/images/42',
|
image_url: 'https://game.ci/assets/images/game-ci-brand-logo-wordmark.svg',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
@ -6145,8 +6157,17 @@ class GitHub {
|
||||||
yield octokit.request(`PATCH /repos/${owner}/${repo}/check-runs/${checkRunId}`, data);
|
yield octokit.request(`PATCH /repos/${owner}/${repo}/check-runs/${checkRunId}`, data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static createGitHubCheck(owner, repo, token, name, sha, nameReadable, summary) {
|
static createGitHubCheck(summary) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (!cloud_runner_options_1.default.githubChecksEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const sha = cloud_runner_1.default.buildParameters.gitSha;
|
||||||
|
const name = `Cloud Runner (${cloud_runner_1.default.buildParameters.buildGuid})`;
|
||||||
|
const nameReadable = name;
|
||||||
|
const token = cloud_runner_1.default.buildParameters.gitPrivateToken;
|
||||||
|
const owner = cloud_runner_options_1.default.githubOwner;
|
||||||
|
const repo = cloud_runner_options_1.default.githubRepoName;
|
||||||
// call github api to create a check
|
// call github api to create a check
|
||||||
const octokit = new core_1.Octokit({
|
const octokit = new core_1.Octokit({
|
||||||
auth: process.env.CHECKS_API_TOKEN || token,
|
auth: process.env.CHECKS_API_TOKEN || token,
|
||||||
|
|
@ -6162,7 +6183,7 @@ class GitHub {
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
external_id: '42',
|
external_id: '42',
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
started_at: '2018-05-04T01:14:52Z',
|
started_at: GitHub.startedDate,
|
||||||
output: {
|
output: {
|
||||||
title: nameReadable,
|
title: nameReadable,
|
||||||
summary,
|
summary,
|
||||||
|
|
@ -6174,6 +6195,8 @@ class GitHub {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GitHub.githubInputEnabled = true;
|
GitHub.githubInputEnabled = true;
|
||||||
|
GitHub.longDescriptionContent = ``;
|
||||||
|
GitHub.startedDate = Date.now();
|
||||||
exports["default"] = GitHub;
|
exports["default"] = GitHub;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -15,7 +15,6 @@ import LocalCloudRunner from './providers/local';
|
||||||
import LocalDockerCloudRunner from './providers/docker';
|
import LocalDockerCloudRunner from './providers/docker';
|
||||||
import GitHub from '../github';
|
import GitHub from '../github';
|
||||||
import SharedWorkspaceLocking from './services/shared-workspace-locking';
|
import SharedWorkspaceLocking from './services/shared-workspace-locking';
|
||||||
import CloudRunnerOptions from './cloud-runner-options';
|
|
||||||
|
|
||||||
class CloudRunner {
|
class CloudRunner {
|
||||||
public static Provider: ProviderInterface;
|
public static Provider: ProviderInterface;
|
||||||
|
|
@ -76,17 +75,8 @@ class CloudRunner {
|
||||||
static async run(buildParameters: BuildParameters, baseImage: string) {
|
static async run(buildParameters: BuildParameters, baseImage: string) {
|
||||||
CloudRunner.setup(buildParameters);
|
CloudRunner.setup(buildParameters);
|
||||||
try {
|
try {
|
||||||
if (CloudRunnerOptions.githubChecksEnabled) {
|
CloudRunner.githubCheckId = await GitHub.createGitHubCheck(CloudRunner.buildParameters.buildGuid);
|
||||||
CloudRunner.githubCheckId = await GitHub.createGitHubCheck(
|
|
||||||
CloudRunnerOptions.githubOwner,
|
|
||||||
CloudRunnerOptions.githubRepoName,
|
|
||||||
CloudRunner.buildParameters.gitPrivateToken,
|
|
||||||
`Cloud Runner (${CloudRunner.buildParameters.buildGuid})`,
|
|
||||||
CloudRunner.buildParameters.gitSha,
|
|
||||||
`Cloud Runner (${CloudRunner.buildParameters.buildGuid})`,
|
|
||||||
CloudRunner.buildParameters.buildGuid,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (buildParameters.retainWorkspace) {
|
if (buildParameters.retainWorkspace) {
|
||||||
CloudRunner.lockedWorkspace = `${CloudRunner.retainedWorkspacePrefix}-${CloudRunner.buildParameters.buildGuid}`;
|
CloudRunner.lockedWorkspace = `${CloudRunner.retainedWorkspacePrefix}-${CloudRunner.buildParameters.buildGuid}`;
|
||||||
|
|
||||||
|
|
@ -142,35 +132,11 @@ class CloudRunner {
|
||||||
CloudRunner.Provider.garbageCollect(``, true, buildParameters.garbageCollectionMaxAge, true, true);
|
CloudRunner.Provider.garbageCollect(``, true, buildParameters.garbageCollectionMaxAge, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CloudRunnerOptions.githubChecksEnabled) {
|
await GitHub.updateGitHubCheck(CloudRunner.buildParameters.buildGuid, `success`, `completed`);
|
||||||
await GitHub.updateGitHubCheck(
|
|
||||||
CloudRunner.githubCheckId,
|
|
||||||
CloudRunnerOptions.githubOwner,
|
|
||||||
CloudRunnerOptions.githubRepoName,
|
|
||||||
CloudRunner.buildParameters.gitPrivateToken,
|
|
||||||
`Cloud Runner (${CloudRunner.buildParameters.buildGuid})`,
|
|
||||||
CloudRunner.buildParameters.gitSha,
|
|
||||||
`Cloud Runner (${CloudRunner.buildParameters.buildGuid})`,
|
|
||||||
CloudRunner.buildParameters.buildGuid,
|
|
||||||
`success`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (CloudRunnerOptions.githubChecksEnabled) {
|
await GitHub.updateGitHubCheck(CloudRunner.buildParameters.buildGuid, error, `failed`, `completed`);
|
||||||
await GitHub.updateGitHubCheck(
|
|
||||||
CloudRunner.githubCheckId,
|
|
||||||
CloudRunnerOptions.githubOwner,
|
|
||||||
CloudRunnerOptions.githubRepoName,
|
|
||||||
CloudRunner.buildParameters.gitPrivateToken,
|
|
||||||
`Cloud Runner (${CloudRunner.buildParameters.buildGuid})`,
|
|
||||||
CloudRunner.buildParameters.gitSha,
|
|
||||||
`Cloud Runner (${CloudRunner.buildParameters.buildGuid})`,
|
|
||||||
CloudRunner.buildParameters.buildGuid,
|
|
||||||
error,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!CloudRunner.buildParameters.isCliMode) core.endGroup();
|
if (!CloudRunner.buildParameters.isCliMode) core.endGroup();
|
||||||
await CloudRunnerError.handleException(error, CloudRunner.buildParameters, CloudRunner.defaultSecrets);
|
await CloudRunnerError.handleException(error, CloudRunner.buildParameters, CloudRunner.defaultSecrets);
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import CloudRunner from '../../cloud-runner';
|
||||||
import { CloudRunnerCustomHooks } from '../../services/cloud-runner-custom-hooks';
|
import { CloudRunnerCustomHooks } from '../../services/cloud-runner-custom-hooks';
|
||||||
import { FollowLogStreamService } from '../../services/follow-log-stream-service';
|
import { FollowLogStreamService } from '../../services/follow-log-stream-service';
|
||||||
import CloudRunnerOptions from '../../cloud-runner-options';
|
import CloudRunnerOptions from '../../cloud-runner-options';
|
||||||
|
import GitHub from '../../../github';
|
||||||
|
|
||||||
class AWSTaskRunner {
|
class AWSTaskRunner {
|
||||||
public static ECS: AWS.ECS;
|
public static ECS: AWS.ECS;
|
||||||
|
|
@ -127,6 +128,7 @@ class AWSTaskRunner {
|
||||||
|
|
||||||
const logBaseUrl = `https://${Input.region}.console.aws.amazon.com/cloudwatch/home?region=${Input.region}#logsV2:log-groups/log-group/${CloudRunner.buildParameters.awsBaseStackName}-${CloudRunner.buildParameters.buildGuid}`;
|
const logBaseUrl = `https://${Input.region}.console.aws.amazon.com/cloudwatch/home?region=${Input.region}#logsV2:log-groups/log-group/${CloudRunner.buildParameters.awsBaseStackName}-${CloudRunner.buildParameters.buildGuid}`;
|
||||||
CloudRunnerLogger.log(`You view the log stream on AWS Cloud Watch: ${logBaseUrl}`);
|
CloudRunnerLogger.log(`You view the log stream on AWS Cloud Watch: ${logBaseUrl}`);
|
||||||
|
GitHub.updateGitHubCheck(`You view the log stream on AWS Cloud Watch: ${logBaseUrl}`, ``);
|
||||||
let shouldReadLogs = true;
|
let shouldReadLogs = true;
|
||||||
let shouldCleanup = true;
|
let shouldCleanup = true;
|
||||||
let timestamp: number = 0;
|
let timestamp: number = 0;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import CloudRunnerLogger from './cloud-runner-logger';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import CloudRunner from '../cloud-runner';
|
import CloudRunner from '../cloud-runner';
|
||||||
import { CloudRunnerStatics } from '../cloud-runner-statics';
|
import { CloudRunnerStatics } from '../cloud-runner-statics';
|
||||||
|
import GitHub from '../../github';
|
||||||
|
|
||||||
export class FollowLogStreamService {
|
export class FollowLogStreamService {
|
||||||
public static handleIteration(message, shouldReadLogs, shouldCleanup, output) {
|
public static handleIteration(message, shouldReadLogs, shouldCleanup, output) {
|
||||||
|
|
@ -9,11 +10,14 @@ export class FollowLogStreamService {
|
||||||
CloudRunnerLogger.log('End of log transmission received');
|
CloudRunnerLogger.log('End of log transmission received');
|
||||||
shouldReadLogs = false;
|
shouldReadLogs = false;
|
||||||
} else if (message.includes('Rebuilding Library because the asset database could not be found!')) {
|
} else if (message.includes('Rebuilding Library because the asset database could not be found!')) {
|
||||||
|
GitHub.updateGitHubCheck(`Library was not found, importing new Library`, ``);
|
||||||
core.warning('LIBRARY NOT FOUND!');
|
core.warning('LIBRARY NOT FOUND!');
|
||||||
core.setOutput('library-found', 'false');
|
core.setOutput('library-found', 'false');
|
||||||
} else if (message.includes('Build succeeded')) {
|
} else if (message.includes('Build succeeded')) {
|
||||||
|
GitHub.updateGitHubCheck(`Build succeeded`, `Build succeeded`);
|
||||||
core.setOutput('build-result', 'success');
|
core.setOutput('build-result', 'success');
|
||||||
} else if (message.includes('Build fail')) {
|
} else if (message.includes('Build fail')) {
|
||||||
|
GitHub.updateGitHubCheck(`Build failed`, `Build failed`);
|
||||||
core.setOutput('build-result', 'failed');
|
core.setOutput('build-result', 'failed');
|
||||||
core.setFailed('unity build failed');
|
core.setFailed('unity build failed');
|
||||||
core.error('BUILD FAILED!');
|
core.error('BUILD FAILED!');
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,25 @@
|
||||||
import { Octokit } from '@octokit/core';
|
import { Octokit } from '@octokit/core';
|
||||||
import CloudRunnerLogger from './cloud-runner/services/cloud-runner-logger';
|
import CloudRunnerLogger from './cloud-runner/services/cloud-runner-logger';
|
||||||
|
import CloudRunner from './cloud-runner/cloud-runner';
|
||||||
|
import CloudRunnerOptions from './cloud-runner/cloud-runner-options';
|
||||||
|
|
||||||
class GitHub {
|
class GitHub {
|
||||||
public static githubInputEnabled: boolean = true;
|
public static githubInputEnabled: boolean = true;
|
||||||
|
private static longDescriptionContent = ``;
|
||||||
|
static startedDate = Date.now();
|
||||||
|
|
||||||
public static async updateGitHubCheck(
|
public static async updateGitHubCheck(summary, longDescription, result = `in_progress`, status = `completed`) {
|
||||||
checkRunId,
|
if (!CloudRunnerOptions.githubChecksEnabled) {
|
||||||
owner,
|
return;
|
||||||
repo,
|
}
|
||||||
token,
|
GitHub.longDescriptionContent += `\n${longDescription}`;
|
||||||
name,
|
const sha = CloudRunner.buildParameters.gitSha;
|
||||||
sha,
|
const name = `Cloud Runner (${CloudRunner.buildParameters.buildGuid})`;
|
||||||
nameReadable,
|
const nameReadable = name;
|
||||||
summary,
|
const token = CloudRunner.buildParameters.gitPrivateToken;
|
||||||
longDescription,
|
const checkRunId = CloudRunner.githubCheckId;
|
||||||
) {
|
const owner = CloudRunnerOptions.githubOwner;
|
||||||
|
const repo = CloudRunnerOptions.githubRepoName;
|
||||||
const octokit = new Octokit({
|
const octokit = new Octokit({
|
||||||
auth: process.env.GITHUB_CHECK_TOKEN || token,
|
auth: process.env.GITHUB_CHECK_TOKEN || token,
|
||||||
});
|
});
|
||||||
|
|
@ -28,21 +33,21 @@ class GitHub {
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
head_sha: sha,
|
head_sha: sha,
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
started_at: '2018-05-04T01:14:52Z',
|
started_at: GitHub.startedDate,
|
||||||
status: `completed`,
|
status,
|
||||||
conclusion: 'success',
|
conclusion: result,
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
completed_at: '2018-05-04T01:14:52Z',
|
completed_at: '2018-05-04T01:14:52Z',
|
||||||
output: {
|
output: {
|
||||||
title: nameReadable,
|
title: nameReadable,
|
||||||
summary,
|
summary,
|
||||||
text: longDescription,
|
text: GitHub.longDescriptionContent,
|
||||||
annotations: [],
|
annotations: [],
|
||||||
images: [
|
images: [
|
||||||
{
|
{
|
||||||
alt: 'Super bananas',
|
alt: 'Game-CI',
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
image_url: 'http://example.com/images/42',
|
image_url: 'https://game.ci/assets/images/game-ci-brand-logo-wordmark.svg',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
@ -51,7 +56,17 @@ class GitHub {
|
||||||
await octokit.request(`PATCH /repos/${owner}/${repo}/check-runs/${checkRunId}`, data);
|
await octokit.request(`PATCH /repos/${owner}/${repo}/check-runs/${checkRunId}`, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async createGitHubCheck(owner, repo, token, name, sha, nameReadable, summary) {
|
public static async createGitHubCheck(summary) {
|
||||||
|
if (!CloudRunnerOptions.githubChecksEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const sha = CloudRunner.buildParameters.gitSha;
|
||||||
|
const name = `Cloud Runner (${CloudRunner.buildParameters.buildGuid})`;
|
||||||
|
const nameReadable = name;
|
||||||
|
const token = CloudRunner.buildParameters.gitPrivateToken;
|
||||||
|
const owner = CloudRunnerOptions.githubOwner;
|
||||||
|
const repo = CloudRunnerOptions.githubRepoName;
|
||||||
|
|
||||||
// call github api to create a check
|
// call github api to create a check
|
||||||
const octokit = new Octokit({
|
const octokit = new Octokit({
|
||||||
auth: process.env.CHECKS_API_TOKEN || token,
|
auth: process.env.CHECKS_API_TOKEN || token,
|
||||||
|
|
@ -69,7 +84,7 @@ class GitHub {
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
external_id: '42',
|
external_id: '42',
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
started_at: '2018-05-04T01:14:52Z',
|
started_at: GitHub.startedDate,
|
||||||
output: {
|
output: {
|
||||||
title: nameReadable,
|
title: nameReadable,
|
||||||
summary,
|
summary,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue