chore: set up GitHub Actions CI (#1055)

This commit is contained in:
Nate Fischer 2021-11-29 23:34:38 -08:00 committed by GitHub
parent 0ae1dd681e
commit d0a45166fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 52 additions and 85 deletions

39
.github/workflows/main.yml vendored Normal file
View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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 <!-- start minVersion -->`v8`<!-- stop minVersion -->!
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

View File

@ -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

View File

@ -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) {