Skip to content

Commit 0d34ea2

Browse files
authored
chore(ci): add GitHub Actions workflow for build and test (#4)
### Lab Phase & Objective This PR is a foundational task for **all phases**. The objective is to implement a Continuous Integration (CI) pipeline using GitHub Actions. This establishes an automated quality gate for the repository, ensuring that all code merged into the `main` branch is compiled and tested successfully. This is a core DevSecOps practice. ### Key Architectural Decisions & Trade-offs - **Trigger on `push` and `pull_request`:** The workflow runs on all PRs targeting `main` and on any direct pushes to `main`. This provides comprehensive protection for our primary branch. - **Maven Wrapper (`./mvnw`):** The CI job explicitly uses the Maven Wrapper. This guarantees that the build environment in the CI runner is 100% consistent with our local development environment, eliminating "works on my machine" issues. - **`clean verify` Goal:** Using the `verify` Maven lifecycle phase ensures the entire project is built, all unit and integration tests are executed, and the application is packaged. A failure in any of these steps will fail the build. - **Eclipse Temurin JDK:** Chose the Temurin distribution of OpenJDK as it is a vendor-neutral, TCK-certified, and enterprise-grade build, which is a best practice for stable CI pipelines. ### Verification Strategy - [ ] **Unit/Integration Tests:** The purpose of this PR *is* the test automation. Verification is done by observing the "Checks" section of this Pull Request. - [x] **CI/CD Pipeline:** The workflow defined in `.github/workflows/ci.yml` should execute and pass. A green checkmark in the PR's "Checks" section indicates success. - [ ] **Docker Compose:** N/A. - [ ] **Manual Verification:** N/A. ### Definition of Done Checklist - [x] The PR title follows the Conventional Commits specification (e.g., `chore: ...`). - [x] The code adheres to project conventions (YAML syntax is correct). - [x] The `README.md` does not require changes for this infrastructure update. - [x] All new logic is covered by automated tests. (This PR *is* the test automation). - [x] Security implications of the changes have been considered (secures the build process). - [ ] Observability implications (metrics, logs, traces) have been considered. (N/A for this change).
1 parent a0f4c34 commit 0d34ea2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Java CI with Maven
2+
3+
# This workflow will run on pushes to the 'main' branch and on pull requests targeting 'main'
4+
on:
5+
push:
6+
branches: [ "main" ]
7+
pull_request:
8+
branches: [ "main" ]
9+
10+
jobs:
11+
build:
12+
# The type of runner that the job will run on
13+
runs-on: ubuntu-latest
14+
15+
# Steps represent a sequence of tasks that will be executed as part of the job
16+
steps:
17+
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up JDK 21
22+
uses: actions/setup-java@v4
23+
with:
24+
java-version: '21'
25+
distribution: 'temurin'
26+
27+
# The build will fail if any tests fail, blocking the PR from merging.
28+
- name: Build and test with Maven
29+
run: ./mvnw -B clean verify

0 commit comments

Comments
 (0)