blob: 665a30b9ddf8957c2386a99b3604d155f219bf5f [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
maven_version:
description: The Maven version used for builds
required: false
default: '3.8.7'
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: '[ "8", "11", "17" ]'
type: string
matrix-exclude:
description: 'exclude for matrix as json'
required: false
default: '[]'
type: string
max-parallel:
description: 'max parallel jobs'
required: false
default: 100
type: number
timeout-minutes:
description: 'timeout-minutes used by the builds (defaults to 360)'
required: false
default: 360
type: number
jdk-distribution-matrix:
description: "jdk distribution matrix"
required: false
default: '[ "temurin" ]'
type: string
# 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-jdk:
description: The jdk version used during fail-fast-build job
required: false
default: '11'
type: string
ff-jdk-distribution:
description: The jdk distribution used during fail-fast-build job
required: false
default: 'temurin'
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-site-goal:
description: The Maven goal used by verfy jobs to build site
required: false
default: '-DskipTests -P reporting site'
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
# allow single build per branch or PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
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 }}
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.1.0:wrapper "-Dmaven=${{ inputs.maven_version }}"
- 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
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
verify:
needs: fail-fast-build
name: ${{ matrix.os }} jdk-${{ matrix.jdk }}-${{ matrix.distribution }}
timeout-minutes: ${{ inputs.timeout-minutes }}
runs-on: ${{ matrix.os }}
if: always() && ( !inputs.ff-run || needs.fail-fast-build.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 ) }}
exclude: ${{ fromJSON( inputs.matrix-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 ||
inputs.verify-goal != inputs.ff-goal ||
inputs.verify-site-goal != inputs.ff-site-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: 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.1.0:wrapper "-Dmaven=${{ inputs.maven_version }}"
- 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