From eddeae995ab9b5b2ad920f4e9fbbf57eef188e73 Mon Sep 17 00:00:00 2001 From: DavidGOrtega Date: Tue, 29 Jun 2021 12:14:57 +0000 Subject: [PATCH] fix job vs id --- bin/cml-runner.js | 3 ++- src/drivers/github.js | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bin/cml-runner.js b/bin/cml-runner.js index fe5c57821..f8d0443c6 100755 --- a/bin/cml-runner.js +++ b/bin/cml-runner.js @@ -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); diff --git a/src/drivers/github.js b/src/drivers/github.js index 08c904ea9..c4d8f6cbd 100644 --- a/src/drivers/github.js +++ b/src/drivers/github.js @@ -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; @@ -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. @@ -380,7 +380,7 @@ class Github { } = await actions.getWorkflowRun({ owner, repo, - run_id + run_id: runId }); if (status !== 'queued') { @@ -388,7 +388,7 @@ class Github { await actions.reRunWorkflow({ owner, repo, - run_id + run_id: runId }); } catch (err) {} }