Skip to content

Commit

Permalink
feat(build): added test.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
zZHorizonZz committed Aug 7, 2024
1 parent cadc2fa commit f12e799
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Run Tests

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

permissions:
contents: read

env:
JAVA_VERSION: "21"
DISTRIBUTION: "corretto"

jobs:
test:
strategy:
matrix:
include:
- type: jvm
build_args: ""
- type: native
build_args: "-Dnative"
name: Run ${{ matrix.type }} Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Cache Maven Dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.DISTRIBUTION }}
cache: maven

- name: Run Tests
run: mvn clean test ${{ matrix.build_args }}

- name: Output Test Results
if: always()
run: |
echo "${{ matrix.type }} Test Results:" >> $GITHUB_STEP_SUMMARY
echo "```" >> $GITHUB_STEP_SUMMARY
if [[ -f "target/surefire-reports/TEST-*.xml" ]]; then
mvn surefire-report:report-only -DshowSuccess=true | awk '
BEGIN { inTestSection = 0; }
/-------------------------------------------------------/ {
if (inTestSection) {
print ""; # Add blank line after each test section
}
inTestSection = 1;
print; # Print the test section header
}
inTestSection { print; } # Print test results within a section
' >> $GITHUB_STEP_SUMMARY
else
echo "No test results found." >> $GITHUB_STEP_SUMMARY
fi
echo "```" >> $GITHUB_STEP_SUMMARY

0 comments on commit f12e799

Please sign in to comment.