blob: ad8bec7aeb37b5bfdbbffc81c7b4c8022a03fd71 [file] [log] [blame]
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: Verify
on:
workflow_call:
inputs:
maven-args:
description: The arguments to pass to all Maven commands when building the code
required: false
default: '-D"invoker.streamLogsOnFailures"'
type: string
os-matrix:
description: os matrix as json array
required: false
default: '[ "ubuntu-latest", "windows-latest", "macos-latest" ]'
type: string
jdk-matrix:
description: jdk matrix as json array
required: false
default: '[ "17", "21", "8" ]'
type: string
jdk-distribution-matrix:
description: jdk distribution matrix
required: false
default: '[ "zulu" ]'
type: string
maven-matrix:
description: The Maven version matrix as json array
required: false
default: '[ "3.6.3", "3.9.8" ]'
type: string
maven4-version:
description: The Maven 4.x version matrix
required: false
default: '4.0.0-beta-3'
type: string
maven4-enabled:
description: Determinate if use Maven 4 in build matrix
required: false
default: false
type: boolean
matrix-include:
description: include for matrix as json
required: false
default: '[]'
type: string
matrix-exclude:
description: exclude for matrix as json
required: false
default: '[]'
type: string
matrix-enabled:
description: Determinate if use matrix build
required: false
default: true
type: boolean
max-parallel:
description: max parallel jobs
required: false
default: 20
type: number
timeout-minutes:
description: timeout-minutes used by the builds (defaults to 360)
required: false
default: 360
type: number
# fail fast job setup
ff-run:
description: Determines should fail-fast-build run at all
required: false
default: true
type: boolean
ff-os:
description: The os used during fail-fast-build job
required: false
default: 'ubuntu-latest'
type: string
ff-maven:
description: The Maven version used during fail-fast-build job
required: false
default: '3.9.8'
type: string
ff-jdk:
description: The jdk version used during fail-fast-build job
required: false
default: '17'
type: string
ff-jdk-distribution:
description: The jdk distribution used during fail-fast-build job
required: false
default: 'zulu'
type: string
ff-goal:
description: The Maven goal used by fail-fast-build job
required: false
default: '-P run-its verify'
type: string
ff-site-run:
description: Determines should fail-fast-build run site step
required: false
default: true
type: boolean
ff-site-goal:
description: The Maven goal used by fail-fast-build job to build site
required: false
default: '-DskipTests -P reporting site site:stage'
type: string
ff-timeout-minutes:
description: timeout-minutes used by fail-fast-build jobs (defaults to 360)
required: false
default: 360
type: number
verify-goal:
description: The Maven goal used by verfy jobs
required: false
default: '-P run-its verify'
type: string
verify-fail-fast:
description: Determinate if verification matrix should fail fast
required: false
default: true
type: boolean
failure-upload-path:
description: A file, directory or wildcard pattern that describes what to upload on failure
required: false
type: string
install-mercurial:
description: Ensure all build images have Mercurial(hg) installed
required: false
default: false
type: boolean
install-gpg:
description: Ensure all build images have GnuPG installed
required: false
default: false
type: boolean
# allow single build per branch or PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# clare all permissions for GITHUB_TOKEN
permissions: {}
jobs:
# verify build on one node - before matrix will start
fail-fast-build:
name: ${{ inputs.ff-os }} jdk-${{ inputs.ff-jdk }}-${{ inputs.ff-jdk-distribution }} ${{ inputs.ff-maven }}
runs-on: ${{ inputs.ff-os }}
timeout-minutes: ${{ inputs.ff-timeout-minutes }}
# execute on any push or pull request from forked repo
if: inputs.ff-run && ( github.event_name == 'push' || ( github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork ) )
steps:
- name: Show free disk space
run: df -h
shell: bash
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.ff-jdk }}
distribution: ${{ inputs.ff-jdk-distribution }}
cache: 'maven'
- name: Set up Maven
run:
mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.2:wrapper "-Dmaven=${{ inputs.ff-maven }}"
- name: Build with Maven
run: ./mvnw --errors --batch-mode --show-version ${{ inputs.maven-args }} ${{ inputs.ff-goal }}
- name: Build Maven Site
run: ./mvnw --errors --batch-mode --show-version ${{ inputs.maven-args }} ${{ inputs.ff-site-goal }}
if: inputs.ff-site-run
- name: Upload Maven Site
uses: actions/upload-artifact@v4
if: inputs.ff-site-run
with:
name: ${{ github.run_number }}-site-${{ inputs.ff-os }}-${{ inputs.ff-jdk }}-${{ inputs.ff-jdk-distribution }}
path: |
target/staging/**
- name: Upload artifact on failure
uses: actions/upload-artifact@v4
if: failure() && inputs.failure-upload-path != ''
with:
name: ${{ github.run_number }}-failure-${{ inputs.ff-os }}-${{ inputs.ff-jdk }}-${{ inputs.ff-jdk-distribution }}
path: ${{ inputs.failure-upload-path }}
- name: Show free disk space
if: always()
run: df -h
shell: bash
- name: Clean Ensuring no file handle remains open on windows
run: ./mvnw clean --errors --batch-mode --show-version
# prepare matrix data for verify step
setup-matrix:
runs-on: "ubuntu-latest"
needs: fail-fast-build
if: always() && inputs.matrix-enabled && ( !inputs.ff-run || needs.fail-fast-build.result == 'success' )
outputs:
maven: ${{ steps.maven.outputs.matrix }}
exclude: ${{ steps.exclude.outputs.matrix }}
steps:
- id: maven
name: setup Maven matrix
run: |
{
echo 'matrix<<EOF'
if [ "${{ inputs.maven4-enabled }}" = "true" ]; then
echo '${{ inputs.maven-matrix }}' | jq -c '. + ["${{ inputs.maven4-version }}"]'
else
echo '${{ inputs.maven-matrix }}'
fi
echo 'EOF'
} >> "$GITHUB_OUTPUT"
cat "$GITHUB_OUTPUT"
- id: exclude
name: setup exclude matrix
run: |
{
echo 'matrix<<EOF'
if [ "${{ inputs.maven4-enabled }}" = "true" ]; then
echo '${{ inputs.matrix-exclude }}' | jq -c '. + [{"jdk": "8", "maven": "${{ inputs.maven4-version }}"}]'
else
echo '${{ inputs.matrix-exclude }}'
fi
echo 'EOF'
} >> "$GITHUB_OUTPUT"
cat "$GITHUB_OUTPUT"
verify:
needs: setup-matrix
name: ${{ matrix.os }} jdk-${{ matrix.jdk }}-${{ matrix.distribution }} ${{ matrix.maven }}
timeout-minutes: ${{ inputs.timeout-minutes }}
runs-on: ${{ matrix.os }}
if: always() && ( !inputs.ff-run || needs.setup-matrix.result == 'success' )
strategy:
fail-fast: ${{ inputs.verify-fail-fast }}
matrix:
os: ${{ fromJSON( inputs.os-matrix ) }}
jdk: ${{ fromJSON( inputs.jdk-matrix ) }}
distribution: ${{ fromJSON( inputs.jdk-distribution-matrix ) }}
maven: ${{ fromJSON( needs.setup-matrix.outputs.maven ) }}
include: ${{ fromJSON( inputs.matrix-include ) }}
exclude: ${{ fromJSON( needs.setup-matrix.outputs.exclude ) }}
max-parallel: ${{ inputs.max-parallel }}
steps:
- name: Should run
id: should-run
if: >
matrix.os != inputs.ff-os ||
matrix.jdk != inputs.ff-jdk ||
matrix.distribution != inputs.ff-jdk-distribution ||
matrix.maven != inputs.ff-maven ||
inputs.verify-goal != inputs.ff-goal
run: echo ok
# Some projects (like Maven SCM) need the command-line tools for all SCMs installed.
# Git and Subversion are installed on all by default.
# Mercurial is not installed on macOS.
# https://docs.github.com/en/actions/using-github-hosted-runners/customizing-github-hosted-runners#installing-software-on-macos-runners
- name: Install Mercurial (hg) on macOS
if: >
inputs.install-mercurial &&
steps.should-run.conclusion == 'success' &&
matrix.os == 'macos-latest'
run: |
brew install mercurial
- name: Install GnuPG
if: >
inputs.install-gpg &&
steps.should-run.conclusion == 'success' &&
matrix.os == 'windows-latest'
run: |
$env:PATH = "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\chocolatey\bin"
[Environment]::SetEnvironmentVariable("Path", $env:PATH, "Machine")
choco install --yes gpg4win
echo "C:\Program Files (x86)\Gpg4win\..\GnuPG\bin" >> $env:GITHUB_PATH
- name: Check GnuPG
if: >
inputs.install-gpg &&
steps.should-run.conclusion == 'success'
run: gpg --version
- name: Show free disk space
if: steps.should-run.conclusion == 'success'
run: df -h
shell: bash
- name: Checkout
if: steps.should-run.conclusion == 'success'
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up JDK
if: steps.should-run.conclusion == 'success'
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.jdk }}
distribution: ${{ matrix.distribution }}
cache: 'maven'
- name: Set up Maven
if: steps.should-run.conclusion == 'success'
run: mvn --errors --batch-mode --show-version org.apache.maven.plugins:maven-wrapper-plugin:3.3.2:wrapper "-Dmaven=${{ matrix.maven }}"
- name: Build with Maven
if: steps.should-run.conclusion == 'success'
run: ./mvnw --errors --batch-mode --show-version ${{ inputs.maven-args }} ${{ inputs.verify-goal }}
- name: Upload artifact on failure
uses: actions/upload-artifact@v4
if: steps.should-run.conclusion == 'success' && failure() && inputs.failure-upload-path != ''
with:
name: ${{ github.run_number }}-failure-${{ matrix.os }}-${{ matrix.jdk }}-${{ matrix.distribution }}
path: ${{ inputs.failure-upload-path }}
- name: Show free disk space
if: steps.should-run.conclusion == 'success' && always()
run: df -h
shell: bash
- name: Clean Ensuring no file handle remains open on windows
if: steps.should-run.conclusion == 'success'
run: ./mvnw clean --errors --batch-mode --show-version