workaround quirks from GitHub Actions (#5630)
This commit is contained in:
@@ -9,8 +9,7 @@ exports.init = function(url, auth, num) {
|
|||||||
};
|
};
|
||||||
exports.should_stop = function(callback) {
|
exports.should_stop = function(callback) {
|
||||||
read(base + "/actions/runs?per_page=100", function(reply) {
|
read(base + "/actions/runs?per_page=100", function(reply) {
|
||||||
if (!reply || !Array.isArray(reply.workflow_runs)) return;
|
var runs = verify(reply, "workflow_runs").sort(function(a, b) {
|
||||||
var runs = reply.workflow_runs.sort(function(a, b) {
|
|
||||||
return b.run_number - a.run_number;
|
return b.run_number - a.run_number;
|
||||||
});
|
});
|
||||||
var found = false, remaining = 20;
|
var found = false, remaining = 20;
|
||||||
@@ -22,8 +21,7 @@ exports.should_stop = function(callback) {
|
|||||||
if (is_cron(workflow) && workflow.run_number == run_number) found = true;
|
if (is_cron(workflow) && workflow.run_number == run_number) found = true;
|
||||||
} while (!found && workflow.status == "completed");
|
} while (!found && workflow.status == "completed");
|
||||||
read(workflow.jobs_url, function(reply) {
|
read(workflow.jobs_url, function(reply) {
|
||||||
if (!reply || !Array.isArray(reply.jobs)) return;
|
if (!verify(reply, "jobs").every(function(job) {
|
||||||
if (!reply.jobs.every(function(job) {
|
|
||||||
if (job.status == "completed") return true;
|
if (job.status == "completed") return true;
|
||||||
remaining--;
|
remaining--;
|
||||||
return found || !is_cron(workflow);
|
return found || !is_cron(workflow);
|
||||||
@@ -70,3 +68,12 @@ function read(url, callback) {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function verify(reply, field) {
|
||||||
|
if (!reply) return [];
|
||||||
|
var values = reply[field];
|
||||||
|
if (!Array.isArray(values)) return [];
|
||||||
|
return values.filter(function(value) {
|
||||||
|
return value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,13 +20,9 @@ switch (process.argv.length) {
|
|||||||
var tasks = [ run(), run() ];
|
var tasks = [ run(), run() ];
|
||||||
if (iterations) return;
|
if (iterations) return;
|
||||||
var alive = setInterval(function() {
|
var alive = setInterval(function() {
|
||||||
actions.should_stop(function() {
|
actions.should_stop(stop);
|
||||||
clearInterval(alive);
|
|
||||||
tasks.forEach(function(kill) {
|
|
||||||
kill();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}, 8 * 60 * 1000);
|
}, 8 * 60 * 1000);
|
||||||
|
var deadline = setTimeout(stop, (5 * 60 + 55) * 60 * 1000);
|
||||||
|
|
||||||
function run() {
|
function run() {
|
||||||
var child, stdout, stderr, log;
|
var child, stdout, stderr, log;
|
||||||
@@ -76,3 +72,11 @@ function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stop() {
|
||||||
|
clearInterval(alive);
|
||||||
|
clearInterval(deadline);
|
||||||
|
tasks.forEach(function(kill) {
|
||||||
|
kill();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user