Skip to content

Commit e34a7be

Browse files
committed
Add pull request pipeline
Add test workflow to Artifact, Pull Request, and Build and publish workflows. Refactor build steps into build.yml
1 parent 9a865f9 commit e34a7be

File tree

5 files changed

+52
-16
lines changed

5 files changed

+52
-16
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ name: Build
22

33
on:
44
workflow_call:
5-
inputs:
6-
node-version:
7-
required: false
8-
type: string
9-
default: '18.x'
105

116
jobs:
127
build:

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ env:
1212
CI: false
1313

1414
jobs:
15-
run-build:
16-
uses: ./.github/workflows/build-reusable.yml
15+
test:
16+
uses: ./.github/workflows/test.yml
17+
18+
build:
19+
uses: ./.github/workflows/build.yml
20+
needs: test
1721

1822
deploy:
1923
runs-on: ubuntu-22.04
20-
needs: run-build
24+
needs: build
2125
steps:
2226
- name: Checkout source code
2327
uses: actions/checkout@v3

.github/workflows/github.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ on:
99
workflow_dispatch:
1010

1111
jobs:
12+
test:
13+
uses: ./.github/workflows/test.yml
14+
1215
build:
1316
name: Build image
1417
runs-on: ubuntu-22.04
18+
needs: test
1519

1620
steps:
1721
- name: Set env variables

.github/workflows/pr.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
name: Build and test Pull Request
1+
name: Pull Request checks
22

33
on:
44
pull_request:
55

66
jobs:
7-
run-build:
8-
uses: ./.github/workflows/build-reusable.yml
7+
build:
8+
uses: ./.github/workflows/build.yml
99

1010
test:
11-
runs-on: ubuntu-22.04
12-
needs: run-build
13-
steps:
14-
- name: Run unit tests
15-
run: npm run frontend:test
11+
uses: ./.github/workflows/test.yml
1612

.github/workflows/test.yml

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

0 commit comments

Comments
 (0)