Skip to content

Merge pull request #38 from kiblykat/snyk-upgrade-f769e2bade115083c96… #154

Merge pull request #38 from kiblykat/snyk-upgrade-f769e2bade115083c96…

Merge pull request #38 from kiblykat/snyk-upgrade-f769e2bade115083c96… #154

Workflow file for this run

# This workflow will build a Java Spring Boot Application with Maven then run test cases.
name: Build and Test Java Spring Boot Application
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
build-and-run-tests:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
# POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_DB: the_review_room
# Set health checks to wait until Postgres has started.
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps the TCP port 5432 on the service container to the host.
- 5432:5432
steps:
- name: Pull repository
uses: actions/[email protected]
- name: Set up JDK
uses: actions/[email protected]
with:
java-version: "21"
distribution: "temurin"
# Uncomment and configure if needed.
# cache: maven
# The Maven basic phases in order: Validate, Compile, Test, Package, Verify, Install, Deploy.
# The verify command executes each default lifecycle phase in order (validate, compile, package, etc.), before executing verify.
# In most cases the effect is the same as package. However, in case there are integration tests, these will be executed as well.
# During the verify phase some additional checks can be done, e.g. if your code is written according to the predefined checkstyle rules.
# If you want to run your integration tests and check it, use verify. If you only want to run unit tests, use test.
# This does not seem to generate HTML reports, just the normal text reports.
- name: Build and run unit tests
# run: mvn test
run: mvn verify
- name: Generate HTML test report
# This does not rebuild, and uses the last successful build, to the test cases might not be updated.
run: mvn surefire-report:report
# Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive (Optional).
# - name: Update dependency graph
# uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
# - name: Build Jar file
# # Skip tests since they were already run.
# run: mvn package -DskipTests
- name: Upload the generated application jar file artifact
uses: actions/[email protected]
with:
name: the-review-room-0.0.1-SNAPSHOT
path: target/the-review-room-0.0.1-SNAPSHOT.jar
retention-days: 7
- name: Upload the test report artifacts
uses: actions/[email protected]
if: ${{ always() }}
with:
name: test-report
# path: '**/target/*-reports/TEST*.xml'
path: "**/target/*-reports/**"
if-no-files-found: error
retention-days: 7
- name: Upload the HTML test report artifacts
uses: actions/[email protected]
if: ${{ always() }}
with:
name: html-test-report
path: "**/target/site/**"
if-no-files-found: error
retention-days: 7
- name: Upload the application and test log file artifacts
uses: actions/[email protected]
if: ${{ always() }}
with:
name: application-and-test-logs
path: "**/logs/**"
if-no-files-found: error
retention-days: 7