-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added JUnit as part of reusable pipeline
- Loading branch information
1 parent
fa601b8
commit 97f036d
Showing
2 changed files
with
48 additions
and
75 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 |
---|---|---|
|
@@ -11,7 +11,14 @@ on: | |
description: 'Unique version which should be used in next step(s) for CodeDeploy artifact (e.g. 20230528-144100_d63fd762704ef242d9827662b872b305744f753e)' | ||
value: ${{ jobs.main.outputs.codedeploy-artifact-version }} | ||
|
||
|
||
permissions: | ||
checks: write # for junit reporting | ||
pull-requests: write # for jacoco PR comments | ||
|
||
env: | ||
MIN_COVERAGE_OVERALL: 25 | ||
MIN_COVERAGE_CHANGED_FILES: 65 | ||
SERVICE_JAR_DIR: ${{ github.workspace }}/build/libs | ||
CODEDEPLOY_DIR: ${{ github.workspace }}/deployment/codedeploy | ||
GITHUB_CODEDEPLOY_ARTIFACT_NAME: codedeploy-artifact | ||
|
@@ -23,6 +30,20 @@ jobs: | |
pipeline-artifact-name: ${{ steps.save-artifact-name.outputs.name }} | ||
app-version: ${{ steps.save-app-version.outputs.version }} | ||
codedeploy-artifact-version: ${{ steps.save-artifact-version.outputs.version }} | ||
services: | ||
postgres: | ||
image: postgis/postgis # Postgres with PostGIS extension | ||
env: | ||
POSTGRES_PASSWORD: password | ||
POSTGRES_USER: postgres | ||
POSTGRES_DB: postgres | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432:5432 | ||
steps: | ||
- run: echo "[${{ github.triggering_actor }}] triggered [${{ github.event_name }}] event on ${{ github.ref_type }}/PR# [${{ github.ref_name }}]" | ||
- run: echo "🎉 This job is running on a ${{ runner.os }} server hosted by GitHub!" | ||
|
@@ -31,16 +52,36 @@ jobs: | |
- name: Setup Java | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: adopt | ||
java-version: 17 | ||
java-package: jdk | ||
cache: gradle | ||
### TODO : Include JUnit tests & verify code coverage | ||
- name: Build package, execute tests & verify overall coverage | ||
distribution: 'temurin' | ||
java-version: '17' | ||
java-package: 'jdk' | ||
cache: 'gradle' | ||
- name: Setup Gradle | ||
uses: gradle/gradle-build-action@v2 | ||
with: | ||
arguments: shadowJar -x test | ||
gradle-version: 8.2 | ||
### Build, Test, Coverage Verification | ||
- name: Build fat jar, including Unit tests, coverage verification | ||
run: gradle shadowJar jacocoTestReport jacocoTestCoverageVerification | ||
- name: Publish Test Report | ||
uses: mikepenz/action-junit-report@v4 | ||
if: success() || failure() # always run even if the previous step fails | ||
with: | ||
report_paths: '**/build/test-results/test/TEST-*.xml' | ||
- name: Publish code coverage report as PR comment | ||
id: jacoco | ||
uses: madrapps/[email protected] | ||
with: | ||
paths: '**/build/reports/jacoco/test/jacocoTestReport.xml' | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
min-coverage-overall: $MIN_COVERAGE_OVERALL | ||
min-coverage-changed-files: $MIN_COVERAGE_CHANGED_FILES | ||
title: Code Coverage | ||
- name: Fail when coverage of changed files is too low | ||
run: | | ||
CHANGED_FILES_FAILED=$(echo '${{ steps.jacoco.outputs.coverage-changed-files }} < ${{ env.MIN_COVERAGE_CHANGED_FILES }}' | bc) | ||
[[ $CHANGED_FILES_FAILED -ne 0 ]] && echo 'Changed files coverage ${{ steps.jacoco.outputs.coverage-changed-files }}% is smaller than required ${{ env.MIN_COVERAGE_CHANGED_FILES }}%' | ||
[[ $CHANGED_FILES_FAILED -ne 0 ]] && exit 1 || exit 0 | ||
- name: List generated artifacts | ||
run: | | ||
ls -l $SERVICE_JAR_DIR/* | ||
|
This file was deleted.
Oops, something went wrong.