Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions .github/workflows/build-test-lint-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

# - name: Cache Maven dependencies
# uses: actions/cache@v3
# with:
# path: ~/.m2/repository
# key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
# restore-keys: |
# ${{ runner.os }}-maven-
cache: 'maven'

- name: Install dependencies
run: mvn clean install -DskipTests
run: chmod +x mvnw && ./mvnw clean install -DskipTests

- name: Run Tests
run: mvn test
run: ./mvnw test
env:
ENV: production
DATABASE_URL: ${{ secrets.DATABASE_URL }}
Expand All @@ -49,27 +42,36 @@ jobs:
MAIL_SERVICE_STARTTLS: ${{ secrets.MAIL_SERVICE_STARTTLS }}
MAIL_SERVICE_DOMAIN_NAME: ${{ secrets.MAIL_SERVICE_DOMAIN_NAME }}

- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports
path: |
target/surefire-reports/
target/site/jacoco/

# lint-and-format:
# runs-on: ubuntu-latest
# needs: build-and-test
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# uses: actions/checkout@v4
#
# - name: Set up JDK 17
# uses: actions/setup-java@v3
# uses: actions/setup-java@v4
# with:
# java-version: '17'
# distribution: 'temurin'
#
# - name: Run Checkstyle
# run: mvn checkstyle:check
# run: ./mvnw checkstyle:check
#
# - name: Run PMD
# run: mvn pmd:check
# run: ./mvnw pmd:check
#
# - name: Run SpotBugs
# run: mvn spotbugs:check
# run: ./mvnw spotbugs:check

# - name: Verify code formatting with Spotless (excluding Javadocs)
# run: mvn spotless:check -Dspotless.apply.skip
# run: ./mvnw spotless:check -Dspotless.apply.skip
46 changes: 46 additions & 0 deletions .github/workloads/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: LibraryMan-API CI Pipeline

# 1. Automated Triggers: Triggers on every push or PR to key branches
on:
push:
branches: [ "main", "Build", "Test", "Deploy", "CI" ]
pull_request:
branches: [ "main" ]

jobs:
pipeline:
runs-on: ubuntu-latest

steps:
# 2. Setup Phase
- name: Checkout Repository Code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven

# 3. Automation Phase
- name: Make Maven Wrapper Executable
run: chmod +x mvnw

- name: Build and Execute 111 Unit Tests
# This automates the build and test process within the pipeline
run: ./mvnw clean test

- name: Generate JaCoCo Coverage Report
# This generates the report for the "Accessible Reports" requirement
run: ./mvnw jacoco:report

# 4. Reporting Phase (Deliverables)
- name: Archive Test & Coverage Reports
if: always() # Ensures reports are uploaded even if tests fail
uses: actions/upload-artifact@v4
with:
name: assignment-reports
path: |
target/surefire-reports/
target/site/jacoco/
19 changes: 19 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,25 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
14 changes: 14 additions & 0 deletions pulls/2/description
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Fixes #1

Modernize the CI pipeline to produce accessible test and coverage reports as downloadable artifacts.

### Workflow (`build-test-lint-format.yml`)
- Upgrade `actions/checkout`, `actions/setup-java`, to **v4**
- Replace commented-out `actions/cache@v3` with `setup-java`'s built-in `cache: 'maven'`
- Switch from `mvn` to `./mvnw` for reproducible builds via the Maven wrapper
- Add `actions/upload-artifact@v4` (`if: always()`) to archive Surefire + JaCoCo reports

### Build (`pom.xml`)
- Add `jacoco-maven-plugin` 0.8.12 with `prepare-agent` and `report` goals bound to the `test` phase

After this, every push/PR run will produce a downloadable `test-reports` artifact containing `target/surefire-reports/` and `target/site/jacoco/.
Loading