Skip to content

Commit

Permalink
test: migrate travis-ci to Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Oct 10, 2021
1 parent 4b6e9df commit 563399d
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 57 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/node-pretest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Tests: pretest/posttest'

on: [pull_request, push]

jobs:
pretest:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@main
name: 'nvm install lts/* && npm install'
with:
node-version: 'lts/*'
- run: npm run pretest

# posttest:
# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v2
# - uses: ljharb/actions/node/install@main
# name: 'nvm install lts/* && npm install'
# with:
# node-version: 'lts/*'
# - run: npm run posttest
83 changes: 83 additions & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: 'Tests: node.js'

on: [pull_request, push]

jobs:
matrix:
runs-on: ubuntu-latest
outputs:
majors: ${{ steps.set-matrix.outputs.requireds }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
versionsAsRoot: true
type: 'majors'
preset: '>=10'

majors:
needs: [matrix]
name: 'latest majors'
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node-version: ${{ fromJson(needs.matrix.outputs.majors) }}
eslint:
- 7
- 6
- 5
- 4
- 3
include:
- node-version: 14
eslint: 7.7
- node-version: 8
eslint: 6
- node-version: 8
eslint: 5
- node-version: 8
eslint: 4
- node-version: 8
eslint: 3
- node-version: 6
eslint: 5
ajv: 5
- node-version: 6
eslint: 4
- node-version: 6
eslint: 3
- node-version: 4
eslint: 4
- node-version: 4
eslint: 3

steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@main
name: 'nvm install ${{ matrix.node-version }} && npm install'
with:
node-version: ${{ matrix.node-version }}
skip-ls-check: true
- run: npm install --no-save eslint@${{ matrix.eslint }}
- run: npm install --no-save "ajv@${{ matrix.ajv }}"
if: ${{ !!matrix.ajv }}
- run: npm install --no-save "ajv@5"
if: ${{ !matrix.ajv && matrix.eslint == 4 }}
- run: npm install --no-save "ajv@6"
if: ${{ !matrix.ajv && matrix.eslint == 5 }}
- run: npm prune > /dev/null
- run: npm ls > /dev/null
- run: npm uninstall --no-save @eslint/eslintrc
if: ${{ matrix.eslint < 7 || matrix.eslint == 7.7 }} # < 7.12, actually
- run: npm run cover
- run: npm run check-coverage
- uses: codecov/codecov-action@v2

node:
name: 'node 10+'
needs: [majors]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'
12 changes: 12 additions & 0 deletions .github/workflows/require-allow-edits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Require “Allow Edits”

on: [pull_request_target]

jobs:
_:
name: "Require “Allow Edits”"

runs-on: ubuntu-latest

steps:
- uses: ljharb/require-allow-edits@main
49 changes: 0 additions & 49 deletions .travis.yml

This file was deleted.

15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
"description": "Find built-in ESLint rules you don't have in your custom config.",
"main": "dist/lib/rule-finder.js",
"scripts": {
"cover": "nyc --reporter=lcov --reporter=text --reporter=html npm test",
"cover": "nyc --reporter=lcov --reporter=text --reporter=html npm run tests-only",
"lint": "eslint --ext .js,.json .",
"test": "mocha --recursive",
"pretest": "npm run lint",
"tests-only": "mocha --recursive",
"test": "npm run tests-only",
"posttest": "aud --production",
"update-contributors": "all-contributors generate",
"commit": "git-cz",
"validate": "npm-run-all --parallel lint cover --sequential check-coverage",
"check-coverage": "nyc check-coverage --statements 100 --branches 100 --functions 100 --lines 100",
"prebuild": "rimraf dist",
"build": "babel src -d dist",
"prepublish": "npm run build",
"report-coverage": "cat ./coverage/lcov.info | node_modules/.bin/codecov",
"travis-after-all": "travis-after-all && npm run report-coverage"
"prepublish": "not-in-publish || npm run build"
},
"bin": {
"eslint-find-rules": "dist/bin/find.js",
Expand All @@ -42,6 +43,7 @@
"devDependencies": {
"ajv": "^5 || ^6",
"all-contributors-cli": "^4.11.2",
"aud": "^1.1.5",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-preset-es2015": "^6.24.1",
Expand All @@ -51,14 +53,15 @@
"eslint": "^3.12.0 || ^4 || ^5 || ^6 || ^7",
"eslint-plugin-json": "^2.1.2",
"ghooks": "^2.0.4",
"in-publish": "^2.0.1",
"mocha": "^3.5.3",
"npm-run-all": "^4.1.5",
"nyc": "^11.9.0",
"opt-cli": "^1.6.0",
"proxyquire": "^1.8.0",
"rimraf": "^2.7.1",
"semver": "^6.3.0",
"sinon": "^2.4.1",
"travis-after-all": "^1.4.5",
"validate-commit-msg": "^2.14.0"
},
"peerDependencies": {
Expand Down
6 changes: 4 additions & 2 deletions test/lib/rule-finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ try {

const processCwd = process.cwd;

const eslintVersion = process.env.ESLINT === '3' || process.env.ESLINT === '4' ? 'prior-v5' : 'post-v5';
const supportsScopedPlugins = process.env.ESLINT !== '3' && process.env.ESLINT !== '4';
const eslintPkg = require('eslint/package.json');
const semver = require('semver');
const eslintVersion = semver.satisfies(eslintPkg.version, '< 5') ? 'prior-v5' : 'post-v5';
const supportsScopedPlugins = semver.satisfies(eslintPkg.version, '>= 5');

const moduleResolver = {
resolve(name, relative) {
Expand Down

0 comments on commit 563399d

Please sign in to comment.