Skip to content

Commit 2adec4a

Browse files
committed
HV-2021 Add simple GH actions to build Hibernate Validator
1 parent 6c0a02b commit 2adec4a

File tree

3 files changed

+218
-0
lines changed

3 files changed

+218
-0
lines changed

.github/mvn-settings.xml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
3+
<servers>
4+
<server>
5+
<id>google-maven-central</id>
6+
<configuration>
7+
<timeout>10000</timeout> <!-- milliseconds -->
8+
</configuration>
9+
</server>
10+
</servers>
11+
<profiles>
12+
<profile>
13+
<id>google-mirror</id>
14+
<repositories>
15+
<repository>
16+
<id>google-maven-central</id>
17+
<name>GCS Maven Central mirror EU</name>
18+
<url>https://maven-central.storage-download.googleapis.com/maven2/</url>
19+
<releases>
20+
<enabled>true</enabled>
21+
</releases>
22+
<snapshots>
23+
<enabled>false</enabled>
24+
</snapshots>
25+
</repository>
26+
</repositories>
27+
<pluginRepositories>
28+
<pluginRepository>
29+
<id>google-maven-central</id>
30+
<name>GCS Maven Central mirror EU</name>
31+
<url>https://maven-central.storage-download.googleapis.com/maven2/</url>
32+
<releases>
33+
<enabled>true</enabled>
34+
</releases>
35+
<snapshots>
36+
<enabled>false</enabled>
37+
</snapshots>
38+
</pluginRepository>
39+
</pluginRepositories>
40+
</profile>
41+
<profile>
42+
<id>jakarta-ee-staging</id>
43+
<repositories>
44+
<repository>
45+
<id>jakarta-ee-staging</id>
46+
<url>https://jakarta.oss.sonatype.org/content/repositories/staging/</url>
47+
<layout>default</layout>
48+
<releases>
49+
<enabled>true</enabled>
50+
<updatePolicy>never</updatePolicy>
51+
</releases>
52+
<snapshots>
53+
<enabled>false</enabled>
54+
</snapshots>
55+
</repository>
56+
</repositories>
57+
</profile>
58+
</profiles>
59+
<activeProfiles>
60+
<activeProfile>google-mirror</activeProfile>
61+
<activeProfile>jakarta-ee-staging</activeProfile>
62+
</activeProfiles>
63+
</settings>

.github/workflows/build.yml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# Copyright Red Hat Inc. and Hibernate Authors
3+
4+
# The main CI of Hibernate Validator is https://ci.hibernate.org/job/hibernate-validator/.
5+
# However, Hibernate Validator builds run on GitHub actions regularly
6+
# to build on Windows
7+
# and check that both the Linux and Windows workflows still work
8+
# and can be used in GitHub forks.
9+
# See https://docs.github.com/en/actions
10+
# for more information about GitHub actions.
11+
12+
name: GitHub Actions Build
13+
14+
on:
15+
push:
16+
branches:
17+
# Pattern order matters: the last matching inclusion/exclusion wins
18+
- '**'
19+
- '!4.*'
20+
- '!5.*'
21+
- '!6.*'
22+
- '!7.*'
23+
- '!8.*'
24+
- '!dependabot/**'
25+
tags:
26+
- '**'
27+
# WARNING: Using pull_request_target to access secrets, but we check out the merge commit.
28+
# See checkout action for details.
29+
pull_request_target:
30+
types: [opened, synchronize, reopened, ready_for_review]
31+
branches:
32+
# Pattern order matters: the last matching inclusion/exclusion wins
33+
- '**'
34+
- '!4.*'
35+
- '!5.*'
36+
- '!6.*'
37+
- '!7.*'
38+
- '!8.*'
39+
# Ignore dependabot PRs that are not just about build dependencies;
40+
# we'll reject such dependant PRs and send a PR ourselves.
41+
- '!dependabot/**'
42+
- 'dependabot/maven/build-dependencies-**'
43+
44+
concurrency:
45+
group: "workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}"
46+
cancel-in-progress: ${{ github.event_name == 'pull_request_target' || github.repository != 'hibernate/hibernate-validator' }}
47+
48+
defaults:
49+
run:
50+
shell: bash
51+
52+
env:
53+
MAVEN_ARGS: "-e -B --settings .github/mvn-settings.xml --fail-at-end"
54+
TESTCONTAINERS_REUSE_ENABLE: true
55+
56+
jobs:
57+
build:
58+
name: ${{matrix.os.name}}
59+
runs-on: ${{ matrix.os.runs-on }}
60+
strategy:
61+
fail-fast: false
62+
matrix:
63+
os:
64+
- {
65+
name: "Linux JDK 17",
66+
runs-on: 'ubuntu-latest',
67+
java: {
68+
version: 17
69+
},
70+
maven: {
71+
args: '-Pci-build --no-transfer-progress'
72+
}
73+
}
74+
- {
75+
name: "Windows JDK 17",
76+
runs-on: 'windows-latest',
77+
java: {
78+
version: 17
79+
},
80+
maven: {
81+
args: '-Pci-build --no-transfer-progress'
82+
}
83+
}
84+
steps:
85+
- name: Support longpaths on Windows
86+
if: "startsWith(matrix.os.runs-on, 'windows')"
87+
run: git config --global core.longpaths true
88+
- name: Check out commit already pushed to branch
89+
if: "! github.event.pull_request.number"
90+
uses: actions/checkout@v4
91+
- name: Check out PR head
92+
uses: actions/checkout@v4
93+
if: github.event.pull_request.number
94+
with:
95+
# WARNING: This is potentially dangerous since we're checking out unreviewed code,
96+
# and since we're using the pull_request_target event we can use secrets.
97+
# Thus, we must be extra careful to never expose secrets to steps that execute this code,
98+
# and to strictly limit our set of secrets to those that only pose minor security threats.
99+
# This means in particular we won't expose Develocity credentials to the main maven executions,
100+
# but instead will execute maven a third time just to push build scans to Develocity; (once we have scans enabled)
101+
ref: "refs/pull/${{ github.event.pull_request.number }}/head"
102+
- name: Set up Java ${{ matrix.os.java.version }}
103+
uses: actions/setup-java@v4
104+
with:
105+
java-version: ${{ matrix.os.java.version }}
106+
distribution: temurin
107+
# https://github.com/actions/cache/blob/main/examples.md#java---maven
108+
- name: Cache local Maven repository
109+
uses: actions/cache@v4
110+
with:
111+
path: ~/.m2/repository
112+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
113+
restore-keys: |
114+
${{ runner.os }}-maven-
115+
- name: Set up Maven
116+
run: ./mvnw -v
117+
118+
- name: Build code and run tests and basic checks
119+
run: |
120+
./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean install \
121+
-Pjqassistant -Pdist -Prelocation
122+
123+
- name: Build code and run tests in container mode
124+
run: |
125+
./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean verify \
126+
-Pjqassistant -Pskip-checks \
127+
-am -pl :hibernate-validator-tck-runner \
128+
-Dincontainer -Dincontainer-prepared
129+
# Workaround for https://github.com/actions/upload-artifact/issues/240
130+
- name: List build reports to upload (if build failed)
131+
if: ${{ failure() || cancelled() }}
132+
# The weird syntax is because we're setting a multiline environment variable
133+
# See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-multiline-string
134+
run: |
135+
{
136+
echo 'buildReportPaths<<EOF'
137+
find . -path '**/*-reports'
138+
echo EOF
139+
} >> "$GITHUB_ENV"
140+
- name: Upload build reports (if build failed)
141+
uses: actions/upload-artifact@v4
142+
if: ${{ failure() || cancelled() }}
143+
with:
144+
name: ${{ format('build-reports-{0}', matrix.os.name ) }}
145+
path: ${{ env.buildReportPaths }}
146+
retention-days: 7

pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,6 +1843,15 @@
18431843
<goal.formatter-maven-plugin>validate</goal.formatter-maven-plugin>
18441844
</properties>
18451845
</profile>
1846+
<profile>
1847+
<id>skip-checks</id>
1848+
<properties>
1849+
<enforcer.skip>true</enforcer.skip>
1850+
<checkstyle.skip>true</checkstyle.skip>
1851+
<format.skip>true</format.skip>
1852+
<forbiddenapis.skip>true</forbiddenapis.skip>
1853+
</properties>
1854+
</profile>
18461855
<profile>
18471856
<id>IDEA</id>
18481857
<activation>

0 commit comments

Comments
 (0)