From d0a45166fd24dcea72fdf1b30435fa7ed1c6fd71 Mon Sep 17 00:00:00 2001 From: Nate Fischer Date: Mon, 29 Nov 2021 23:34:38 -0800 Subject: [PATCH] chore: set up GitHub Actions CI (#1055) --- .github/workflows/main.yml | 39 +++++++++++++++++++++++++++++++++++ .travis.yml | 26 ----------------------- CONTRIBUTING.md | 5 ++--- README.md | 5 ++--- appveyor.yml | 32 ---------------------------- scripts/check-node-support.js | 30 ++++++++------------------- 6 files changed, 52 insertions(+), 85 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..72ffd3ea --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,39 @@ +name: CI +on: + - push + - pull_request +jobs: + test: + name: Node.js ${{ matrix.node-version }} on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + node-version: + - 8 + - 9 + - 10 + - 11 + - 12 + - 13 + - 14 + os: + - ubuntu-latest + - macos-latest + - windows-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm run test-with-coverage + - run: npm run lint + - run: npm run gendocs + - run: npm run check-node-support + - name: Check for modified files (skip on Windows) + run: npm run after-travis + if: matrix.os != 'windows-latest' + - uses: codecov/codecov-action@v2 + with: + fail_ci_if_error: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1a3ed7ac..00000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: node_js -sudo: false -node_js: - - 8 - - 9 - - 10 - - 11 - - 12 - - 13 - - 14 - -os: - - linux - - osx -script: - - npm run test-with-coverage - - npm run lint - # make sure when the docs are generated nothing changes (a.k.a. the docs have already been generated) - - npm run gendocs - - npm run check-node-support - - npm run after-travis "Make sure to generate docs!" -after_success: - - npm run codecov -- -f coverage/lcov.info - -notifications: - email: false diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a6b32ba3..1559b4d7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,9 +15,8 @@ stable). If you've found a bug, please follow these steps: PRs are welcome! However, we ask that you follow a few guidelines: - Please add tests for all changes/new features. - - Make sure your code passes `npm test`. Please check the CI (both Appveyor and - Travis). If you can't figure out why something doesn't work, feel free to ask - for help. + - Make sure your code passes `npm test`. Please check the CI. If you can't + figure out why something doesn't work, feel free to ask for help. - Make sure you conform to our style guidelines. You can run `npm run lint` to check style, and `npm run lint -- --fix` to automatically fix some issues. - Make documentation changes *within the source files*, not in the README. diff --git a/README.md b/README.md index 6abf1f97..a87c7afd 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # ShellJS - Unix shell commands for Node.js -[![Travis](https://img.shields.io/travis/shelljs/shelljs/master.svg?style=flat-square&label=unix)](https://travis-ci.org/shelljs/shelljs) -[![AppVeyor](https://img.shields.io/appveyor/ci/shelljs/shelljs/master.svg?style=flat-square&label=windows)](https://ci.appveyor.com/project/shelljs/shelljs/branch/master) +[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fshelljs%2Fshelljs%2Fbadge%3Fref%3Dmaster&style=flat-square)](https://actions-badge.atrox.dev/shelljs/shelljs/goto?ref=master) [![Codecov](https://img.shields.io/codecov/c/github/shelljs/shelljs/master.svg?style=flat-square&label=coverage)](https://codecov.io/gh/shelljs/shelljs) [![npm version](https://img.shields.io/npm/v/shelljs.svg?style=flat-square)](https://www.npmjs.com/package/shelljs) [![npm downloads](https://img.shields.io/npm/dm/shelljs.svg?style=flat-square)](https://www.npmjs.com/package/shelljs) @@ -14,7 +13,7 @@ projects - say goodbye to those gnarly Bash scripts! ShellJS is proudly tested on every node release since `v8`! -The project is [unit-tested](http://travis-ci.org/shelljs/shelljs) and battle-tested in projects like: +The project is unit-tested and battle-tested in projects like: + [Firebug](http://getfirebug.com/) - Firefox's infamous debugger + [JSHint](http://jshint.com) & [ESLint](http://eslint.org/) - popular JavaScript linters diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index bc8becc8..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,32 +0,0 @@ -environment: - matrix: - - nodejs_version: '14' - - nodejs_version: '13' - - nodejs_version: '12' - - nodejs_version: '11' - - nodejs_version: '10' - - nodejs_version: '9' - - nodejs_version: '8' - -version: '{build}' - -# Install scripts. (runs after repo cloning) -install: - - ps: Install-Product node $env:nodejs_version - - set PATH=%APPDATA%\npm;%PATH% - - node --version - - npm --version - - npm install - -matrix: - fast_finish: false - -# No need for MSBuild on this project -build: off - -test_script: - - npm run test-with-coverage - - npm run lint - -on_success: - - npm run codecov -- -f coverage/lcov.info diff --git a/scripts/check-node-support.js b/scripts/check-node-support.js index 31d91228..e2db445d 100755 --- a/scripts/check-node-support.js +++ b/scripts/check-node-support.js @@ -51,21 +51,11 @@ function range(start, stop) { return ret; } -function checkTravis(minNodeVersion, maxNodeVersion, travisYaml) { - var expectedTravisVersions = range(minNodeVersion, maxNodeVersion); - var msg = 'Check Travis node_js versions'; - assertDeepEquals(travisYaml.node_js, expectedTravisVersions, msg); -} - -function checkAppveyor(minNodeVersion, maxNodeVersion, appveyorYaml) { - var expectedAppveyorVersions = range(minNodeVersion, maxNodeVersion) - .map(function (num) { - return { nodejs_version: num.toString() }; - }) - .reverse(); // Arbitrarily, we store appveyor in reverse order. - var msg = 'Check Appveyor environment.matrix versions'; - assertDeepEquals(appveyorYaml.environment.matrix, expectedAppveyorVersions, - msg); +function checkGithubActions(minNodeVersion, maxNodeVersion, githubActionsYaml) { + var expectedVersions = range(minNodeVersion, maxNodeVersion); + var msg = 'Check GitHub Actions node_js versions'; + assertDeepEquals(githubActionsYaml.jobs.test.strategy.matrix['node-version'], + expectedVersions, msg); } try { @@ -74,13 +64,11 @@ try { var package = require('../package.json'); checkEngines(MIN_NODE_VERSION, package); - var travisFileName = path.join(__dirname, '..', '.travis.yml'); - var travisYaml = yaml.safeLoad(shell.cat(travisFileName)); - checkTravis(MIN_NODE_VERSION, MAX_NODE_VERSION, travisYaml); + var githubActionsFileName = path.join(__dirname, '..', '.github', 'workflows', + 'main.yml'); + var githubActionsYaml = yaml.safeLoad(shell.cat(githubActionsFileName)); + checkGithubActions(MIN_NODE_VERSION, MAX_NODE_VERSION, githubActionsYaml); - var appveyorFileName = path.join(__dirname, '..', 'appveyor.yml'); - var appveyorYaml = yaml.safeLoad(shell.cat(appveyorFileName)); - checkAppveyor(MIN_NODE_VERSION, MAX_NODE_VERSION, appveyorYaml); console.log('All files look good (this project supports v' + MIN_NODE_VERSION + '-v' + MAX_NODE_VERSION + ')!'); } catch (e) {