-
-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Pull Request Build - Java | ||
|
||
# Trigger the workflow on pull requests to the main branch | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Step 1: Check out the repository code | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
# Step 2: Set up JDK 11 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'adopt' | ||
|
||
# Step 3: Cache Maven dependencies (optional but recommended) | ||
- name: Cache Maven packages | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
# Step 4: Run Maven Verify | ||
- name: Run Maven Verify | ||
run: mvn verify | ||
continue-on-error: true # Allow the workflow to continue even if the build fails | ||
|
||
# Step 5: Upload test results (JUnit XML reports) if tests fail | ||
- name: Upload Test Results | ||
if: failure() # Only upload if the build failed | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: test-results | ||
path: target/surefire-reports/*.xml # Path to the test results | ||
|
||
# Step 6: Always upload the full logs to help debug failures | ||
- name: Upload Build Logs | ||
if: always() # Always upload logs, even if the build passes | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build-logs | ||
path: target/*.log |