Skip to content

Commit df9039b

Browse files
evansmjShahanaFarooqui
authored andcommitted
Add workflows
- Add CI pipeline - Add test workflow. - Refactor build steps into build.yml
1 parent b1050a7 commit df9039b

File tree

4 files changed

+128
-86
lines changed

4 files changed

+128
-86
lines changed

.github/workflows/build.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-22.04
10+
steps:
11+
- name: Checkout source code
12+
uses: actions/checkout@v3
13+
14+
- name: Setup Node
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: 18.x
18+
19+
- name: Get version from package.json
20+
id: package-version
21+
run: |
22+
echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
23+
echo "Project Version: $VERSION"
24+
25+
- name: Cache node_modules
26+
uses: actions/cache@v3
27+
id: cache-npm-packages
28+
with:
29+
path: node_modules
30+
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
31+
32+
- name: Install NPM dependencies
33+
if: steps.cache-npm-packages.outputs.cache-hit != 'true'
34+
run: npm clean-install
35+
36+
- name: Cache build frontend
37+
uses: actions/cache@v3
38+
id: cache-build-frontend
39+
with:
40+
path: apps/frontend
41+
key: ${{ runner.os }}-frontend-${{ github.sha }}
42+
43+
- name: Run build production application
44+
run: npm run frontend:build
45+
46+
- name: Cache build backend
47+
uses: actions/cache@v3
48+
id: cache-build-backend
49+
with:
50+
path: apps/backend
51+
key: ${{ runner.os }}-backend-${{ github.sha }}
52+
53+
- name: Run build backend server
54+
run: npm run backend:build

.github/workflows/ci.yml

Lines changed: 7 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,15 @@
1-
name: Artifact
1+
name: CI Workflow
22

33
on:
4-
release:
5-
types: [released]
64
pull_request:
7-
types: [closed]
8-
branches: [ master ]
95
workflow_dispatch:
106

11-
env:
12-
CI: false
13-
147
jobs:
15-
build:
16-
runs-on: ubuntu-22.04
17-
steps:
18-
- name: Checkout source code
19-
uses: actions/checkout@v3
20-
21-
- name: Setup Node
22-
uses: actions/setup-node@v3
23-
with:
24-
node-version: 18.x
25-
26-
- name: Get version from package.json
27-
id: package-version
28-
run: |
29-
echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
30-
echo "Project Version: $VERSION"
31-
32-
- name: Cache node_modules
33-
uses: actions/cache@v3
34-
id: cache-npm-packages
35-
with:
36-
path: node_modules
37-
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
38-
39-
- name: Install NPM dependencies
40-
if: steps.cache-npm-packages.outputs.cache-hit != 'true'
41-
run: npm clean-install
42-
43-
- name: Cache build frontend
44-
uses: actions/cache@v3
45-
id: cache-build-frontend
46-
with:
47-
path: apps/frontend
48-
key: ${{ runner.os }}-frontend-${{ github.sha }}
8+
lint:
9+
uses: ./.github/workflows/lint.yml
4910

50-
- name: Run build production application
51-
run: npm run frontend:build
11+
test:
12+
uses: ./.github/workflows/test.yml
5213

53-
- name: Cache build backend
54-
uses: actions/cache@v3
55-
id: cache-build-backend
56-
with:
57-
path: apps/backend
58-
key: ${{ runner.os }}-backend-${{ github.sha }}
59-
60-
- name: Run build backend server
61-
run: npm run backend:build
62-
63-
deploy:
64-
runs-on: ubuntu-22.04
65-
needs: build
66-
steps:
67-
- name: Checkout source code
68-
uses: actions/checkout@v3
69-
70-
- name: Cache build frontend
71-
uses: actions/cache@v3
72-
id: cache-build-frontend
73-
with:
74-
path: apps/frontend
75-
key: ${{ runner.os }}-frontend-${{ github.sha }}
76-
77-
- name: Cache build backend
78-
uses: actions/cache@v3
79-
id: cache-build-backend
80-
with:
81-
path: apps/backend
82-
key: ${{ runner.os }}-backend-${{ github.sha }}
83-
84-
- name: Compress files
85-
run: tar -czf /tmp/clnapp.tar.gz apps/frontend/build apps/backend/dist package.json package-lock.json
86-
87-
- uses: actions/upload-artifact@v3
88-
with:
89-
name: clnapp-build$VERSION
90-
path: /tmp/clnapp.tar.gz
14+
build:
15+
uses: ./.github/workflows/build.yml

.github/workflows/github.yml renamed to .github/workflows/release.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,39 @@
1-
name: Build and publish Github image
1+
name: Build artifact and package
22

33
on:
44
release:
55
types: [released]
6-
pull_request:
7-
types: [closed]
8-
branches: [ master ]
96
workflow_dispatch:
107

118
jobs:
9+
artifact:
10+
runs-on: ubuntu-22.04
11+
steps:
12+
- name: Checkout source code
13+
uses: actions/checkout@v3
14+
15+
- name: Cache build frontend
16+
uses: actions/cache@v3
17+
id: cache-build-frontend
18+
with:
19+
path: apps/frontend
20+
key: ${{ runner.os }}-frontend-${{ github.sha }}
21+
22+
- name: Cache build backend
23+
uses: actions/cache@v3
24+
id: cache-build-backend
25+
with:
26+
path: apps/backend
27+
key: ${{ runner.os }}-backend-${{ github.sha }}
28+
29+
- name: Compress files
30+
run: tar -czf /tmp/clnapp.tar.gz apps/frontend/build apps/backend/dist package.json package-lock.json
31+
32+
- uses: actions/upload-artifact@v3
33+
with:
34+
name: clnapp-build$VERSION
35+
path: /tmp/clnapp.tar.gz
36+
1237
build:
1338
name: Build image
1439
runs-on: ubuntu-22.04

.github/workflows/test.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Unit tests
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-22.04
10+
steps:
11+
- name: Checkout source code
12+
uses: actions/checkout@v3
13+
14+
- name: Setup Node
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: 18.x
18+
19+
- name: Get version from package.json
20+
id: package-version
21+
run: |
22+
echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
23+
echo "Project Version: $VERSION"
24+
25+
- name: Cache node_modules
26+
uses: actions/cache@v3
27+
id: cache-npm-packages
28+
with:
29+
path: node_modules
30+
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }}
31+
32+
- name: Install NPM dependencies
33+
if: steps.cache-npm-packages.outputs.cache-hit != 'true'
34+
run: npm clean-install
35+
36+
- name: Run frontend unit tests
37+
run: npm run frontend:test
38+

0 commit comments

Comments
 (0)