Skip to content

Commit 361772a

Browse files
committedJan 21, 2021
Add GitHub actions support.
1 parent c2fa5d7 commit 361772a

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed
 

‎.github/workflows/main.yml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Node.js CI
2+
3+
on: [push]
4+
5+
jobs:
6+
test-node:
7+
runs-on: ubuntu-latest
8+
timeout-minutes: 10
9+
strategy:
10+
matrix:
11+
node-version: [10.x, 12.x, 14.x]
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Use Node.js ${{ matrix.node-version }}
15+
uses: actions/setup-node@v1
16+
with:
17+
node-version: ${{ matrix.node-version }}
18+
- name: Install
19+
run: npm install
20+
- name: Fetch test suite
21+
run: npm run fetch-test-suite
22+
- name: Run test with Node.js ${{ matrix.node-version }}
23+
run: npm run test-node
24+
test-karma:
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 10
27+
strategy:
28+
matrix:
29+
node-version: [14.x]
30+
steps:
31+
- uses: actions/checkout@v2
32+
- name: Use Node.js ${{ matrix.node-version }}
33+
uses: actions/setup-node@v1
34+
with:
35+
node-version: ${{ matrix.node-version }}
36+
- run: npm install
37+
- name: Run karma tests
38+
run: npm run test-karma
39+
lint:
40+
runs-on: ubuntu-latest
41+
timeout-minutes: 10
42+
strategy:
43+
matrix:
44+
node-version: [14.x]
45+
steps:
46+
- uses: actions/checkout@v2
47+
- name: Use Node.js ${{ matrix.node-version }}
48+
uses: actions/setup-node@v1
49+
with:
50+
node-version: ${{ matrix.node-version }}
51+
- run: npm install
52+
- name: Run eslint
53+
run: npm run lint
54+
coverage:
55+
needs: [test-node, test-karma]
56+
runs-on: ubuntu-latest
57+
timeout-minutes: 10
58+
strategy:
59+
matrix:
60+
node-version: [14.x]
61+
steps:
62+
- uses: actions/checkout@v2
63+
- name: Use Node.js ${{ matrix.node-version }}
64+
uses: actions/setup-node@v1
65+
with:
66+
node-version: ${{ matrix.node-version }}
67+
- name: Install
68+
run: npm install
69+
- name: Fetch test suite
70+
run: npm run fetch-test-suite
71+
- name: Generate coverage report
72+
run: npm run coverage-ci
73+
- name: Upload coverage to Codecov
74+
uses: codecov/codecov-action@v1
75+
with:
76+
file: ./coverage/lcov.info
77+
fail_ci_if_error: true

‎package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,11 @@
103103
"fetch-json-ld-framing-test-suite": "if [ ! -e test-suites/json-wg-framing ]; then git clone --depth 1 https://github.com/w3c/json-ld-framing.git test-suites/json-ld-framing; fi",
104104
"fetch-json-ld-org-test-suite": "if [ ! -e test-suites/json-ld.org ]; then git clone --depth 1 https://github.com/json-ld/json-ld.org.git test-suites/json-ld.org; fi",
105105
"fetch-normalization-test-suite": "if [ ! -e test-suites/normalization ]; then git clone --depth 1 https://github.com/json-ld/normalization.git test-suites/normalization; fi",
106-
"test": "cross-env NODE_ENV=test mocha --delay -t 30000 -A -R ${REPORTER:-spec} tests/test.js",
106+
"test": "npm run test-node",
107+
"test-node": "cross-env NODE_ENV=test mocha --delay -t 30000 -A -R ${REPORTER:-spec} tests/test.js",
107108
"test-karma": "cross-env NODE_ENV=test karma start",
108109
"coverage": "nyc --reporter=lcov --reporter=text-summary npm test",
110+
"coverage-ci": "nyc --reporter=lcovonly npm run test",
109111
"coverage-report": "nyc report",
110112
"lint": "eslint *.js lib/**.js tests/**.js"
111113
},

0 commit comments

Comments
 (0)
Please sign in to comment.