Skip to content

Commit b82d53a

Browse files
committed
Add github actions for lint and test
1 parent ba90f16 commit b82d53a

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

.github/workflows/ci.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
on:
2+
push:
3+
pull_request:
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Code Checkout
10+
uses: actions/checkout@v4
11+
- name: Install Node
12+
uses: actions/setup-node@v4
13+
with:
14+
node-version: "lts/*"
15+
cache: 'npm'
16+
- name: Create Checksum of package.json
17+
run: echo PACKAGE_CHECKSUM="$(shasum package.json | awk '{ print $1 }')" >> "$GITHUB_ENV"
18+
- name: Restore Cache
19+
uses: actions/cache/restore@v4
20+
with:
21+
path: ./node_modules
22+
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
23+
- name: Install Dependencies
24+
run: npm install
25+
- name: Save Cache
26+
uses: actions/cache/save@v4
27+
id: cache
28+
with:
29+
path: ./node_modules
30+
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
31+
- name: Lint JavaScript
32+
run: npm run lint
33+
test:
34+
needs: lint
35+
runs-on: ubuntu-latest
36+
#Spin up postgres as a service, wait till healthy before moving on. Uses latest Postgres Version.
37+
services:
38+
postgres:
39+
image: postgres:latest
40+
env:
41+
POSTGRES_DB: analytics_reporter_test
42+
POSTGRES_USER: postgres
43+
POSTGRES_PASSWORD: postgres
44+
ports:
45+
- 5432:5432
46+
options:
47+
--health-cmd pg_isready
48+
--health-interval 10s
49+
--health-timeout 5s
50+
--health-retries 5
51+
steps:
52+
- name: Code Checkout
53+
uses: actions/checkout@v4
54+
- name: Install Node
55+
uses: actions/setup-node@v4
56+
with:
57+
node-version: "lts/*"
58+
cache: 'npm'
59+
- name: Create Checksum of package.json
60+
run: echo PACKAGE_CHECKSUM="$(shasum package.json | awk '{ print $1 }')" >> "$GITHUB_ENV"
61+
- name: Restore Cache
62+
uses: actions/cache/restore@v4
63+
with:
64+
path: ./node_modules
65+
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
66+
- name: Install Dependencies
67+
run: npm install
68+
- name: Save Cache
69+
uses: actions/cache/save@v4
70+
id: cache
71+
with:
72+
path: ./node_modules
73+
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
74+
- name: Run tests
75+
env:
76+
POSTGRES_USER: postgres
77+
POSTGRES_PASSWORD: postgres
78+
POSTGRES_DB: analytics_reporter_test
79+
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
80+
run: npm test

0 commit comments

Comments
 (0)