Skip to content

Commit

Permalink
run all node.js tests on GHA (mochajs#4459)
Browse files Browse the repository at this point in the history
- disables `node_modules` cache on windows cuz its slow
- adds annotation support for Mocha tests (via https://npm.im/mocha-github-actions-reporter) and ESLint checks
- `::add-path::` is deprecated, but the suggested migration does not work; see [ongoing discussion](https://github.community/t/migration-from-deprecated-add-path-on-windows/136265)
- (tangential) add a success threshold to bothersome OC image downloader script; fail production deploys for this reason & do not fail others
  • Loading branch information
boneskull authored Oct 7, 2020
1 parent 238268d commit df8e9e6
Show file tree
Hide file tree
Showing 6 changed files with 253 additions and 169 deletions.
202 changes: 202 additions & 0 deletions .github/workflows/mocha.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
name: Tests
'on':
push:
pull_request:
types:
- opened
- synchronize
- closed
- reopened
# see https://github.com/bradennapier/eslint-plus-action#handle-forked-prs
schedule:
- cron: '*/15 * * * *'

jobs:
prepare-commit-msg:
name: Retrive head commit message
runs-on: ubuntu-latest
outputs:
HEAD_COMMIT_MSG: '${{ steps.commitMsg.outputs.HEAD_COMMIT_MSG }}'
steps:
- uses: actions/checkout@v2
if: github.event_name == 'pull_request'
- name: find commit msg for PR
id: commitMsg
if: github.event_name == 'pull_request'
run: >-
echo "::set-output name=HEAD_COMMIT_MSG::$(git log --no-merges -1
--oneline)"
check-skip:
name: Check to skip CI
needs: prepare-commit-msg
runs-on: ubuntu-latest
if: >-
${{ !contains(github.event.head_commit.message, '[ci skip]') &&
!contains(needs.prepare-commit-msg.outputs.HEAD_COMMIT_MSG, '[ci skip]')
}}
steps:
- run: 'echo "${{ github.event.head_commit.message }}"'

smoke:
name: 'Smoke [Node.js v${{ matrix.node }} / ${{ matrix.os }}]'
needs: check-skip
runs-on: '${{ matrix.os }}'
strategy:
matrix:
os:
- ubuntu-latest
- windows-2019
node:
- 10
- 12
- 14
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '${{ matrix.node }}'
- run: npm install --production
- run: npm run test:smoke

eslint:
name: ESLint Check
runs-on: ubuntu-latest
needs: smoke
steps:
- uses: actions/checkout@v2
- uses: bradennapier/[email protected]
with:
issueSummary: false
npmInstall: false

markdown:
name: Markdown Check
runs-on: ubuntu-latest
needs: smoke
steps:
- uses: actions/setup-node@v1
with:
node-version: 14
- uses: actions/checkout@v2
- name: 'Cache node_modules'
uses: actions/cache@v2
with:
path: '~/.npm'
key: "ubuntu-latest-node-v14-${{ hashFiles('**/package-lock.json') }}"
restore-keys: |
ubuntu-latest-node-v14-
- name: Install Dependencies
run: npm ci --ignore-scripts
- name: 'Check Markdown'
run: npm start lint.markdown

test-node:
name: 'Node.js [v${{ matrix.node }} / ${{ matrix.os }}]'
needs: smoke
runs-on: '${{ matrix.os }}'
env:
NODE_OPTIONS: '--trace-warnings'
strategy:
matrix:
os:
- ubuntu-latest
- windows-2019
node:
- 10
- 12
- 14
include:
- os: ubuntu-latest
node: 14
env:
COVERAGE: 1
steps:
- name: Cache Growl Installer (Windows)
if: "${{ matrix.os == 'windows-2019' }}"
id: cache-growl
uses: actions/cache@v2
with:
path: GrowlInstaller
key: '${{ runner.os }}-growl-installer'
restore-keys: |
${{ runner.os }}-growl-installer
- name: Download Growl Installer (Windows)
if: "${{ matrix.os == 'windows-2019' && steps.cache-growl.outputs.cache-hit != 'true'}}"
run: >
echo "Downloading Growl installer..."
mkdir GrowlInstaller | out-null
$seaURL =
"https://github.com/briandunnington/growl-for-windows/releases/download/final/GrowlInstaller.exe"
$seaPath = "GrowlInstaller\GrowlInstaller.exe"
$webclient = New-Object Net.WebClient
$webclient.DownloadFile($seaURL, $seaPath)
7z x $seaPath -oGrowlInstaller | out-null
echo "Done."
- name: Retrieve Growl Installer (Windows)
if: "${{ matrix.os == 'windows-2019' }}"
uses: actions/cache@v2
with:
path: GrowlInstaller
key: '${{ runner.os }}-growl-installer'
restore-keys: |
${{ runner.os }}-growl-installer
- name: Add Growl Installer to Path (Windows)
if: "${{ matrix.os == 'windows-2019' }}"
run: 'echo "::add-path::C:\Program Files (x86)\Growl for Windows"'
- name: Install Growl
if: "${{ matrix.os == 'windows-2019' }}"
run: |
echo "Installing Growl..."
cmd /c start /wait msiexec /i GrowlInstaller\Growl_v2.0.msi /quiet
echo "Done."
- name: Start Growl Service (Windows)
if: "${{ matrix.os == 'windows-2019' }}"
run: |
echo "Starting Growl service..."
Start-Process -NoNewWindow Growl
## Growl requires some time before it's ready to handle notifications
echo "Verifying Growl responding"
Start-Sleep -s 10
growlnotify test
- name: Install libnotify-bin (Linux)
if: "${{ matrix.os == 'ubuntu-latest' }}"
run: sudo apt-get install libnotify-bin
- uses: actions/setup-node@v1
with:
node-version: '${{ matrix.node }}'
- uses: actions/checkout@v2
- name: 'Cache node_modules (Linux)'
if: "${{ matrix.os != 'windows-2019' }}"
uses: actions/cache@v2
with:
path: '~/.npm'
key: "${{ matrix.os }}-node-v${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}"
restore-keys: |
${{ matrix.os }}-node-v${{ matrix.node }}-
- name: Install Dependencies
run: npm ci --ignore-scripts
- name: Install Annotation Support
run: npm install mocha-github-actions-reporter
- name: Run All Node.js Tests
run: npm start test.node
env:
COVERAGE: '${{ matrix.env.COVERAGE }}'
MOCHA_REPORTER: mocha-github-actions-reporter
# this is so mocha-github-actions-reporter can find mocha
NODE_PATH: lib
- name: Generate Coverage Report (Linux + Node.js latest)
if: '${{ matrix.env.COVERAGE }}'
run: npm start coverage-report-lcov
- name: Upload Coverage to Coveralls (Linux + Node.js latest)
if: '${{ matrix.env.COVERAGE }}'
uses: coverallsapp/github-action@master
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
95 changes: 0 additions & 95 deletions .github/workflows/windows-ci.yml

This file was deleted.

61 changes: 2 additions & 59 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@

# these are executed in order. each must pass for the next to be run
stages:
- smoke # this ensures a "user" install works properly
- precache # warm up cache for default Node.js version
- lint # lint code and docs
- test # all tests

# defaults
language: node_js
node_js: '14'
addons:
apt:
packages:
# Growl
- libnotify-bin
node_js: '12'
# `nvm install` happens before the cache is restored, which means
# we must install our own npm elsewhere (`~/npm`)
before_install: |
Expand All @@ -28,31 +20,17 @@ before_install: |
# avoids bugs around https://github.com/travis-ci/travis-ci/issues/5092
export PATH=~/npm/node_modules/.bin:$PATH
# this avoids compilation in most cases (where we don't need it)
install: npm ci --ignore-scripts
install: npm ci
cache:
directories:
- ~/.npm # cache npm's cache
- ~/npm # cache latest npm

jobs:
include:
- script: COVERAGE=1 npm start test.node
after_success: npm start coveralls
name: 'Latest Node.js (with coverage)'

- &node
script: npm start test.node
node_js: '12'
name: 'Node.js v12'

- <<: *node
node_js: '10'
name: 'Node.js v10'

- script: npm start test.browser
name: 'Browser'
node_js: 12
install: npm ci # we need the native modules here
addons:
artifacts:
paths:
Expand All @@ -61,43 +39,8 @@ jobs:
chrome: stable
sauce_connect: true

- stage: lint
script: npm start lint
name: 'JS & Markdown'

# smoke tests use default npm.
- &smoke
stage: smoke
env: null
before_install: true
install: npm install --production
name: 'Latest Node.js'
script: ./bin/mocha --no-config --reporter spec test/smoke/smoke.spec.js
cache:
directories:
- ~/.npm
- node_modules # npm install, unlike npm ci, doesn't wipe node_modules

- <<: *smoke
node_js: '12'
name: 'Node.js v12'

- <<: *smoke
node_js: '10'
name: 'Node.js v10'

- stage: precache
script: true
name: 'Prime cache'

env:
- 'NODE_OPTIONS="--trace-warnings"'

notifications:
email: false
webhooks:
urls:
# for gitter mochajs/contributors
- secure: rGMGYWBaZgEa9i997jJHKzjI8WxECqLi6BqsMhvstDq9EeTeXkZFVfz4r6G3Xugsk3tFwb/pDpiYo1OK36kA5arUJTCia51u4Wn+c7lHKcpef/vXztoyucvw6/jXdVm/FQz1jztYYbqdyAOWC2BV8gYvg5F8TpK05UGCe5R0bRA=
on_success: change
on_failure: always
Loading

0 comments on commit df8e9e6

Please sign in to comment.