Align GitHub Actions setup on Hibernate Search #1
Workflow file for this run
This file contains hidden or 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
# SPDX-License-Identifier: Apache-2.0 | |
# Copyright Red Hat Inc. and Hibernate Authors | |
# The main CI of Hibernate Validator is https://ci.hibernate.org/job/hibernate-validator/. | |
# However, Hibernate Validator builds run on GitHub actions regularly | |
# to build on Windows | |
# and check that both the Linux and Windows workflows still work | |
# and can be used in GitHub forks. | |
# See https://docs.github.com/en/actions | |
# for more information about GitHub actions. | |
name: GH Actions CI | |
on: | |
push: | |
branches: | |
# Pattern order matters: the last matching inclusion/exclusion wins | |
- '**' | |
- '!4.*' | |
- '!5.*' | |
- '!6.*' | |
- '!7.*' | |
- '!8.*' | |
- '!dependabot/**' | |
tags: | |
- '**' | |
pull_request: | |
types: [opened, synchronize, reopened, ready_for_review] | |
branches: | |
# Pattern order matters: the last matching inclusion/exclusion wins | |
- '**' | |
- '!4.*' | |
- '!5.*' | |
- '!6.*' | |
- '!7.*' | |
- '!8.*' | |
# Ignore dependabot PRs that are not just about build dependencies; | |
# we'll reject such dependant PRs and send a PR ourselves. | |
- '!dependabot/**' | |
- 'dependabot/maven/build-dependencies-**' | |
concurrency: | |
group: "workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}" | |
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.repository != 'hibernate/hibernate-validator' }} | |
defaults: | |
run: | |
shell: bash | |
env: | |
MAVEN_ARGS: "-e -B --settings .github/mvn-settings.xml --fail-at-end --no-transfer-progress" | |
TESTCONTAINERS_REUSE_ENABLE: true | |
jobs: | |
build: | |
name: ${{matrix.os.name}} | |
runs-on: ${{ matrix.os.runs-on }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- { | |
name: "Linux JDK 17", | |
runs-on: 'ubuntu-latest', | |
java: { | |
version: 17 | |
}, | |
maven: { | |
# Since we only start an Elasticsearch container on Linux we add the profile to enable container reuse here: | |
args: '-Pci-build' | |
} | |
} | |
# We can't start Linux containers on GitHub Actions' Windows VMs, | |
# so we can't run Elasticsearch tests. | |
# See https://github.com/actions/runner-images/issues/1143#issuecomment-972929995 | |
- { | |
name: "Windows JDK 17", | |
runs-on: 'windows-latest', | |
java: { | |
version: 17 | |
}, | |
maven: { | |
args: '-Dtest.elasticsearch.skip=true' | |
} | |
} | |
steps: | |
- name: Support longpaths on Windows | |
if: "startsWith(matrix.os.runs-on, 'windows')" | |
run: git config --global core.longpaths true | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
# Fetch the whole history to make sure that gitflow incremental builder | |
# can find the base commit. | |
fetch-depth: 0 | |
- name: Set up Java ${{ matrix.os.java.version }} | |
uses: actions/setup-java@v4 | |
with: | |
java-version: ${{ matrix.os.java.version }} | |
distribution: temurin | |
# https://github.com/actions/cache/blob/main/examples.md#java---maven | |
- name: Cache local Maven repository | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
# use a different key than workflows running in trusted mode | |
key: ${{ github.event_name == 'push' && 'trusted' || 'untrusted' }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ github.event_name == 'push' && 'trusted' || 'untrusted' }}-${{ runner.os }}-maven- | |
- name: Set up Maven | |
run: ./mvnw -v | |
- name: Build code and run tests and basic checks | |
run: | | |
./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean install \ | |
-Pjqassistant -Pdist -Prelocation | |
- name: Build code and run tests in container mode | |
run: | | |
./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean verify \ | |
-Pjqassistant -Pskip-checks \ | |
-am -pl :hibernate-validator-tck-runner \ | |
-Dincontainer -Dincontainer-prepared | |
- name: Omit produced artifacts from build cache | |
run: rm -r ~/.m2/repository/org/hibernate/validator |