Skip to content

Commit

Permalink
workaround sporadic I/O lags in GitHub Actions (#5612)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl authored Aug 9, 2022
1 parent 9d37276 commit 6c0e522
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
env:
NODE: ${{ matrix.node }}
TYPE: ${{ matrix.script }}
UGLIFY_GITHUB_LAG: 10000
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
Expand Down
20 changes: 11 additions & 9 deletions test/mocha.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
var fs = require("fs");

var config = {
limit: 10000,
timeout: function(limit) {
this.limit = limit;
}
this.limit = limit + lag;
},
};
var lag = +process.env["UGLIFY_GITHUB_LAG"] || 0;
var tasks = [];
var titles = [];
config.timeout(10000);
describe = function(title, fn) {
config = Object.create(config);
titles.push(title);
Expand All @@ -21,10 +22,11 @@ it = function(title, fn) {
fn.titles.push(title);
tasks.push(fn);
};

fs.readdirSync("test/mocha").filter(function(file) {
return /\.js$/.test(file);
}).forEach(function(file) {
(function(arg) {
return arg ? [ arg ] : fs.readdirSync("test/mocha").filter(function(file) {
return /\.js$/.test(file);
});
})(process.argv[2]).forEach(function(file) {
require("./mocha/" + file);
});

Expand Down Expand Up @@ -66,12 +68,12 @@ process.nextTick(function run() {
if (task.length) {
task.timeout = function(limit) {
clearTimeout(timer);
task.limit = limit;
task.limit = limit + lag;
timer = setTimeout(function() {
raise(new Error("Timed out: exceeds " + limit + "ms"));
}, limit);
};
task.timeout(task.limit);
task.timeout(task.limit - lag);
process.on("uncaughtException", raise);
task.call(task, done);
} else {
Expand Down

0 comments on commit 6c0e522

Please sign in to comment.