Skip to content

Commit

Permalink
ci: move format, lint and test jobs to GitHub Actions (#1814)
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinnot committed Feb 9, 2020
1 parent 22e2fca commit e863c84
Show file tree
Hide file tree
Showing 5 changed files with 1,278 additions and 647 deletions.
125 changes: 125 additions & 0 deletions .github/workflows/continuous-integration.yaml
@@ -0,0 +1,125 @@
name: Continuous Integration

on:
pull_request:
types:
- opened
- synchronize
push:
branches:
- master

jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12
- name: Cache npm dependencies
uses: actions/cache@v1
with:
key: npm-${{ hashFiles('package-lock.json') }}
path: ~/.npm
restore-keys: |
npm-
- name: Install dependencies
run: npm ci --ignore-scripts --no-audit --no-progress --prefer-offline
- name: Format
run: npm run format
lint-javascript:
name: Lint JavaScript
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12
- name: Cache npm dependencies
uses: actions/cache@v1
with:
key: npm-${{ hashFiles('package-lock.json') }}
path: ~/.npm
restore-keys: |
npm-
- name: Install dependencies
run: npm ci --ignore-scripts --no-audit --no-progress --prefer-offline
- name: Lint
run: npm run lint:js
lint-typescript:
name: Lint TypeScript declaration files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12
- name: Cache npm dependencies
uses: actions/cache@v1
with:
key: npm-${{ hashFiles('package-lock.json') }}
path: ~/.npm
restore-keys: |
npm-
- name: Install dependencies
run: npm ci --ignore-scripts --no-audit --no-progress --prefer-offline
- name: Lint
run: |
npm run lint:ts
test:
name: Test
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- id: npm-cache
if: runner.os == 'Linux'
name: Get npm cache directory
run: |
echo "::set-output name=dir::$(npm config get cache)"
- if: runner.os == 'Linux'
name: Cache npm dependencies
uses: actions/cache@v1
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: |
npm-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ runner.os }}-${{ matrix.node-version }}-
- name: Install dependencies
run: npm ci --ignore-scripts --no-audit --no-progress --prefer-offline
# The following conditional can be removed once tests are fully migrated
# to Mocha. Alternatively a grep command used to select correct files can
# be refactored to work on Windows. Ideally all tests should be run across
# all platforms.
- if: runner.os != 'Windows'
name: Test
run: npm run test
- if: runner.os == 'Windows'
name: Test
run: npm run test:tap
strategy:
fail-fast: false
matrix:
node-version: [8, 10, 12, 13]
os: [macos-latest, ubuntu-latest, windows-latest]
7 changes: 4 additions & 3 deletions .gitignore
@@ -1,6 +1,7 @@
.cache
.nyc_output
.vscode
coverage
node_modules
npm-debug.log
coverage
.nyc_output/
tests/browserify-public/browserify-bundle.js
.vscode/
19 changes: 1 addition & 18 deletions .travis.yml
Expand Up @@ -12,8 +12,6 @@ branches:
- /^\d+\.x$/ # semantic-release maintenance releases

stages:
- lint
- test
- name: release
if: branch =~ /^(\d+\.x|master|next|beta)$/ AND type IN (push)
- name: update-prettier
Expand All @@ -25,24 +23,9 @@ jobs:
node_js: lts/*
script:
- git checkout $TRAVIS_BRANCH
- npm run prettier
- npm run format:fix
# commit changes and push back to branch on GitHub. If there are no changes then exit without error
- 'git commit -a -m "style: prettier" && git push "https://${GH_TOKEN}@github.com/$TRAVIS_REPO_SLUG" ${TRAVIS_BRANCH} || true'
- stage: lint
node_js: lts/*
env: linting
# Show prettier errors, even if lint fails.
script: run-s --silent --continue-on-error lint prettier:check dtslint
- stage: test
node_js: 12
# Avoid running lint and prettier again.
script: npm run --silent unit && npm run mocha
- node_js: 10
# Avoid running lint and prettier again.
script: npm run --silent unit && npm run mocha
- node_js: 8
# Avoid running lint and prettier again.
script: npm run --silent unit && npm run mocha
- stage: release
node_js: lts/*
env: semantic-release
Expand Down

0 comments on commit e863c84

Please sign in to comment.