Skip to content

Commit 7633be2

Browse files
feat: Updated GitHub Workflows to run API tests on PR creation (#312)
* feat: Updated GitHub Workflows to run API tests on PR creation * fix: Updated InputSchemaServiceTest tests * chore: Update 'paths' for running API and E2E tests.
1 parent 3e235bb commit 7633be2

File tree

7 files changed

+89
-41
lines changed

7 files changed

+89
-41
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Devbox Setup
2+
description: Install devbox with caching and create required .env file
3+
4+
inputs:
5+
enable-cache:
6+
description: Enable devbox caching
7+
default: 'true'
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Create .env file
13+
run: touch .env
14+
shell: bash
15+
16+
- name: Install devbox
17+
uses: jetify-com/devbox-install-action@v0.12.0
18+
with:
19+
enable-cache: ${{ inputs.enable-cache }}

.github/workflows/deploy-builder-api.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,8 @@ jobs:
3131
- name: 'Checkout'
3232
uses: 'actions/checkout@v4'
3333

34-
# Devbox needs a .env file to exist, even if it's empty
35-
# TODO: Make this useful in this and other workflows by just consolidating env vars
36-
# here (so that we don't need to manage multiple places)
37-
- name: 'Create .env file'
38-
run: touch .env
39-
40-
# Setup devbox which includes all our dependencies: Maven, JDK 21, Quarkus, etc.
41-
- name: 'Install devbox'
42-
uses: 'jetify-com/devbox-install-action@v0.12.0'
43-
with:
44-
enable-cache: true
34+
- name: 'Setup devbox'
35+
uses: ./.github/actions/devbox-setup
4536

4637
# Cache Maven dependencies to speed up builds
4738
- name: 'Cache Maven dependencies'

.github/workflows/deploy-builder-frontend.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,8 @@ jobs:
2929
- name: Checkout repository
3030
uses: actions/checkout@v4
3131

32-
# Devbox needs a .env file to exist, even if it's empty
33-
- name: 'Create .env file'
34-
run: touch .env
35-
36-
# Setup devbox which includes Node.js, Firebase CLI, and Google Cloud SDK
37-
- name: 'Install devbox'
38-
uses: 'jetify-com/devbox-install-action@v0.12.0'
39-
with:
40-
enable-cache: true
32+
- name: 'Setup devbox'
33+
uses: ./.github/actions/devbox-setup
4134

4235
# Configure Workload Identity Federation and generate an access token
4336
- id: 'auth'

.github/workflows/deploy-library-api.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,8 @@ jobs:
2727
- name: 'Checkout'
2828
uses: 'actions/checkout@v4'
2929

30-
# Devbox needs a .env file to exist, even if it's empty
31-
- name: 'Create .env file'
32-
run: touch .env
33-
34-
# Setup devbox which includes all our dependencies: Maven, JDK 21, Quarkus, etc.
35-
- name: 'Install devbox'
36-
uses: 'jetify-com/devbox-install-action@v0.12.0'
37-
with:
38-
enable-cache: true
30+
- name: 'Setup devbox'
31+
uses: ./.github/actions/devbox-setup
3932

4033
# Cache Maven dependencies to speed up builds
4134
- name: 'Cache Maven dependencies'
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Run API Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "builder-api/**"
8+
- "library-api/**"
9+
pull_request:
10+
branches: [main]
11+
paths:
12+
- "builder-api/**"
13+
- "library-api/**"
14+
15+
jobs:
16+
builder-api-tests:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup devbox
23+
uses: ./.github/actions/devbox-setup
24+
25+
- name: Cache Maven dependencies
26+
uses: actions/cache@v4
27+
with:
28+
path: ~/.m2/repository
29+
key: ${{ runner.os }}-maven-builder-${{ hashFiles('builder-api/pom.xml') }}
30+
restore-keys: |
31+
${{ runner.os }}-maven-
32+
33+
- name: Run builder-api tests
34+
run: devbox run -- bash -c "cd builder-api && mvn test"
35+
36+
library-api-tests:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
42+
- name: Setup devbox
43+
uses: ./.github/actions/devbox-setup
44+
45+
- name: Cache Maven dependencies
46+
uses: actions/cache@v4
47+
with:
48+
path: ~/.m2/repository
49+
key: ${{ runner.os }}-maven-library-${{ hashFiles('library-api/pom.xml') }}
50+
restore-keys: |
51+
${{ runner.os }}-maven-
52+
53+
- name: Run library-api tests
54+
run: devbox run -- bash -c "cd library-api && mvn test"

.github/workflows/run-e2e-tests.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ on:
55
paths:
66
- "builder-frontend/**"
77
- "builder-api/**"
8+
- "library-api/**"
89
pull_request:
910
branches: [main]
1011
paths:
1112
- "builder-frontend/**"
1213
- "builder-api/**"
14+
- "library-api/**"
1315

1416
env:
1517
PROJECT_ID: "benefit-decision-toolkit-play"
@@ -34,19 +36,14 @@ jobs:
3436
node-version: lts/*
3537

3638
# 1) Devbox Setup #
37-
- name: "Create .env file" # Devbox needs a .env file to exist, even if it's empty
38-
run: touch .env
39+
- name: Setup devbox
40+
uses: ./.github/actions/devbox-setup
3941

4042
- name: Rename env files
4143
run: |
4244
mv builder-frontend/.env.example builder-frontend/.env
4345
mv builder-api/.env.example builder-api/.env
4446
45-
- name: "Install devbox" # Setup devbox which includes Node.js, Firebase CLI, and Google Cloud SDK
46-
uses: "jetify-com/devbox-install-action@v0.12.0"
47-
with:
48-
enable-cache: true
49-
5047
# 2) Prepare app dependencies #
5148
- name: "Cache Maven dependencies"
5249
# Cache Maven dependencies to speed up builds

builder-api/src/test/java/org/acme/service/InputSchemaServiceTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.databind.JsonNode;
44
import com.fasterxml.jackson.databind.ObjectMapper;
5+
56
import org.acme.model.domain.CheckConfig;
67
import org.acme.model.domain.FormPath;
78
import org.junit.jupiter.api.BeforeEach;
@@ -551,8 +552,8 @@ void extractJsonSchemaPaths_withTransformedSchema_extractsCorrectPaths() throws
551552

552553
List<FormPath> paths = service.extractJsonSchemaPaths(schema);
553554

554-
assertTrue(paths.contains(new FormPath("people.applicant.dateOfBirth", "string")));
555-
assertTrue(paths.contains(new FormPath("people.applicant.enrollments", "array")));
555+
assertTrue(paths.contains(new FormPath("people.applicant.dateOfBirth", "date")));
556+
assertTrue(paths.contains(new FormPath("people.applicant.enrollments", "array:string")));
556557
assertEquals(2, paths.size());
557558
}
558559

@@ -584,7 +585,7 @@ void extractJsonSchemaPaths_withEnrollmentOnlySchema_extractsCorrectPath() throw
584585

585586
List<FormPath> paths = service.extractJsonSchemaPaths(schema);
586587

587-
assertTrue(paths.contains(new FormPath("people.applicant.enrollments", "array")));
588+
assertTrue(paths.contains(new FormPath("people.applicant.enrollments", "array:string")));
588589
assertEquals(1, paths.size());
589590
}
590591

@@ -619,8 +620,8 @@ void extractJsonSchemaPaths_withMultiplePersonIds_extractsPathsForAll() throws E
619620

620621
List<FormPath> paths = service.extractJsonSchemaPaths(schema);
621622

622-
assertTrue(paths.contains(new FormPath("people.applicant.dateOfBirth", "string")));
623-
assertTrue(paths.contains(new FormPath("people.spouse.dateOfBirth", "string")));
623+
assertTrue(paths.contains(new FormPath("people.applicant.dateOfBirth", "date")));
624+
assertTrue(paths.contains(new FormPath("people.spouse.dateOfBirth", "date")));
624625
assertEquals(2, paths.size());
625626
}
626627
}

0 commit comments

Comments
 (0)