chore: Update Java version to 21 and fix test setup #404
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
name: Build and Test | ||
on: | ||
push: | ||
branches: [ master, develop ] | ||
pull_request: | ||
branches: [ master, develop ] | ||
concurrency: | ||
group: build-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
env: | ||
java_version: '21' | ||
java_distribution: 'temurin' | ||
jobs: | ||
build_artifact: | ||
name: Build Artifact | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up Java ${{ env.java_version }} | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: ${{ env.java_version }} | ||
distribution: ${{ env.java_distribution }} | ||
cache: 'maven' | ||
- name: Build with Maven | ||
run: mvn -B package --file pom.xml "-DskipTests=true" "-Dmaven.javadoc.skip=true" "-Dcheckstyle.skipExec=true" | ||
- name: Upload Artifacts | ||
if: github.event_name == 'push' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: MiSim Jars | ||
path: ./target/*.jar | ||
run_tests: | ||
if: !contains(github.event.head_commit.message, '[maven-release-plugin]') | ||
name: Run Tests & Report | ||
runs-on: ubuntu-latest | ||
needs: build_artifact | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Java ${{ env.java_version }} | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: ${{ env.java_version }} | ||
distribution: ${{ env.java_distribution }} | ||
cache: 'maven' | ||
- name: Run JUnit Tests | ||
run: mvn -B test --file pom.xml "-Dcheckstyle.skipExec=true" | ||
- name: Upload Failed Test Results | ||
if: ${{ failure() }} | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: Failed Test Results | ||
path: | | ||
./target/surefire-reports | ||
./failed_test_results | ||
- name: Publish Test Report | ||
uses: dorny/test-reporter@v1 | ||
if: (success() || failure()) && (github.event.pull_request == '' || github.event.pull_request.head.repo.fork == false) | ||
with: | ||
name: Test Results (Dorny) | ||
reporter: 'java-junit' | ||
path: 'target/surefire-reports/*.xml' | ||
run_hello_world_Linux: | ||
if: "!contains(github.event.head_commit.message, '[maven-release-plugin]')" | ||
name: Run Hello World (Linux) | ||
runs-on: ubuntu-latest | ||
needs: run_tests | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Java ${{ env.java_version }} | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: ${{ env.java_version }} | ||
distribution: ${{ env.java_distribution }} | ||
cache: 'maven' | ||
- name: Run Hello World | ||
run: ./hello_world.sh | ||
run_hello_world_Windows: | ||
if: "!contains(github.event.head_commit.message, '[maven-release-plugin]')" | ||
name: Run Hello World (Windows) | ||
runs-on: windows-latest | ||
needs: run_tests | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Java ${{ env.java_version }} | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: ${{ env.java_version }} | ||
distribution: ${{ env.java_distribution }} | ||
cache: 'maven' | ||
- name: Run Hello World | ||
run: ./hello_world.bat |