Fix workflow vs. action

This commit is contained in:
Bart Thomee
2025-07-27 12:12:52 -04:00
parent 5c4c658c38
commit 7c9aad6e9f
5 changed files with 93 additions and 68 deletions

View File

@@ -1,48 +0,0 @@
name: generate-matrix
inputs:
architecture:
description: 'A string representing a JSON array with objects containing the "platform" (e.g. "linux/arm64") and "runner" (e.g. "ubuntu-24.04-arm") to use.'
required: true
type: string
os:
description: 'A string representing a JSON array with objects containing the "distro" (e.g. "debian"), "release" (e.g. "bookworm"), "compiler_name" (e.g. "gcc") and "compiler_version" (e.g. "13") to use.'
required: true
type: string
build_type:
description: 'A string representing a JSON array with strings holding the build type (e.g. "Debug", "Release") to use.'
required: true
type: string
cmake_args:
description: 'A string representing a JSON array with strings holding the CMake arguments (e.g. "-DUnity=ON", "-DUnity=OFF") to use. Multiple arguments can be specified by separating them with a space (e.g. "-DUnity=ON -DVoidstar=ON").'
required: true
type: string
# Generate the JSON outputs by using JQ to compact the JSON string so they can
# be used in a job as follows:
# strategy:
# fail-fast: false
# matrix:
# architecture: ${{ fromJson(needs.json-outputs.outputs.architecture) }}
# os: ${{ fromJson(needs.json-outputs.outputs.os) }}
# build_type: ${{ fromJson(needs.json-outputs.outputs.build_type) }}
# cmake_args: ${{ fromJson(needs.json-outputs.outputs.cmake_args) }}
# runs-on: ${{ matrix.architecture.runner }}
# container: ghcr.io/xrplf/ci/${{ matrix.os.distro }}-${{ matrix.os.release }}:${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}
# ...
runs:
using: composite
steps:
- name: Generate outputs
shell: bash
id: generate
run: |
echo "architecture=$(jq -c <<< '${{ inputs.architecture }}')" >> "$GITHUB_OUTPUT"
echo "os=$(jq -c <<< '${{ inputs.os }}')" >> "$GITHUB_OUTPUT"
echo "build_type=$(jq -c <<< '${{ inputs.build_type }}')" >> "$GITHUB_OUTPUT"
echo "cmake_args=$(jq -c <<< '${{ inputs.cmake_args }}')" >> "$GITHUB_OUTPUT"
outputs:
architecture: ${{ steps.generate.outputs.architecture }}
os: ${{ steps.generate.outputs.os }}
build_type: ${{ steps.generate.outputs.build_type }}
cmake_args: ${{ steps.generate.outputs.cmake_args }}

View File

@@ -137,15 +137,14 @@ jobs:
# Generate the strategy matrix.
generate-matrix:
runs-on: ubuntu-latest
steps:
- name: Generate strategy matrix
uses: ./.github/actions/generate-matrix
with:
architecture: ${{ env.STRATEGY_MATRIX_ARCHITECTURE }}
os: ${{ env.STRATEGY_MATRIX_OS }}
build_type: ${{ env.STRATEGY_MATRIX_BUILD_TYPE }}
cmake_args: ${{ env.STRATEGY_MATRIX_UNITY }}
needs:
- expose-env
uses: ./.github/workflows/generate-matrix.yml
with:
architecture: ${{ needs.expose-env.outputs.strategy_matrix_architecture }}
os: ${{ needs.expose-env.outputs.strategy_matrix_os }}
build_type: ${{ needs.expose-env.outputs.strategy_matrix_build_type }}
cmake_args: ${{ needs.expose-env.outputs.strategy_cmake_args }}
# Install and cache the dependencies using various configurations.
install-dependencies:

View File

@@ -102,18 +102,21 @@ jobs:
run: echo ""
outputs:
conan_global_conf: ${{ env.CONAN_GLOBAL_CONF }}
strategy_matrix_architecture: ${{ env.STRATEGY_MATRIX_ARCHITECTURE }}
strategy_matrix_os: ${{ env.STRATEGY_MATRIX_OS }}
strategy_matrix_build_type: ${{ env.STRATEGY_MATRIX_BUILD_TYPE }}
strategy_matrix_cmake_args: ${{ env.STRATEGY_MATRIX_CMAKE_ARGS }}
# Generate the strategy matrix.
generate-matrix:
runs-on: ubuntu-latest
steps:
- name: Generate strategy matrix
uses: ./.github/actions/generate-matrix
with:
architecture: ${{ env.STRATEGY_MATRIX_ARCHITECTURE }}
os: ${{ env.STRATEGY_MATRIX_OS }}
build_type: ${{ env.STRATEGY_MATRIX_BUILD_TYPE }}
cmake_args: ${{ env.STRATEGY_MATRIX_UNITY }}
needs:
- expose-env
uses: ./.github/workflows/generate-matrix.yml
with:
architecture: ${{ needs.expose-env.outputs.strategy_matrix_architecture }}
os: ${{ needs.expose-env.outputs.strategy_matrix_os }}
build_type: ${{ needs.expose-env.outputs.strategy_matrix_build_type }}
cmake_args: ${{ needs.expose-env.outputs.strategy_cmake_args }}
# Install and cache the dependencies using various configurations.
install-dependencies:

View File

@@ -19,8 +19,9 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Check levelization
run: Builds/levelization/levelization.sh
# TODO: Re-enable this step once the levelization script is faster.
# - name: Check levelization
# run: Builds/levelization/levelization.sh
- name: Check for differences
env:
MESSAGE: |

70
.github/workflows/generate-matrix.yml vendored Normal file
View File

@@ -0,0 +1,70 @@
# This workflow is used to generate a strategy matrix for Linux, Windows, and
# MacOS build and test jobs.
name: generate-matrix
on:
workflow_call:
inputs:
runner:
description: 'An optional string representing the GitHub runner to use.'
required: true
type: string
architecture:
description: 'A string representing a JSON array holding objects containing the "platform" (e.g. "linux/arm64") and "runner" (e.g. "ubuntu-24.04-arm") to use.'
required: true
type: string
os:
description: 'A string representing a JSON array holding objects containing the "distro" (e.g. "debian"), "release" (e.g. "bookworm"), "compiler_name" (e.g. "gcc") and "compiler_version" (e.g. "13") to use.'
required: true
type: string
build_type:
description: 'A string representing a JSON array holding strings with the build type (e.g. "Debug", "Release") to use.'
required: true
type: string
cmake_args:
description: 'A string representing a JSON array holding strings with the CMake arguments (e.g. "-DUnity=ON", "-DUnity=OFF") to use. Multiple arguments can be specified by separating them with a space (e.g. "-DUnity=ON -DVoidstar=ON").'
required: true
type: string
# Generate the JSON outputs by using JQ to compact the JSON string.
# * This workflow can be called as follows:
# ```yaml
# generate-matrix:
# uses: ./.github/workflows/generate-matrix.yml
# with:
# architecture: ${{ env.STRATEGY_MATRIX_ARCHITECTURE }}
# os: ${{ env.STRATEGY_MATRIX_OS }}
# build_type: ${{ env.STRATEGY_MATRIX_BUILD_TYPE }}
# cmake_args: ${{ env.STRATEGY_MATRIX_CMAKE_ARGS }}
# ```
# * This workflow can be used as follows:
# ```yaml
# use-matrix:
# needs: generate-matrix
# strategy:
# fail-fast: false
# matrix:
# architecture: ${{ fromJson(needs.generate-matrix.outputs.architecture) }}
# os: ${{ fromJson(needs.generate-matrix.outputs.os) }}
# build_type: ${{ fromJson(needs.generate-matrix.outputs.build_type) }}
# cmake_args: ${{ fromJson(needs.generate-matrix.outputs.cmake_args) }}
# runs-on: ${{ matrix.architecture.runner }}
# container: ghcr.io/xrplf/ci/${{ matrix.os.distro }}-${{ matrix.os.release }}:${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}
# ...
# ```
jobs:
generate-matrix:
runs-on: ${{ inputs.runner }}
steps:
- name: Generate outputs
id: generate
run: |
echo "architecture=$(jq -c <<< '${{ inputs.architecture }}')" >> "$GITHUB_OUTPUT"
echo "os=$(jq -c <<< '${{ inputs.os }}')" >> "$GITHUB_OUTPUT"
echo "build_type=$(jq -c <<< '${{ inputs.build_type }}')" >> "$GITHUB_OUTPUT"
echo "cmake_args=$(jq -c <<< '${{ inputs.cmake_args }}')" >> "$GITHUB_OUTPUT"
outputs:
architecture: ${{ steps.generate.outputs.architecture }}
os: ${{ steps.generate.outputs.os }}
build_type: ${{ steps.generate.outputs.build_type }}
cmake_args: ${{ steps.generate.outputs.cmake_args }}