diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f9b0a1f2e..d9e2eb77e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,24 +2,65 @@ name: Build and Test on: push: - branches: [main] + branches: + - "*" # Trigger on all branches + pull_request: + branches: [main] # Trigger on pull requests to the 'main' branch jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-latest # Use the latest version of Ubuntu as the runner steps: - - name: Checkout code - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v2 # Checkout your repository's code - - name: Set up JDK 17 - uses: actions/setup-java@v2 - with: - java-version: '17' - distribution: 'adopt' + - name: Set up JDK 17 + uses: actions/setup-java@v2 # Set up Java Development Kit (JDK) version 17 + with: + java-version: "17" + distribution: "adopt" - - name: Build with Maven - run: mvn -B package --file pom.xml - - name: Run tests with Maven - run: mvn -B test --file pom.xml + - name: Build with Maven + run: mvn -B package --file pom.xml + # Build your project using Maven in non-interactive mode and specify the POM file. + + - name: Run tests with Maven + run: mvn -B test --file pom.xml + # Run tests using Maven in non-interactive mode and specify the POM file. + + # Store build artifacts for history + - name: Archive Build Artifacts + uses: actions/upload-artifact@v2 # Upload build artifacts to the workflow + with: + name: build-artifacts # Name for the uploaded artifacts + path: target/ # Path to the build artifacts (typically 'target/' for Maven) + + # Static Code Analysis with Checkstyle + - name: Static Code Analysis with Checkstyle + run: | + # Install and run Checkstyle + mvn org.apache.maven.plugins:maven-checkstyle-plugin:3.1.1:checkstyle + # Run Checkstyle using Maven. + mvn checkstyle:check + + # Store static code analysis reports + - name: Archive Static Code Analysis Reports + uses: actions/upload-artifact@v2 + with: + name: static-code-analysis-reports + path: target/checkstyle-result.xml # Path to the Checkstyle report. + + # Code Coverage + - name: Code Coverage + run: | + # Run JaCoCo report generation + mvn jacoco:report + + # Store code coverage reports + - name: Archive Code Coverage Reports + uses: actions/upload-artifact@v2 + with: + name: code-coverage-reports + path: target/site/jacoco/ # Path to the code coverage report. diff --git a/pom.xml b/pom.xml index ce92ea579..b17d77958 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 org.springframework.samples spring-petclinic @@ -33,6 +35,7 @@ 0.0.11 0.0.39 + @@ -166,7 +169,8 @@ - This build requires at least Java ${java.version}, update your JVM, and run the build again + This build requires at least Java ${java.version}, update your JVM, and + run the build again ${java.version} @@ -191,6 +195,9 @@ org.apache.maven.plugins maven-checkstyle-plugin ${maven-checkstyle.version} + + false + com.puppycrawl.tools @@ -370,7 +377,8 @@ ${basedir}/src/main/scss/ ${basedir}/src/main/resources/static/resources/css/ - ${project.build.directory}/webjars/META-INF/resources/webjars/bootstrap/${webjars-bootstrap.version}/scss/ + + ${project.build.directory}/webjars/META-INF/resources/webjars/bootstrap/${webjars-bootstrap.version}/scss/ @@ -408,7 +416,7 @@ - + ˇˇ org.springframework.boot spring-boot-maven-plugin @@ -444,4 +452,4 @@ - + \ No newline at end of file