Skip to content

Add a scheduler for GitHub workflows #587

Add a scheduler for GitHub workflows

Add a scheduler for GitHub workflows #587

Workflow file for this run

# 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-**'
# Allow calling this workflow from the scheduler
workflow_call:
inputs:
branch:
required: true
type: string
# Allow running this workflow manually
workflow_dispatch:
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 -Pci-build --no-transfer-progress"
TESTCONTAINERS_REUSE_ENABLE: true
permissions:
contents: read
jobs:
build:
name: ${{matrix.os.name}}
runs-on: ${{ matrix.os.runs-on }}
strategy:
fail-fast: false
matrix:
os:
- {
name: "Linux JDK 25",
runs-on: 'ubuntu-latest',
java: {
version: 25
},
maven: {
args: ''
}
}
- {
name: "Windows JDK 25",
runs-on: 'windows-latest',
java: {
version: 25
},
maven: {
args: ''
}
}
steps:
- name: Support longpaths on Windows
if: "startsWith(matrix.os.runs-on, 'windows')"
run: git config --global core.longpaths true
- name: Checkout ${{ inputs.branch }}
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # 6.0.0
with:
ref: ${{ inputs.branch }}
persist-credentials: false
- name: Set up Java ${{ matrix.os.java.version }}
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # 5.0.0
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@0057852bfaa89a56745cba8c7296529d2fc39830 # 4.3.0
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 (Standalone)
run: |
./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean install \
-Pjqassistant -Pdist
env:
DEVELOCITY_ACCESS_KEY: "${{ secrets.DEVELOCITY_ACCESS_KEY || '' }}"
DEVELOCITY_BASE_URL: "${{ env.DEVELOCITY_BASE_URL || 'https://develocity.commonhaus.dev' }}"
# For jobs running on 'pull_request', upload build scan data.
# The actual publishing must be done in a separate job (see ci-report.yml).
# We don't write to the remote cache as that would be unsafe.
- name: Upload GitHub Actions artifact for the Develocity build scan
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # 5.0.0
if: "${{ github.event_name == 'pull_request' && !cancelled() }}"
with:
name: build-scan-data-standalone-${{ matrix.os.name }}
path: ~/.m2/.develocity/build-scan-data
- name: Run TCK 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
env:
DEVELOCITY_ACCESS_KEY: "${{ secrets.DEVELOCITY_ACCESS_KEY || '' }}"
DEVELOCITY_BASE_URL: "${{ env.DEVELOCITY_BASE_URL || 'https://develocity.commonhaus.dev' }}"
- name: Upload GitHub Actions artifact for the Develocity build scan
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # 5.0.0
if: "${{ github.event_name == 'pull_request' && !cancelled() }}"
with:
name: build-scan-data-incontainer-${{ matrix.os.name }}
path: ~/.m2/.develocity/build-scan-data
- name: Notify the build failure
if: ${{ failure() && github.repository == 'hibernate/hibernate-validator'}}
uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2
with:
api-key: ${{ secrets.ZULIP_GITHUB_WORKFLOW_NOTIFICATION_API_KEY }}
email: ${{ secrets.ZULIP_GITHUB_WORKFLOW_NOTIFICATION_EMAIL }}
organization-url: "https://hibernate.zulipchat.com"
type: "stream"
to: "hibernate-validator-dev"
topic: "GitHub workflow failures"
content: "The GitHub [build #${{github.run_id}}](https://github.com/hibernate/hibernate-validator/actions/runs/${{github.run_id}}) failed and requires your attention :warning:"
- name: Omit produced artifacts from build cache
run: rm -r ~/.m2/repository/org/hibernate/validator