Skip to content

Commit 859e496

Browse files
committed
chore: test builds
1 parent f1f90ae commit 859e496

1 file changed

Lines changed: 100 additions & 0 deletions

File tree

.github/workflows/test-build.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Test Build
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- "release/**"
8+
9+
permissions:
10+
contents: read
11+
checks: write
12+
pull-requests: write
13+
packages: write
14+
15+
jobs:
16+
build-and-test:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
pr_number: ${{ github.event.pull_request.number }}
20+
short_sha: ${{ steps.short_sha.outputs.short_sha }}
21+
steps:
22+
- name: Checkout Repository
23+
uses: actions/checkout@v4
24+
25+
- name: Get Short SHA
26+
id: short_sha
27+
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
28+
29+
- name: Set up JDK
30+
uses: actions/setup-java@v4
31+
with:
32+
java-version: "21"
33+
distribution: "corretto"
34+
cache: "maven"
35+
36+
- name: Cache Maven packages
37+
uses: actions/cache@v4
38+
with:
39+
path: |
40+
~/.m2/repository
41+
!~/.m2/repository/org/devgateway/tcdi
42+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
43+
restore-keys: |
44+
${{ runner.os }}-maven-
45+
46+
- name: Build and Test
47+
run: mvn -B verify -Dcheckstyle.skip=true -Dtest='!**/DatasetClientTest' --file pom.xml
48+
49+
- name: Publish Test Results
50+
uses: EnricoMi/publish-unit-test-result-action@v2
51+
if: always()
52+
with:
53+
files: |
54+
**/target/surefire-reports/*.xml
55+
56+
- name: Upload Build Artifacts
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: build-artifacts
60+
path: |
61+
**/target/*.jar
62+
retention-days: 7
63+
64+
build-and-push-docker-image:
65+
needs: build-and-test
66+
runs-on: ubuntu-latest
67+
steps:
68+
- name: Checkout Repository
69+
uses: actions/checkout@v4
70+
71+
- name: Set up QEMU
72+
uses: docker/setup-qemu-action@v3
73+
with:
74+
platforms: linux/amd64,linux/arm64
75+
76+
- name: Set up Docker Buildx
77+
uses: docker/setup-buildx-action@v2
78+
79+
- name: Login to Docker Registry
80+
uses: docker/login-action@v3
81+
with:
82+
registry: ${{ vars.DOCKER_REGISTRY }}
83+
username: ${{ secrets.DOCKER_USERNAME }}
84+
password: ${{ secrets.DOCKER_PASSWORD }}
85+
86+
- name: Build and push Docker image
87+
uses: docker/build-push-action@v6
88+
with:
89+
platforms: linux/amd64,linux/arm64
90+
cache-from: type=gha, scope=data-viz-admin
91+
cache-to: type=gha, scope=data-viz-admin
92+
context: .
93+
push: true
94+
build-args: |
95+
VERSION=pr-${{ needs.build-and-test.outputs.pr_number }}
96+
TAG=${{ needs.build-and-test.outputs.short_sha }}
97+
GIT_BRANCH=${{ github.head_ref }}
98+
tags: |
99+
${{ vars.DOCKER_REGISTRY }}/data-viz-admin:pr-${{ needs.build-and-test.outputs.pr_number }}
100+
${{ vars.DOCKER_REGISTRY }}/data-viz-admin:pr-${{ needs.build-and-test.outputs.pr_number }}-${{ needs.build-and-test.outputs.short_sha }}

0 commit comments

Comments
 (0)