Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: move format, lint and test jobs to GitHub Actions #1814

Merged
merged 21 commits into from Feb 9, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
86d817a
ci: move format, lint and test jobs to GitHub Actions
merlinnot Nov 8, 2019
18901d1
Merge branch 'master' into github-actions
merlinnot Nov 8, 2019
d82c8e3
ci: split JavaScript and TypeScript linters
merlinnot Nov 8, 2019
7f15cb9
build: remove an extra comma from package.json
merlinnot Nov 8, 2019
2bd9fb1
ci: temporarily disable tests on Windows
merlinnot Nov 8, 2019
3008ea9
ci: trigger on pull requests
merlinnot Nov 8, 2019
7987a35
build: add .cache to .gitignore
merlinnot Nov 8, 2019
09fb130
ci: run Tap tests on Windows
merlinnot Nov 8, 2019
eeba69e
ci: remove ESLint cache to simplify lint job
merlinnot Nov 8, 2019
adebc1c
chore: revert package-lock.json changes
merlinnot Nov 8, 2019
3992dd2
Merge branch 'master' into github-actions
merlinnot Nov 28, 2019
1635b06
ci: simplify caching mechanism
merlinnot Feb 5, 2020
9d6602c
Merge branch 'master' into github-actions
merlinnot Feb 5, 2020
b07b93f
chore: deduplicate package-lock.json
merlinnot Feb 5, 2020
6ea6353
chore: do not cancel other pipelines when one fails
merlinnot Feb 5, 2020
29e4138
ci: use Node.js version from the matrix in tests
merlinnot Feb 5, 2020
8377355
chore: update dtslint to v2.0.5
merlinnot Feb 5, 2020
d317725
Merge remote-tracking branch 'upstream/master' into github-actions
merlinnot Feb 9, 2020
20783e0
ci: speed up MacOS and Windows runs by disabling dependency cache
merlinnot Feb 9, 2020
0d7c1a3
ci: update to actions/checkout v2
merlinnot Feb 9, 2020
3ac2e5a
ci: use more clean npm ci syntax
merlinnot Feb 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
139 changes: 139 additions & 0 deletions .github/workflows/continuous-integration.yaml
@@ -0,0 +1,139 @@
name: Continuous Integration

on: push

jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- 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 --prefer-offline --progress=false
- name: Format
run: npm run format
lint-javascript:
name: Lint JavaScript
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- 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: Cache local cache
uses: actions/cache@v1
with:
key: eslint-${{ github.sha }}
path: .cache
restore-keys: |
eslint-
- name: Install dependencies
run: npm ci --ignore-scripts --no-audit --prefer-offline --progress=false
- name: Lint
run: |
# This is required to workaround a limitation of ESLint which uses
# file modification time in its cache, instead of file checksum.
merlinnot marked this conversation as resolved.
Show resolved Hide resolved
#
# cspell:ignore iregex
find . \
-type d -name "node_modules" -prune -o \
-type f -iregex '.*.ts' \
-exec ./scripts/ci/set_mtime_to_md5.sh {} \;
npm run lint:js
lint-typescript:
name: Lint TypeScript declaration files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- 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 --prefer-offline --progress=false
- name: Lint
run: |
npm run lint:ts
test:
name: Test
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12
- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
# The following two steps can be greatly simplified once
# https://github.com/actions/cache/issues/39 is fixed.
merlinnot marked this conversation as resolved.
Show resolved Hide resolved
- if: runner.os != 'Windows'
name: Cache npm dependencies
uses: actions/cache@v1
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: |
npm-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ runner.os }}-
- if: runner.os == 'Windows'
name: Cache npm dependencies
uses: actions/cache@v1
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: |
npm-${{ runner.os }}-${{ hashFiles('**\package-lock.json') }}
restore-keys: |
npm-${{ runner.os }}-
- name: Install dependencies
run: npm ci --ignore-scripts --no-audit --prefer-offline --progress=false
- # The following conditional can be removed once tests are fully
# migrated.
if: runner.os != 'Windows'
merlinnot marked this conversation as resolved.
Show resolved Hide resolved
name: Test
run: npm run test
strategy:
fail-fast: true
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
merlinnot marked this conversation as resolved.
Show resolved Hide resolved
node: [8, 10, 12, 13]
merlinnot marked this conversation as resolved.
Show resolved Hide resolved
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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we can. Although I'd prefer to do it in a separate PR instead of making this one even larger. Is it ok with you? Seems like it doesn't have to be merged at the same time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely, I'd suggest the same. Sorry, I should have said so

- 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
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions package.json
Expand Up @@ -57,17 +57,17 @@
"tap": "^14.0.0"
},
"scripts": {
"unit": "tap --100 --coverage --coverage-report=text ./tests/test_*.js",
"pretest": "npm run -s lint",
"test": "npm run -s unit",
"posttest": "npm run -s prettier:check",
"coverage": "tap --coverage-report=html && open coverage/lcov-report/index.html",
"mocha": "nyc mocha $(grep -lr '^\\s*it(' tests)",
"lint": "eslint \"**/*.js\"",
"prettier": "prettier --write \"**/*.@(js|json|md|ts|yml)\"",
"prettier:check": "prettier --check \"**/*.@(js|json|md|ts|yml)\"",
"dtslint": "dtslint types",
"semantic-release": "semantic-release"
merlinnot marked this conversation as resolved.
Show resolved Hide resolved
"format:fix": "prettier --write '**/*.{js,json,md,ts,yml,yaml}'",
"format": "prettier --check '**/*.{js,json,md,ts,yml,yaml}'",
"lint": "run-p lint:js lint:ts",
"lint:js": "eslint --cache --cache-location './.cache/eslint' '**/*.js'",
"lint:js:fix": "eslint --cache --cache-location './.cache/eslint' --fix '**/*.js'",
"lint:ts": "dtslint types",
"semantic-release": "semantic-release",
"test": "run-p test:mocha test:tap",
"test:coverage": "tap --coverage-report=html && open coverage/lcov-report/index.html",
"test:mocha": "nyc mocha $(grep -lr '^\\s*it(' tests)",
"test:tap": "tap --100 --coverage --coverage-report=text ./tests/test_*.js"
merlinnot marked this conversation as resolved.
Show resolved Hide resolved
},
"nyc": {
"reporter": [
Expand Down
5 changes: 5 additions & 0 deletions scripts/ci/set_mtime_to_md5.sh
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

FILE="${1}"
MD5="$((0x$(md5sum ${FILE} | cut -b 1-7)))"
touch "${FILE}" -c -d @${MD5}