Skip to content

Commit

Permalink
[Tests] migrate tests to Github Actions
Browse files Browse the repository at this point in the history
The OSX tests remain on travis.
  • Loading branch information
ljharb committed Jan 30, 2021
1 parent cecb58b commit 319d0ca
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 92 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/node-4+.yml
@@ -0,0 +1,86 @@
name: 'Tests: node.js'

on: [pull_request, push]

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

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

strategy:
matrix:
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
eslint:
- 7
- 6
- 5
- 4
- 3
- 2
include:
- node-version: 'lts/*'
eslint: 7
ts-parser: 2
env:
TS_PARSER: 2
exclude:
- node-version: 9
eslint: 7
- node-version: 8
eslint: 7
- node-version: 7
eslint: 7
- node-version: 7
eslint: 6
- node-version: 6
eslint: 7
- node-version: 6
eslint: 6
- node-version: 5
eslint: 7
- node-version: 5
eslint: 6
- node-version: 5
eslint: 5
- node-version: 4
eslint: 7
- node-version: 4
eslint: 6
- node-version: 4
eslint: 5

steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
continue-on-error: ${{ matrix.eslint == 4 && matrix.node-version == 4 }}
name: 'npm install && npm run tests-only'
env:
ESLINT_VERSION: ${{ matrix.eslint }}
TRAVIS_NODE_VERSION: ${{ matrix.node-version }}
with:
node-version: ${{ matrix.node-version }}
after_install: npm run copy-metafiles && ./tests/dep-time-travel.sh
command: 'tests-only'
after_success: 'npm run coveralls'
skip-ls-check: true

node:
name: 'node 4+'
needs: [latest]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'
27 changes: 27 additions & 0 deletions .github/workflows/node-pretest.yml
@@ -0,0 +1,27 @@
name: 'Tests: pretest/posttest'

on: [pull_request, push]

jobs:
# pretest:
# runs-on: ubuntu-latest

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

posttest:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run posttest'
with:
node-version: 'lts/*'
command: 'posttest'
skip-ls-check: true
49 changes: 49 additions & 0 deletions .github/workflows/packages.yml
@@ -0,0 +1,49 @@
name: 'Tests: packages'

on: [pull_request, push]

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

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

strategy:
matrix:
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
package:
- resolvers/node
- resolvers/webpack
# - memo-parser
# - utils

steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/run@main
name: 'npm install && npm run tests-only'
with:
node-version: ${{ matrix.node-version }}
after_install: npm run copy-metafiles && cd ${{ matrix.package }} && npm install
command: 'tests-only'
after_success: npm run coveralls
skip-ls-check: true

packages:
name: 'packages: all tests'
needs: [tests]
runs-on: ubuntu-latest
steps:
- run: 'echo tests completed'
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -25,9 +25,13 @@ resolvers/node/LICENSE
resolvers/webpack/LICENSE
utils/LICENSE
memo-parser/.npmrc
memo-parser/.nycrc
resolvers/node/.npmrc
resolvers/node/.nycrc
resolvers/webpack/.npmrc
resolvers/webpack/.nycrc
utils/.npmrc
utils/.nycrc

# Dependency directory
# Commenting this out is preferred by some people, see
Expand Down
15 changes: 15 additions & 0 deletions .nycrc
@@ -0,0 +1,15 @@
{
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"require": [
"babel-register"
],
"sourceMap": true,
"instrument": false,
"exclude": [
"coverage",
"test",
"tests"
]
}
69 changes: 1 addition & 68 deletions .travis.yml
@@ -1,56 +1,8 @@
language: node_js
node_js:
- '14'
- '13'
- '12'
- '10'
- '8'
- '6'
- '4'

os: linux

env:
- ESLINT_VERSION=^7.0.0-0
- ESLINT_VERSION=6
- ESLINT_VERSION=5
- ESLINT_VERSION=4
- ESLINT_VERSION=3
- ESLINT_VERSION=2

# osx backlog is often deep, so to be polite we can just hit these highlights
matrix:
include:
- env: LINT=true
node_js: lts/*
- env: TS_PARSER=2 ESLINT_VERSION=7
node_js: lts/*
before_script: 'npm install --no-save @typescript-eslint/parser@2'
- env: PACKAGE=resolvers/node
node_js: 14
- env: PACKAGE=resolvers/node
node_js: 12
- env: PACKAGE=resolvers/node
node_js: 10
- env: PACKAGE=resolvers/node
node_js: 8
- env: PACKAGE=resolvers/node
node_js: 6
- env: PACKAGE=resolvers/node
node_js: 4
- env: PACKAGE=resolvers/webpack
node_js: 14
- env: PACKAGE=resolvers/webpack
node_js: 12
- env: PACKAGE=resolvers/webpack
node_js: 10
- env: PACKAGE=resolvers/webpack
node_js: 8
- env: PACKAGE=resolvers/webpack
node_js: 6
- env: PACKAGE=resolvers/webpack
node_js: 4

- os: osx
env: ESLINT_VERSION=5
node_js: 14
Expand All @@ -70,37 +22,18 @@ matrix:
env: ESLINT_VERSION=2
node_js: 4

exclude:
- node_js: '4'
env: ESLINT_VERSION=5
- node_js: '4'
env: ESLINT_VERSION=6
- node_js: '4'
env: ESLINT_VERSION=^7.0.0-0
- node_js: '6'
env: ESLINT_VERSION=6
- node_js: '6'
env: ESLINT_VERSION=^7.0.0-0
- node_js: '8'
env: ESLINT_VERSION=^7.0.0-0

fast_finish: true
allow_failures:
# issues with TypeScript deps in this version intersection
- node_js: '4'
env: ESLINT_VERSION=4

before_install:
- 'nvm install-latest-npm'
- 'npm install'
- 'npm run copy-metafiles'
- 'if [ -n "${PACKAGE-}" ]; then cd "${PACKAGE}"; fi'
install:
- 'npm install'
- 'if [ -n "${ESLINT_VERSION}" ]; then ./tests/dep-time-travel.sh; fi'

script:
- 'if [ -n "${LINT-}" ]; then npm run posttest ; else npm run tests-only ; fi'
- npm run tests-only

after_success:
- npm run coveralls
11 changes: 0 additions & 11 deletions package.json
Expand Up @@ -112,16 +112,5 @@
"read-pkg-up": "^2.0.0",
"resolve": "^1.17.0",
"tsconfig-paths": "^3.9.0"
},
"nyc": {
"require": [
"babel-register"
],
"sourceMap": false,
"instrument": false,
"include": [
"src/",
"resolvers/"
]
}
}
7 changes: 1 addition & 6 deletions resolvers/node/package.json
Expand Up @@ -37,11 +37,6 @@
"chai": "^3.5.0",
"coveralls": "^3.0.0",
"mocha": "^3.5.3",
"nyc": "^11.7.1"
},
"nyc": {
"exclude": [
"test/"
]
"nyc": "^11.9.0"
}
}
7 changes: 1 addition & 6 deletions resolvers/webpack/package.json
Expand Up @@ -54,11 +54,6 @@
"chai": "^3.5.0",
"coveralls": "^3.0.0",
"mocha": "^3.5.3",
"nyc": "^11.7.1"
},
"nyc": {
"exclude": [
"test/"
]
"nyc": "^11.9.0"
}
}
1 change: 1 addition & 0 deletions scripts/copyMetafiles.js
Expand Up @@ -5,6 +5,7 @@ import resolverDirectories from './resolverDirectories';
const files = [
'LICENSE',
'.npmrc',
'.nycrc',
];

const directories = [
Expand Down
9 changes: 8 additions & 1 deletion tests/dep-time-travel.sh
Expand Up @@ -2,7 +2,9 @@

# expected: ESLINT_VERSION numeric env var

npm install --no-save eslint@$ESLINT_VERSION --ignore-scripts || true
echo "installing ${ESLINT_VERSION}..."

npm install --no-save "eslint@${ESLINT_VERSION}" --ignore-scripts || true

# completely remove the new TypeScript parser for ESLint < v5
if [[ "$ESLINT_VERSION" -lt "5" ]]; then
Expand All @@ -24,3 +26,8 @@ if [[ "$TRAVIS_NODE_VERSION" -lt "8" ]]; then
echo "Downgrading eslint-import-resolver-typescript..."
npm i --no-save eslint-import-resolver-typescript@1.0.2
fi

if [[ -n "$TS_PARSER" ]]; then
echo "Downgrading @typescript-eslint/parser..."
npm i --no-save @typescript-eslint/parser@2
fi

0 comments on commit 319d0ca

Please sign in to comment.