Skip to content

Commit

Permalink
fix job vs id
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGOrtega authored and 0x2b3bfa0 committed Jun 30, 2021
1 parent 22679ea commit eddeae9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion bin/cml-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,11 @@ const runLocal = async (opts) => {
RUNNER_TIMEOUT_TIMER = 0;
} else if (log && log.status === 'job_ended') {
const { job } = log;

if (!RUNNER_SHUTTING_DOWN) {
const jobs = job
? [job]
: (await cml.pipelineJobs({ ids: RUNNER_JOBS_RUNNING }))
: (await cml.pipelineJobs({ jobs: RUNNER_JOBS_RUNNING }))
.filter((job) => job.status === 'completed')
.map((job) => job.id);

Expand Down
18 changes: 9 additions & 9 deletions src/drivers/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,16 @@ class Github {
}

async pipelineJobs(opts = {}) {
const { ids } = opts;
const { jobs: runnerJobs } = opts;
const { owner, repo } = ownerRepo({ uri: this.repo });
const { actions } = octokit(this.token, this.repo);

const jobs = await Promise.all(
ids.map(async (id) => {
runnerJobs.map(async (job) => {
const { data } = await actions.getJobForWorkflowRun({
owner,
repo,
job_id: id
job_id: job.id
});

return data;
Expand Down Expand Up @@ -353,23 +353,23 @@ class Github {
}

async pipelineRestart(opts = {}) {
const { jobId: job_id } = opts;
const { jobId } = opts;
const { owner, repo } = ownerRepo({ uri: this.repo });
const { actions } = octokit(this.token, this.repo);

const {
data: { run_id }
data: { run_id: runId }
} = await actions.getJobForWorkflowRun({
owner,
repo,
job_id
job_id: jobId
});

try {
await actions.cancelWorkflowRun({
owner,
repo,
run_id
run_id: runId
});
} catch (err) {
// HANDLES: Cannot cancel a workflow run that is completed.
Expand All @@ -380,15 +380,15 @@ class Github {
} = await actions.getWorkflowRun({
owner,
repo,
run_id
run_id: runId
});

if (status !== 'queued') {
try {
await actions.reRunWorkflow({
owner,
repo,
run_id
run_id: runId
});
} catch (err) {}
}
Expand Down

2 comments on commit eddeae9

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

Please sign in to comment.