Skip to content

Commit

Permalink
refactor(ci): Switch to GitHub Actions CI (#1600)
Browse files Browse the repository at this point in the history
* Switch to GitHub Actions CI
* Add a benchmark npm script
* CI: ignore dependabot branches

* benchmark.yml: allow skipping benchmark run through commit messages

One can use [bench skip] or [skip bench] in the commit message to skip running the benchmark action

* site.yml: add caching, CI and FORCE_COLOR env vars

* Move Coveralls to Actions
  • Loading branch information
XhmikosR committed Dec 28, 2020
1 parent 18c0038 commit b9453ea
Show file tree
Hide file tree
Showing 10 changed files with 167 additions and 44 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/benchmark.yml
@@ -0,0 +1,43 @@
name: Benchmark

on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:

env:
CI: true
FORCE_COLOR: 2
NODE: 14

jobs:
benchmark:
runs-on: ubuntu-latest
if: "!contains(github.event.commits[0].message, '[bench skip]') || !contains(github.event.commits[0].message, '[skip bench]')"

steps:
- name: Clone repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '${{ env.NODE }}'

- name: Set up npm cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
${{ runner.OS }}-node-v${{ env.NODE }}-
- name: Install npm dependencies
run: npm ci

- name: Run benchmarks
run: npm run benchmark
env:
BENCHMARK: true
61 changes: 61 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,61 @@
name: CI

on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:

env:
CI: true
FORCE_COLOR: 2
NODE_COV: 14 # The Node.js version to run coveralls on

jobs:
run:
name: Node ${{ matrix.node }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node:
- 10
- 12
- 14
- 15

steps:
- name: Clone repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '${{ matrix.node }}'

- name: Set up npm cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-v${{ matrix.node }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-v${{ matrix.node }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
${{ runner.OS }}-node-v${{ matrix.node }}-
- name: Install npm dependencies
run: npm ci

- name: Run Jest
run: npm run test:jest
if: matrix.node != env.NODE_COV

- name: Run Jest with coverage
run: npm run test:jest:cov
if: matrix.node == env.NODE_COV

- name: Run Coveralls
uses: coverallsapp/github-action@master
if: matrix.node == env.NODE_COV
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
1 change: 1 addition & 0 deletions .github/workflows/codeql.yml
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- '!dependabot/**'
pull_request:
# The branches below must be a subset of the branches above
branches:
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/lint.yml
@@ -0,0 +1,43 @@
name: Lint

on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:

env:
CI: true
FORCE_COLOR: 2
NODE: 14

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Clone repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '${{ env.NODE }}'

- name: Set up npm cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
${{ runner.OS }}-node-v${{ env.NODE }}-
- name: Install npm dependencies
run: npm ci

- name: Run lint
run: npm run lint

- name: Test types
run: npm run test:types
15 changes: 14 additions & 1 deletion .github/workflows/site.yml
Expand Up @@ -4,6 +4,11 @@ on:
branches:
- main

env:
CI: true
FORCE_COLOR: 2
NODE: 14

jobs:
deploy:
name: Deploy to GitHub Pages
Expand All @@ -12,7 +17,15 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14.x
node-version: '${{ env.NODE }}'
- name: Set up npm cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
${{ runner.OS }}-node-v${{ env.NODE }}-
- run: npm ci
- name: Build JSDoc
run: npm run build:docs
Expand Down
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

7 changes: 1 addition & 6 deletions Makefile
Expand Up @@ -20,13 +20,8 @@ subl:
test-cov:
@./node_modules/.bin/jest --coverage

# Due to occasional unavailability of the code coverage reporting service, the
# exit status of the command in this recipe may optionally be ignored.
report-cov: test-cov
cat coverage/lcov.info | ./node_modules/.bin/coveralls || [ "$(OPTIONAL)" = "true" ]

travis-test: OPTIONAL = true
travis-test: lint types report-cov
travis-test: lint types
@true

bench:
Expand Down
4 changes: 2 additions & 2 deletions Readme.md
Expand Up @@ -3,8 +3,8 @@
<h5 align="center">Fast, flexible & lean implementation of core jQuery designed specifically for the server.</h5>

<div align="center">
<a href="https://travis-ci.org/cheeriojs/cheerio">
<img src="https://img.shields.io/travis/cheeriojs/cheerio/main" alt="Travis CI">
<a href="https://github.com/cheeriojs/cheerio/actions?query=workflow%3ACI+branch%3Amain">
<img src="https://img.shields.io/github/workflow/status/cheeriojs/cheerio/CI/main" alt="Build Status">
</a>
<a href="https://coveralls.io/github/cheeriojs/cheerio">
<img src="https://img.shields.io/coveralls/github/cheeriojs/cheerio/main" alt="Coverage">
Expand Down
25 changes: 0 additions & 25 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -41,7 +41,6 @@
"devDependencies": {
"@types/node": "^14.14.10",
"benchmark": "^2.1.4",
"coveralls": "^3.0.2",
"eslint": "^7.10.0",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-jsdoc": "^30.6.2",
Expand All @@ -59,6 +58,7 @@
"scripts": {
"test": "npm run lint && npm run test:jest && npm run test:types",
"test:jest": "jest",
"test:jest:cov": "npm run test:jest -- --coverage",
"test:types": "tsd",
"lint": "npm run lint:es && npm run lint:prettier",
"lint:es": "eslint .",
Expand All @@ -68,6 +68,7 @@
"format:prettier": "npm run format:prettier:raw -- --write",
"format:prettier:raw": "prettier \"**/*.{js,ts,md,json,yml}\" --ignore-path .prettierignore",
"build:docs": "jsdoc --configure jsdoc-config.json",
"benchmark": "node benchmark/benchmark.js --regex \"^(?!.*highmem)\"",
"pre-commit": "lint-staged"
},
"prettier": {
Expand Down

0 comments on commit b9453ea

Please sign in to comment.