Skip to content

Commit 2200fd4

Browse files
Merge pull request #409 from nmarklund10/nmarklund10/408-issue
Create CI Pipeline with Github actions that lints, builds and installs
2 parents 0529106 + de6daed commit 2200fd4

1 file changed

Lines changed: 101 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Bmore Responsive CI
2+
3+
on: push
4+
5+
env:
6+
NODE_ENV: development
7+
DATABASE_PASSWORD: password
8+
JWT_KEY: fortestsonly
9+
10+
jobs:
11+
audit:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: Cache node modules
18+
uses: actions/cache@v2
19+
env:
20+
cache-name: cache-node-modules
21+
with:
22+
# npm cache files are stored in `~/.npm` on Linux/macOS
23+
path: ~/.npm
24+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
25+
restore-keys: |
26+
${{ runner.os }}-build-${{ env.cache-name }}-
27+
${{ runner.os }}-build-
28+
${{ runner.os }}-
29+
30+
- name: Install npm packages
31+
run: npm install
32+
33+
# - name: Audit npm packages
34+
# run: npm audit
35+
36+
lint:
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- uses: actions/checkout@v2
41+
42+
- name: install eslint
43+
run: npm install eslint
44+
45+
- name: Lint JS
46+
run: npm run lint
47+
48+
- name: install hadolint
49+
run: docker pull hadolint/hadolint
50+
51+
- name: Lint Dockerfile
52+
run: |
53+
docker run --rm -i hadolint/hadolint < Dockerfile
54+
55+
build:
56+
runs-on: ubuntu-latest
57+
needs:
58+
- audit
59+
- lint
60+
61+
steps:
62+
- uses: actions/checkout@v2
63+
64+
- name: Build docker stack
65+
run: docker-compose up -d --build
66+
67+
- name: Save docker images
68+
run: |
69+
docker save -o /tmp/containers.tar bmore-responsive_api:latest postgres:latest
70+
71+
- name: Cache API docker image
72+
uses: actions/upload-artifact@v2
73+
with:
74+
name: containers
75+
path: /tmp/containers.tar
76+
77+
test:
78+
runs-on: ubuntu-latest
79+
needs: build
80+
steps:
81+
- uses: actions/checkout@v2
82+
83+
- name: Download docker images
84+
uses: actions/download-artifact@v3
85+
with:
86+
name: containers
87+
path: /tmp
88+
89+
- name: Extract docker images
90+
run: |
91+
docker load -i /tmp/containers.tar
92+
93+
- name: Compose docker images
94+
run: docker compose up -d
95+
96+
- name: Test
97+
run: |
98+
sleep 10 # wait for containers to set up
99+
docker exec bmore-responsive-api-1 npm test
100+
101+

0 commit comments

Comments
 (0)