From: Alex Lam S.L Date: Sun, 20 Oct 2019 20:11:14 +0000 (+0800) Subject: enable GitHub Actions (#3503) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=5bd0cf8633d32a4b71be5654a04e353d3f86324e;p=UglifyJS.git enable GitHub Actions (#3503) --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..229f2dd9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: CI +on: [ push, pull_request ] +jobs: + test: + strategy: + matrix: + os: [ ubuntu-latest, windows-latest ] + node: [ "0.10", 0.12, 4, 6, 8, 10, latest ] + script: [ compress, mocha, release/benchmark, release/jetstream ] + name: ${{ matrix.os }} ${{ matrix.node }} ${{ matrix.script }} + runs-on: ${{ matrix.os }} + env: + NODE: ${{ matrix.node }} + TYPE: ${{ matrix.script }} + steps: + - uses: actions/checkout@v1 + - shell: bash + run: | + git clone --branch v1.5.2 --depth 1 https://github.com/jasongin/nvs.git ~/.nvs + . ~/.nvs/nvs.sh + nvs --version + nvs add node/$NODE + nvs use node/$NODE + node --version + npm --version --no-update-notifier + npm install --no-audit --no-optional --no-save --no-update-notifier + node test/$TYPE diff --git a/.github/workflows/ufuzz.yml b/.github/workflows/ufuzz.yml new file mode 100644 index 00000000..9153a1ec --- /dev/null +++ b/.github/workflows/ufuzz.yml @@ -0,0 +1,24 @@ +name: Fuzzing +on: + schedule: + - cron: "*/15 * * * *" +jobs: + ufuzz: + strategy: + matrix: + os: [ ubuntu-latest, windows-latest ] + name: ${{ matrix.os }} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v1 + - shell: bash + run: | + git clone --branch v1.5.2 --depth 1 https://github.com/jasongin/nvs.git ~/.nvs + . ~/.nvs/nvs.sh + nvs --version + nvs add node/$NODE + nvs use node/$NODE + node --version + npm --version --no-update-notifier + npm install --no-audit --no-optional --no-save --no-update-notifier + node test/ufuzz/job 3600000 diff --git a/test/compress.js b/test/compress.js index 7fdedd12..c2e747cd 100644 --- a/test/compress.js +++ b/test/compress.js @@ -9,7 +9,7 @@ var U = require("./node"); var file = process.argv[2]; var dir = path.resolve(path.dirname(module.filename), "compress"); if (file) { - var minify_options = require("./ufuzz.json").map(JSON.stringify); + var minify_options = require("./ufuzz/options.json").map(JSON.stringify); log("--- {file}", { file: file }); var tests = parse_test(path.resolve(dir, file)); process.exit(Object.keys(tests).filter(function(name) { diff --git a/test/ufuzz.js b/test/ufuzz/index.js similarity index 99% rename from test/ufuzz.js rename to test/ufuzz/index.js index 86125477..8f86e49c 100644 --- a/test/ufuzz.js +++ b/test/ufuzz/index.js @@ -1,4 +1,3 @@ -// ufuzz.js // derived from https://github.com/qfox/uglyfuzzer by Peter van der Zee "use strict"; @@ -6,11 +5,11 @@ // bin/uglifyjs s.js -c && bin/uglifyjs s.js -c passes=3 && bin/uglifyjs s.js -c passes=3 -m // cat s.js | node && node s.js && bin/uglifyjs s.js -c | node && bin/uglifyjs s.js -c passes=3 | node && bin/uglifyjs s.js -c passes=3 -m | node -require("../tools/exit"); +require("../../tools/exit"); -var UglifyJS = require(".."); +var UglifyJS = require("../.."); var randomBytes = require("crypto").randomBytes; -var sandbox = require("./sandbox"); +var sandbox = require("../sandbox"); var MAX_GENERATED_TOPLEVELS_PER_RUN = 1; var MAX_GENERATION_RECURSION_DEPTH = 12; @@ -1088,7 +1087,7 @@ var fallback_options = [ JSON.stringify({ compress: false, mangle: false }) ]; -var minify_options = require("./ufuzz.json").map(JSON.stringify); +var minify_options = require("./options.json").map(JSON.stringify); var original_code, original_result, errored; var uglify_code, uglify_result, ok; for (var round = 1; round <= num_iterations; round++) { diff --git a/test/ufuzz/job.js b/test/ufuzz/job.js new file mode 100644 index 00000000..921162f6 --- /dev/null +++ b/test/ufuzz/job.js @@ -0,0 +1,39 @@ +var child_process = require("child_process"); + +var ping = 5 * 60 * 1000; +var period = +process.argv[2]; +var endTime = Date.now() + period; +for (var i = 0; i < 2; i++) spawn(endTime); + +function spawn(endTime) { + var child = child_process.spawn("node", [ + "--max-old-space-size=2048", + "test/ufuzz" + ], { + stdio: [ "ignore", "pipe", "pipe" ] + }).on("exit", respawn); + var line = ""; + child.stdout.on("data", function(data) { + line += data; + }); + child.stderr.once("data", function() { + process.exitCode = 1; + }).pipe(process.stdout); + var keepAlive = setInterval(function() { + var end = line.lastIndexOf("\r"); + console.log(line.slice(line.lastIndexOf("\r", end - 1) + 1, end)); + line = line.slice(end + 1); + }, ping); + var timer = setTimeout(function() { + clearInterval(keepAlive); + child.removeListener("exit", respawn); + child.kill(); + }, endTime - Date.now()); + + function respawn() { + console.log(line); + clearInterval(keepAlive); + clearTimeout(timer); + spawn(endTime); + } +} diff --git a/test/ufuzz.json b/test/ufuzz/options.json similarity index 100% rename from test/ufuzz.json rename to test/ufuzz/options.json diff --git a/test/travis-ufuzz.js b/test/ufuzz/travis.js similarity index 51% rename from test/travis-ufuzz.js rename to test/ufuzz/travis.js index 22dcca93..0c1b8c7c 100644 --- a/test/travis-ufuzz.js +++ b/test/ufuzz/travis.js @@ -6,13 +6,9 @@ var url = require("url"); var period = 45 * 60 * 1000; var wait = 2 * 60 * 1000; -var ping = 5 * 60 * 1000; -if (process.argv[2] == "run") { - var endTime = Date.now() + period; - for (var i = 0; i < 2; i++) spawn(endTime); -} else if (process.argv.length > 2) { +if (process.argv.length > 2) { var token = process.argv[2]; - var branch = process.argv[3] || "v" + require("../package.json").version; + var branch = process.argv[3] || "v" + require("../../package.json").version; var repository = encodeURIComponent(process.argv[4] || "mishoo/UglifyJS2"); var concurrency = process.argv[5] || 1; var platform = process.argv[6] || "latest"; @@ -38,44 +34,11 @@ if (process.argv[2] == "run") { config: { cache: false, env: "NODE=" + platform, - script: "node test/travis-ufuzz run" + script: "node test/ufuzz/job " + period } } })); })(); } else { - console.log("Usage: test/travis-ufuzz.js [branch] [repository] [concurrency] [platform]"); -} - -function spawn(endTime) { - var child = child_process.spawn("node", [ - "--max-old-space-size=2048", - "test/ufuzz" - ], { - stdio: [ "ignore", "pipe", "pipe" ] - }).on("exit", respawn); - var line = ""; - child.stdout.on("data", function(data) { - line += data; - }); - child.stderr.on("data", function() { - process.exitCode = 1; - }).pipe(process.stdout); - var keepAlive = setInterval(function() { - var end = line.lastIndexOf("\r"); - console.log(line.slice(line.lastIndexOf("\r", end - 1) + 1, end)); - line = line.slice(end + 1); - }, ping); - var timer = setTimeout(function() { - clearInterval(keepAlive); - child.removeListener("exit", respawn); - child.kill(); - }, endTime - Date.now()); - - function respawn() { - console.log(line); - clearInterval(keepAlive); - clearTimeout(timer); - spawn(endTime); - } + console.log("Usage: test/ufuzz/travis.js [branch] [repository] [concurrency] [platform]"); }