Skip to content

Commit 2c2f175

Browse files
authored
Add GH Actions PR checks (#8)
* Add gh actions PR checks * fix diff command using wrong exit code * Fix test coverage file path * better diff command * No need for continue on error * regenerate yarn lock * Update build * Do not prettier the dist * use 0 depth for checkout
1 parent 554a219 commit 2c2f175

File tree

5 files changed

+1569
-1503
lines changed

5 files changed

+1569
-1503
lines changed

.github/workflows/pr-checks.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: PR checks
2+
3+
on: pull_request
4+
5+
env:
6+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7+
HUSKY_SKIP_INSTALL: true
8+
9+
jobs:
10+
eslint:
11+
name: Code quality
12+
runs-on: ubuntu-18.04
13+
steps:
14+
- name: Checkout repo
15+
uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
- name: Setup node
19+
uses: actions/setup-node@v1
20+
with:
21+
node-version: 12
22+
- name: Restore node_modules cache
23+
uses: actions/cache@v2
24+
with:
25+
path: "**/node_modules"
26+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
27+
- name: Install packages
28+
run: yarn
29+
- name: ESLint
30+
run: yarn eslint
31+
32+
tests:
33+
name: Unit tests
34+
runs-on: ubuntu-18.04
35+
steps:
36+
- name: Checkout repo
37+
uses: actions/checkout@v2
38+
with:
39+
fetch-depth: 0
40+
- name: Setup node
41+
uses: actions/setup-node@v1
42+
with:
43+
node-version: 12
44+
- name: Restore node_modules cache
45+
uses: actions/cache@v2
46+
with:
47+
path: "**/node_modules"
48+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
49+
- name: Install packages
50+
run: yarn
51+
- name: All tests
52+
run: yarn test
53+
- name: Add coverage comment
54+
uses: ScaCap/code-coverage-assistant@master
55+
with:
56+
github-token: ${{ secrets.GITHUB_TOKEN }}
57+
lcov-file: ./coverage/lcov.info
58+
59+
build:
60+
name: Check build is committed
61+
runs-on: ubuntu-18.04
62+
steps:
63+
- name: Checkout repo
64+
uses: actions/checkout@v2
65+
with:
66+
fetch-depth: 0
67+
- name: Setup node
68+
uses: actions/setup-node@v1
69+
with:
70+
node-version: 12
71+
- name: Restore node_modules cache
72+
uses: actions/cache@v2
73+
with:
74+
path: "**/node_modules"
75+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
76+
- name: Install packages
77+
run: yarn
78+
- name: Build
79+
run: yarn build
80+
- name: Ensure that the committed dist matches the build
81+
# See if there are any diffs in the dist file. Grep returns an error
82+
# when there are no changes, so we flip the output
83+
run: (git diff --name-only | grep dist/main.js || exit 0 && exit 1)

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
dist/*
22
package.json
33
.eslintrc.json
44
.github/

0 commit comments

Comments
 (0)