Skip to content

Commit b9453ea

Browse files
authored
refactor(ci): Switch to GitHub Actions CI (#1600)
* 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
1 parent 18c0038 commit b9453ea

File tree

10 files changed

+167
-44
lines changed

10 files changed

+167
-44
lines changed

.github/workflows/benchmark.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Benchmark
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- 'dependabot/**'
7+
pull_request:
8+
9+
env:
10+
CI: true
11+
FORCE_COLOR: 2
12+
NODE: 14
13+
14+
jobs:
15+
benchmark:
16+
runs-on: ubuntu-latest
17+
if: "!contains(github.event.commits[0].message, '[bench skip]') || !contains(github.event.commits[0].message, '[skip bench]')"
18+
19+
steps:
20+
- name: Clone repository
21+
uses: actions/checkout@v2
22+
23+
- name: Set up Node.js
24+
uses: actions/setup-node@v2
25+
with:
26+
node-version: '${{ env.NODE }}'
27+
28+
- name: Set up npm cache
29+
uses: actions/cache@v2
30+
with:
31+
path: ~/.npm
32+
key: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
33+
restore-keys: |
34+
${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
35+
${{ runner.OS }}-node-v${{ env.NODE }}-
36+
37+
- name: Install npm dependencies
38+
run: npm ci
39+
40+
- name: Run benchmarks
41+
run: npm run benchmark
42+
env:
43+
BENCHMARK: true

.github/workflows/ci.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- 'dependabot/**'
7+
pull_request:
8+
9+
env:
10+
CI: true
11+
FORCE_COLOR: 2
12+
NODE_COV: 14 # The Node.js version to run coveralls on
13+
14+
jobs:
15+
run:
16+
name: Node ${{ matrix.node }}
17+
runs-on: ubuntu-latest
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
node:
23+
- 10
24+
- 12
25+
- 14
26+
- 15
27+
28+
steps:
29+
- name: Clone repository
30+
uses: actions/checkout@v2
31+
32+
- name: Set up Node.js
33+
uses: actions/setup-node@v2
34+
with:
35+
node-version: '${{ matrix.node }}'
36+
37+
- name: Set up npm cache
38+
uses: actions/cache@v2
39+
with:
40+
path: ~/.npm
41+
key: ${{ runner.os }}-node-v${{ matrix.node }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
42+
restore-keys: |
43+
${{ runner.OS }}-node-v${{ matrix.node }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
44+
${{ runner.OS }}-node-v${{ matrix.node }}-
45+
46+
- name: Install npm dependencies
47+
run: npm ci
48+
49+
- name: Run Jest
50+
run: npm run test:jest
51+
if: matrix.node != env.NODE_COV
52+
53+
- name: Run Jest with coverage
54+
run: npm run test:jest:cov
55+
if: matrix.node == env.NODE_COV
56+
57+
- name: Run Coveralls
58+
uses: coverallsapp/github-action@master
59+
if: matrix.node == env.NODE_COV
60+
with:
61+
github-token: '${{ secrets.GITHUB_TOKEN }}'

.github/workflows/codeql.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- '!dependabot/**'
78
pull_request:
89
# The branches below must be a subset of the branches above
910
branches:

.github/workflows/lint.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- 'dependabot/**'
7+
pull_request:
8+
9+
env:
10+
CI: true
11+
FORCE_COLOR: 2
12+
NODE: 14
13+
14+
jobs:
15+
lint:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Clone repository
20+
uses: actions/checkout@v2
21+
22+
- name: Set up Node.js
23+
uses: actions/setup-node@v2
24+
with:
25+
node-version: '${{ env.NODE }}'
26+
27+
- name: Set up npm cache
28+
uses: actions/cache@v2
29+
with:
30+
path: ~/.npm
31+
key: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
32+
restore-keys: |
33+
${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
34+
${{ runner.OS }}-node-v${{ env.NODE }}-
35+
36+
- name: Install npm dependencies
37+
run: npm ci
38+
39+
- name: Run lint
40+
run: npm run lint
41+
42+
- name: Test types
43+
run: npm run test:types

.github/workflows/site.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ on:
44
branches:
55
- main
66

7+
env:
8+
CI: true
9+
FORCE_COLOR: 2
10+
NODE: 14
11+
712
jobs:
813
deploy:
914
name: Deploy to GitHub Pages
@@ -12,7 +17,15 @@ jobs:
1217
- uses: actions/checkout@v2
1318
- uses: actions/setup-node@v2
1419
with:
15-
node-version: 14.x
20+
node-version: '${{ env.NODE }}'
21+
- name: Set up npm cache
22+
uses: actions/cache@v2
23+
with:
24+
path: ~/.npm
25+
key: ${{ runner.os }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
26+
restore-keys: |
27+
${{ runner.OS }}-node-v${{ env.NODE }}-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
28+
${{ runner.OS }}-node-v${{ env.NODE }}-
1629
- run: npm ci
1730
- name: Build JSDoc
1831
run: npm run build:docs

.travis.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

Makefile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,8 @@ subl:
2020
test-cov:
2121
@./node_modules/.bin/jest --coverage
2222

23-
# Due to occasional unavailability of the code coverage reporting service, the
24-
# exit status of the command in this recipe may optionally be ignored.
25-
report-cov: test-cov
26-
cat coverage/lcov.info | ./node_modules/.bin/coveralls || [ "$(OPTIONAL)" = "true" ]
27-
2823
travis-test: OPTIONAL = true
29-
travis-test: lint types report-cov
24+
travis-test: lint types
3025
@true
3126

3227
bench:

Readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<h5 align="center">Fast, flexible & lean implementation of core jQuery designed specifically for the server.</h5>
44

55
<div align="center">
6-
<a href="https://travis-ci.org/cheeriojs/cheerio">
7-
<img src="https://img.shields.io/travis/cheeriojs/cheerio/main" alt="Travis CI">
6+
<a href="https://github.com/cheeriojs/cheerio/actions?query=workflow%3ACI+branch%3Amain">
7+
<img src="https://img.shields.io/github/workflow/status/cheeriojs/cheerio/CI/main" alt="Build Status">
88
</a>
99
<a href="https://coveralls.io/github/cheeriojs/cheerio">
1010
<img src="https://img.shields.io/coveralls/github/cheeriojs/cheerio/main" alt="Coverage">

package-lock.json

Lines changed: 0 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"devDependencies": {
4242
"@types/node": "^14.14.10",
4343
"benchmark": "^2.1.4",
44-
"coveralls": "^3.0.2",
4544
"eslint": "^7.10.0",
4645
"eslint-config-prettier": "^7.0.0",
4746
"eslint-plugin-jsdoc": "^30.6.2",
@@ -59,6 +58,7 @@
5958
"scripts": {
6059
"test": "npm run lint && npm run test:jest && npm run test:types",
6160
"test:jest": "jest",
61+
"test:jest:cov": "npm run test:jest -- --coverage",
6262
"test:types": "tsd",
6363
"lint": "npm run lint:es && npm run lint:prettier",
6464
"lint:es": "eslint .",
@@ -68,6 +68,7 @@
6868
"format:prettier": "npm run format:prettier:raw -- --write",
6969
"format:prettier:raw": "prettier \"**/*.{js,ts,md,json,yml}\" --ignore-path .prettierignore",
7070
"build:docs": "jsdoc --configure jsdoc-config.json",
71+
"benchmark": "node benchmark/benchmark.js --regex \"^(?!.*highmem)\"",
7172
"pre-commit": "lint-staged"
7273
},
7374
"prettier": {

0 commit comments

Comments
 (0)