Skip to content

Commit f084200

Browse files
committed
add integration tests and docker build
1 parent 4eac772 commit f084200

1 file changed

Lines changed: 89 additions & 6 deletions

File tree

.github/workflows/mvn-test-package.yml

Lines changed: 89 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,103 @@ on:
1313
tags: [ '*.*.*' ]
1414

1515
jobs:
16-
build:
16+
maven-build:
1717
runs-on: ubuntu-latest
1818

1919
steps:
2020
- uses: actions/checkout@v4
21-
- name: Set up JDK 17
21+
- name: Set up JDK 21
2222
uses: actions/setup-java@v4
2323
with:
2424
java-version: '21'
2525
distribution: 'temurin'
2626
cache: maven
27-
- name: Build with Maven
28-
run: mvn -B test package --file pom.xml
29-
30-
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
27+
- name: Extract Maven project version
28+
run: |
29+
echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
30+
id: get_version
31+
- name: Build and Test
32+
id: build-and-test
33+
run: mvn -s .github/maven/settings.xml --batch-mode --update-snapshots test
34+
continue-on-error: true
35+
- name: Upload test logs if tests failed
36+
if: steps.build-and-test.outcome != 'success'
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: surefire-reports
40+
path: target/surefire-reports/
41+
- name: Fail build if tests failed
42+
if: steps.build-and-test.outcome != 'success'
43+
run: exit 1
44+
- name: Integration Tests
45+
id: integration-tests
46+
run: mvn -s .github/maven/settings.xml --batch-mode --update-snapshots verify -DskipTests=true
47+
continue-on-error: true
48+
- name: Upload test logs if tests failed
49+
if: steps.integration-tests.outcome != 'success'
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: failsafe-reports
53+
path: target/failsafe-reports/
54+
- name: Fail build if tests failed
55+
if: steps.integration-tests.outcome != 'success'
56+
run: exit 1
57+
- name: Package
58+
run: |
59+
mvn -s .github/maven/settings.xml --batch-mode --update-snapshots -DskipTests=true package
60+
- uses: actions/cache@v4
61+
with:
62+
path: .
63+
key: builddir-${{ github.run_id }}
64+
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
3165
- name: Update dependency graph
3266
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
67+
68+
docker-publish:
69+
name: Docker Build and Publish
70+
if: github.ref_name == 'develop' || github.ref_name == '*.*.*'
71+
needs: maven-build
72+
runs-on: ubuntu-latest
73+
permissions:
74+
contents: read
75+
packages: write
76+
77+
steps:
78+
- uses: actions/cache@v4
79+
with:
80+
path: .
81+
key: builddir-${{ github.run_id }}
82+
83+
- name: Set up Docker Buildx
84+
uses: docker/setup-buildx-action@v2
85+
86+
# Login against a Docker registry except on PR
87+
# https://github.com/docker/login-action
88+
- name: Log into registry ${{ env.REGISTRY }}
89+
if: github.event_name != 'pull_request'
90+
uses: docker/login-action@v2
91+
with:
92+
registry: ${{ env.REGISTRY }}
93+
username: ${{ github.actor }}
94+
password: ${{ secrets.GITHUB_TOKEN }}
95+
96+
# Extract metadata (tags, labels) for Docker
97+
# https://github.com/docker/metadata-action
98+
- name: Extract Docker metadata
99+
id: meta
100+
uses: docker/metadata-action@v4
101+
with:
102+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
103+
104+
# Build and push Docker image with Buildx (don't push on PR)
105+
# https://github.com/docker/build-push-action
106+
- name: Build and push Docker image
107+
uses: docker/build-push-action@v6
108+
with:
109+
context: .
110+
file: docker/Dockerfile
111+
platforms: linux/amd64,linux/arm64
112+
build-args: TAG=${{needs.maven-build.outputs.version}}
113+
push: ${{ github.event_name != 'pull_request' }}
114+
tags: ${{ steps.meta.outputs.tags }}
115+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)