enable GitHub Actions (#3503)
authorAlex Lam S.L <alexlamsl@gmail.com>
Sun, 20 Oct 2019 20:11:14 +0000 (04:11 +0800)
committerGitHub <noreply@github.com>
Sun, 20 Oct 2019 20:11:14 +0000 (04:11 +0800)
.github/workflows/ci.yml [new file with mode: 0644]
.github/workflows/ufuzz.yml [new file with mode: 0644]
test/compress.js
test/ufuzz/index.js [moved from test/ufuzz.js with 99% similarity]
test/ufuzz/job.js [new file with mode: 0644]
test/ufuzz/options.json [moved from test/ufuzz.json with 100% similarity]
test/ufuzz/travis.js [moved from test/travis-ufuzz.js with 51% similarity]

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644 (file)
index 0000000..229f2dd
--- /dev/null
@@ -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 (file)
index 0000000..9153a1e
--- /dev/null
@@ -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
index 7fdedd1..c2e747c 100644 (file)
@@ -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) {
similarity index 99%
rename from test/ufuzz.js
rename to test/ufuzz/index.js
index 8612547..8f86e49 100644 (file)
@@ -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 (file)
index 0000000..921162f
--- /dev/null
@@ -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);
+    }
+}
similarity index 100%
rename from test/ufuzz.json
rename to test/ufuzz/options.json
similarity index 51%
rename from test/travis-ufuzz.js
rename to test/ufuzz/travis.js
index 22dcca9..0c1b8c7 100644 (file)
@@ -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 <token> [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 <token> [branch] [repository] [concurrency] [platform]");
 }