adjusted Jenkinsfile for branch deployment #105
Workflow file for this run
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
# https://docs.github.com/en/actions | |
# The workflow is used for code quality and integrity checks for pushes on branches. | |
# Unfortunately, there is no way not to build on branch pushes when there are also builds on pull requests. | |
# https://github.community/t/how-to-trigger-an-action-on-push-or-pull-request-but-not-both/16662 | |
name: CI | Push on branches | |
on: | |
push: | |
branches: | |
- "**" | |
- "!master" | |
env: | |
CI: true | |
POSTGRES_DB: testing | |
POSTGRES_USER: testing | |
POSTGRES_PASSWORD: testing | |
POSTGRES_HOST: 127.0.0.1 | |
POSTGRES_PORT: 5432 | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:16 | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_DB: ${{ env.POSTGRES_DB }} | |
POSTGRES_USER: ${{ env.POSTGRES_USER }} | |
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }} | |
POSTGRES_HOST_AUTH_METHOD: trust | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '11' | |
cache: 'gradle' | |
- name: Setup Test ENV | |
run: mv conf-github-ci.json conf-test.json | |
- name: Cleanup | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: clean | |
- name: Spotless Check | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: spotlessCheck scoverageClasses | |
- name: Test | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: testClasses assemble reportScoverage | |
- name: Archive test report | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-report | |
path: build/reports/tests/test | |
- name: Archive test results (xml) | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-results | |
path: build/test-results/test/TEST-*.xml | |
- name: Archive code coverage results | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-report | |
path: build/reports/scoverage | |
- name: Test Report | |
uses: dorny/test-reporter@v1 | |
if: always() | |
with: | |
name: Unit/Integration Tests | |
path: build/test-results/test/TEST-*.xml | |
reporter: java-junit | |
list-suites: "all" | |
list-tests: "all" | |
fail-on-error: "true" | |
max-annotations: "10" | |
- name: Coverage Report | |
uses: 5monkeys/cobertura-action@master | |
with: | |
path: build/reports/scoverage/cobertura.xml | |
minimum_coverage: 80 | |
publish-test-results: | |
name: "Publish Unit Tests Results" | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
if: always() | |
steps: | |
- name: Download Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: Publish Unit Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
with: | |
files: artifacts/test-results/**/*.xml |