From 94e39d9f782f45db86a079e07508d63040118ef1 Mon Sep 17 00:00:00 2001 From: Toru Nagashima Date: Sat, 31 Aug 2019 04:05:48 +0900 Subject: [PATCH] Chore: use GitHub Actions (#12144) * Chore: use GitHub Actions * fix syntax error * fix syntax error * fix fuzz test * change triggers * remove badge * add badge * re-add Azure Pipelines files and badge --- .github/workflows/ci.yml | 63 ++++++++++++++++++++++++++++++++++++++++ Makefile.js | 35 ++++++++++++---------- README.md | 1 + 3 files changed, 84 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000..0667729f801 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,63 @@ +name: CI +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + verify_files: + name: Verify Files + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + - name: Install Packages + run: npm install + - name: Lint Files + run: node Makefile lint + - name: Check Rule Files + run: node Makefile checkRuleFiles + - name: Check Licenses + run: node Makefile checkLicenses + + test_on_node: + name: Test + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + node: [8.x, 10.x, 12.x] + exclude: + - os: windows-latest + node: 8.x + - os: windows-latest + node: 10.x + - os: macOS-latest + node: 8.x + - os: macOS-latest + node: 10.x + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + version: ${{ matrix.node }} + - name: Install Packages + run: npm install + - name: Test + run: node Makefile mocha + - name: Fuzz Test + run: node Makefile fuzz + + test_on_browser: + name: Browser Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + - name: Install Packages + run: npm install + - name: Test + run: node Makefile karma + - name: Fuzz Test + run: node Makefile fuzz diff --git a/Makefile.js b/Makefile.js index 02386d2f461..a01d13bde30 100644 --- a/Makefile.js +++ b/Makefile.js @@ -497,7 +497,7 @@ target.lint = function() { } }; -target.fuzz = function({ amount = process.env.CI ? 1000 : 300, fuzzBrokenAutofixes = true } = {}) { +target.fuzz = function({ amount = 1000, fuzzBrokenAutofixes = false } = {}) { const fuzzerRunner = require("./tools/fuzzer-runner"); const fuzzResults = fuzzerRunner.run({ amount, fuzzBrokenAutofixes }); @@ -536,18 +536,13 @@ target.fuzz = function({ amount = process.env.CI ? 1000 : 300, fuzzBrokenAutofix } }; -target.test = function() { - target.lint(); - target.checkRuleFiles(); +target.mocha = () => { let errors = 0, lastReturn; echo("Running unit tests"); - // In CI (Azure Pipelines), use JUnit reporter. - const reporter = process.env.TF_BUILD ? "mocha-junit-reporter" : "progress"; - - lastReturn = exec(`${getBinFile("nyc")} -- ${MOCHA} -R ${reporter} -t ${MOCHA_TIMEOUT} -c ${TEST_FILES}`); + lastReturn = exec(`${getBinFile("nyc")} -- ${MOCHA} -R progress -t ${MOCHA_TIMEOUT} -c ${TEST_FILES}`); if (lastReturn.code !== 0) { errors++; } @@ -557,6 +552,14 @@ target.test = function() { errors++; } + if (errors) { + exit(1); + } +}; + +target.karma = () => { + echo("Running unit tests on browsers"); + target.webpack(); const browserFileLintOutput = new CLIEngine({ @@ -569,20 +572,22 @@ target.test = function() { if (browserFileLintOutput.errorCount > 0) { echo(`error: Failed to lint ${BUILD_DIR}/eslint.js as ES5 code`); echo(CLIEngine.getFormatter("stylish")(browserFileLintOutput.results)); - errors++; + exit(1); } - lastReturn = exec(`${getBinFile("karma")} start karma.conf.js`); - if (lastReturn.code !== 0) { - errors++; - } + const lastReturn = exec(`${getBinFile("karma")} start karma.conf.js`); - if (errors) { + if (lastReturn.code !== 0) { exit(1); } +}; +target.test = function() { + target.lint(); + target.checkRuleFiles(); + target.mocha(); + target.karma(); target.fuzz({ amount: 150, fuzzBrokenAutofixes: false }); - target.checkLicenses(); }; diff --git a/README.md b/README.md index 7ed0416c33d..134c991d81d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![NPM version][npm-image]][npm-url] [![Build Status](https://dev.azure.com/eslint/eslint/_apis/build/status/eslint.eslint?branchName=master)](https://dev.azure.com/eslint/eslint/_build/latest?definitionId=1&branchName=master) +[![Build Status](https://github.com/eslint/eslint/workflows/CI/badge.svg)](https://github.com/eslint/eslint/actions) [![Downloads][downloads-image]][downloads-url] [![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=282608)](https://www.bountysource.com/trackers/282608-eslint?utm_source=282608&utm_medium=shield&utm_campaign=TRACKER_BADGE) [![Join the chat at https://gitter.im/eslint/eslint](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/eslint/eslint?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)