Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
frostebite committed Jan 27, 2024
1 parent 71f94af commit aaeb1d1
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 78 deletions.
69 changes: 34 additions & 35 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.

1 change: 0 additions & 1 deletion src/model/cloud-runner/cloud-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ class CloudRunner {
),
);
await CloudRunner.Provider.cleanupWorkflow(
CloudRunner.buildParameters.buildGuid,
CloudRunner.buildParameters,
CloudRunner.buildParameters.branch,
CloudRunner.defaultSecrets,
Expand Down
7 changes: 1 addition & 6 deletions src/model/cloud-runner/error/cloud-runner-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ export class CloudRunnerError {
CloudRunnerLogger.error(JSON.stringify(error, undefined, 4));
core.setFailed('Cloud Runner failed');
if (CloudRunner.Provider !== undefined) {
await CloudRunner.Provider.cleanupWorkflow(
buildParameters.buildGuid,
buildParameters,
buildParameters.branch,
secrets,
);
await CloudRunner.Provider.cleanupWorkflow(buildParameters, buildParameters.branch, secrets);
}
}
}
2 changes: 0 additions & 2 deletions src/model/cloud-runner/providers/aws/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ class AWSBuildEnvironment implements ProviderInterface {
}

async cleanupWorkflow(
// eslint-disable-next-line no-unused-vars
buildGuid: string,
// eslint-disable-next-line no-unused-vars
buildParameters: BuildParameters,
// eslint-disable-next-line no-unused-vars
Expand Down
1 change: 0 additions & 1 deletion src/model/cloud-runner/providers/docker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class LocalDockerCloudRunner implements ProviderInterface {
return new Promise((result) => result(``));
}
async cleanupWorkflow(
buildGuid: string,
buildParameters: BuildParameters,
// eslint-disable-next-line no-unused-vars
branchName: string,
Expand Down
1 change: 0 additions & 1 deletion src/model/cloud-runner/providers/k8s/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ class Kubernetes implements ProviderInterface {
}

async cleanupWorkflow(
buildGuid: string,
buildParameters: BuildParameters,
// eslint-disable-next-line no-unused-vars
branchName: string,
Expand Down
2 changes: 0 additions & 2 deletions src/model/cloud-runner/providers/local/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class LocalCloudRunner implements ProviderInterface {
throw new Error('Method not implemented.');
}
cleanupWorkflow(
// eslint-disable-next-line no-unused-vars
buildGuid: string,
// eslint-disable-next-line no-unused-vars
buildParameters: BuildParameters,
// eslint-disable-next-line no-unused-vars
Expand Down
2 changes: 0 additions & 2 deletions src/model/cloud-runner/providers/provider-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { ProviderWorkflow } from './provider-workflow';

export interface ProviderInterface {
cleanupWorkflow(
// eslint-disable-next-line no-unused-vars
buildGuid: string,
// eslint-disable-next-line no-unused-vars
buildParameters: BuildParameters,
// eslint-disable-next-line no-unused-vars
Expand Down
2 changes: 0 additions & 2 deletions src/model/cloud-runner/providers/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class TestCloudRunner implements ProviderInterface {
throw new Error('Method not implemented.');
}
cleanupWorkflow(
// eslint-disable-next-line no-unused-vars
buildGuid: string,
// eslint-disable-next-line no-unused-vars
buildParameters: BuildParameters,
// eslint-disable-next-line no-unused-vars
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('Cloud Runner Caching', () => {
targetPlatform: 'StandaloneLinux64',
cacheKey: `test-case-${uuidv4()}`,
containerHookFiles: `debug-cache`,
cloudRunnerBranch: `cloud-runner-develop`,
};
if (CloudRunnerOptions.providerStrategy === `k8s`) {
overrides.containerHookFiles += `,aws-s3-pull-cache,aws-s3-upload-cache`;
Expand Down
54 changes: 29 additions & 25 deletions src/model/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,36 +175,40 @@ class GitHub {

static async triggerWorkflowOnComplete(triggerWorkflowOnComplete: string[]) {
const isLocalAsync = CloudRunner.buildParameters.asyncWorkflow && !CloudRunner.isCloudRunnerAsyncEnvironment;
if (isLocalAsync) {
if (isLocalAsync || triggerWorkflowOnComplete === undefined || triggerWorkflowOnComplete.length === 0) {
return;
}
const workflowsResult = await GitHub.octokitPAT.request(`GET /repos/{owner}/{repo}/actions/workflows`, {
owner: GitHub.owner,
repo: GitHub.repo,
});
const workflows = workflowsResult.data.workflows;
CloudRunnerLogger.log(`Got ${workflows.length} workflows`);
for (const element of triggerWorkflowOnComplete) {
let selectedId = ``;
for (let index = 0; index < workflowsResult.data.total_count; index++) {
if (workflows[index].name === element) {
selectedId = workflows[index].id.toString();
}
}
if (selectedId === ``) {
core.info(JSON.stringify(workflows));
throw new Error(`no workflow with name "${GitHub.asyncChecksApiWorkflowName}"`);
}
await GitHub.octokitPAT.request(`POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches`, {
try {
const workflowsResult = await GitHub.octokitPAT.request(`GET /repos/{owner}/{repo}/actions/workflows`, {
owner: GitHub.owner,
repo: GitHub.repo,
// eslint-disable-next-line camelcase
workflow_id: selectedId,
ref: CloudRunnerOptions.branch,
inputs: {
buildGuid: CloudRunner.buildParameters.buildGuid,
},
});
const workflows = workflowsResult.data.workflows;
CloudRunnerLogger.log(`Got ${workflows.length} workflows`);
for (const element of triggerWorkflowOnComplete) {
let selectedId = ``;
for (let index = 0; index < workflowsResult.data.total_count; index++) {
if (workflows[index].name === element) {
selectedId = workflows[index].id.toString();
}
}
if (selectedId === ``) {
core.info(JSON.stringify(workflows));
throw new Error(`no workflow with name "${GitHub.asyncChecksApiWorkflowName}"`);
}
await GitHub.octokitPAT.request(`POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches`, {
owner: GitHub.owner,
repo: GitHub.repo,
// eslint-disable-next-line camelcase
workflow_id: selectedId,
ref: CloudRunnerOptions.branch,
inputs: {
buildGuid: CloudRunner.buildParameters.buildGuid,
},
});
}
} catch {
core.info(`github workflow complete hook not found`);
}
}
}
Expand Down

0 comments on commit aaeb1d1

Please sign in to comment.