Skip to content

Commit 4d1cdde

Browse files
authored
chore: add tests to github-actions workflow (#13)
From now on, the test runner runs on every pull request.
1 parent 022743d commit 4d1cdde

File tree

3 files changed

+80
-39
lines changed

3 files changed

+80
-39
lines changed

.github/workflows/ci.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
env:
8+
NODE_VERSION: "12.x"
9+
10+
jobs:
11+
setup:
12+
name: Setup
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- uses: actions/setup-node@v1
19+
with:
20+
node-version: "${{ env.NODE_VERSION }}"
21+
22+
- name: Cache node modules
23+
id: cache
24+
uses: actions/cache@v1
25+
with:
26+
path: node_modules
27+
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
28+
29+
- name: Install Dependencies
30+
if: steps.cache.outputs.cache-hit != 'true'
31+
run: npm ci
32+
33+
eslint:
34+
name: Eslint
35+
runs-on: ubuntu-latest
36+
needs: [setup]
37+
timeout-minutes: 5
38+
steps:
39+
- uses: actions/checkout@v2
40+
with:
41+
fetch-depth: 0
42+
43+
- uses: actions/setup-node@v1
44+
with:
45+
node-version: "${{ env.NODE_VERSION }}"
46+
47+
- name: Fetch all branches
48+
run: |
49+
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
50+
51+
- name: Cache node modules
52+
uses: actions/cache@v1
53+
with:
54+
path: node_modules
55+
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
56+
57+
- name: Run Eslint
58+
run: npm run ci:lint -- $(git diff --diff-filter d --name-only origin/${{ github.base_ref }}...HEAD -- '*.js' '*.ts' '*.tsx')
59+
60+
tests:
61+
name: Tests
62+
runs-on: ubuntu-latest
63+
needs: [setup]
64+
timeout-minutes: 5
65+
steps:
66+
- uses: actions/checkout@v2
67+
68+
- uses: actions/setup-node@v1
69+
with:
70+
node-version: "${{ env.NODE_VERSION }}"
71+
72+
- name: Cache node modules
73+
uses: actions/cache@v1
74+
with:
75+
path: node_modules
76+
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
77+
78+
- name: Run Tests
79+
run: npm run ci:test

.github/workflows/lint.yml

-39
This file was deleted.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"lint": "eslint 'src/**/*.js' --quiet --fix",
1010
"clean": "rimraf ./dist ./.cache",
1111
"ci:lint": "eslint 'src/**/*.js' -c ./.eslintrc.js",
12+
"ci:test": "jest --ci" ,
1213
"test": "jest",
1314
"test:watch": "jest --watch"
1415
},

0 commit comments

Comments
 (0)