Convert reusable workflows back to actions to avoid shortcomings with concurrency

This commit is contained in:
Bart Thomee
2025-07-27 14:53:37 -04:00
parent d46c05e1b7
commit 06163a6d75
5 changed files with 170 additions and 184 deletions

View File

@@ -0,0 +1,109 @@
name: Build and Test (Linux and MacOS)
inputs:
build_dir:
description: 'The directory where the build will take place.'
required: true
type: string
build_type:
description: 'The build type to use.'
required: true
type: string
cmake_args:
description: 'Additional arguments to pass to CMake.'
required: false
type: string
cmake_generator:
description: 'The CMake generator to use for the build.'
required: true
type: string
cmake_target:
description: 'The CMake target to build.'
required: false
type: string
default: 'all'
conan_global_conf:
description: 'The contents of the global Conan configuration.'
required: true
type: string
conan_remote_name:
description: 'The name of the Conan remote to use.'
required: true
type: string
conan_remote_url:
description: 'The URL of the Conan remote to use.'
required: true
type: string
conan_remote_username:
description: 'The username for logging into the Conan remote.'
required: true
conan_remote_password:
description: 'The password for logging into the Conan remote.'
required: true
linking:
description: 'A boolean representing whether to check how the binary is linked.'
required: true
type: boolean
# Install the Conan profiles and log into the specified remote. We first remove
# the remote if it already exists, which can occur on self-hosted runners where
# the workspace is not cleaned up between runs.
runs:
using: composite
steps:
- name: Check configuration
run: |
echo "Checking path"
echo ${PATH} | tr ':' '\n'
echo "Checking environment variables."
env | sort
- name: Check versions
run: |
echo "Checking CMake version."
cmake --version
echo "Checking compiler version."
${CC} --version
- name: Configure Conan
uses: ./.github/actions/conan-configure
with:
conan_global_conf: ${{ inputs.conan_global_conf }}
conan_remote_name: ${{ inputs.conan_remote_name }}
conan_remote_url: ${{ inputs.conan_remote_url }}
conan_remote_username: ${{ inputs.conan_remote_username }}
conan_remote_password: ${{ inputs.conan_remote_password }}
- name: Configure CMake
working-directory: ${{ inputs.build_dir }}
run: |
cmake \
${{ inputs.cmake_generator && format('-G "{0}"', inputs.cmake_generator) || '' }} \
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake \
-DCMAKE_BUILD_TYPE=${{ inputs.build_type }} \
-Dtests=TRUE \
-Dxrpld=TRUE \
${{ inputs.cmake_args }} \
..
- name: Build the binary
working-directory: ${{ inputs.build_dir }}
run: |
cmake --build . \
--config ${{ inputs.build_type }} \
--parallel $(nproc) \
--target ${{ inputs.cmake_target }}
- name: Check linking
if: inputs.linking
working-directory: ${{ inputs.build_dir }}
run: |
ldd ./rippled
if [ "$(ldd ./rippled | grep -E '(libstdc\+\+|libgcc)' | wc -l)" -eq 0 ]; then
echo 'The binary is statically linked.'
else
echo 'The binary is dynamically linked.'
exit 1
fi
- name: Test the binary
working-directory: ${{ inputs.build_dir }}
run: |
./rippled --unittest --unittest-jobs $(nproc)
ctest -j $(nproc) --output-on-failure

View File

@@ -28,7 +28,7 @@ inputs:
runs:
using: composite
steps:
- name: Check configuration
- name: Check versions
shell: bash
run: |
echo "Checking Conan version."

View File

@@ -186,29 +186,33 @@ jobs:
conan_remote_username: ${{ secrets.conan_remote_username }}
conan_remote_password: ${{ secrets.conan_remote_password }}
# # Build and test the binary using various configurations.
# build-and-test:
# needs:
# - generate-outputs
# - install-dependencies
# uses: ./.github/workflows/build-nix.yml
# strategy:
# fail-fast: false
# matrix:
# architecture: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_architecture) }}
# os: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_os) }}
# build_type: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_build_type) }}
# cmake_args: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_cmake_args) }}
# with:
# build_dir: ${{ inputs.build_dir }}
# build_type: ${{ matrix.build_type }}
# cmake_args: ${{ matrix.cmake_args }}
# cmake_generator: "Ninja"
# conan_global_conf: ${{ needs.generate-outputs.outputs.conan_global_conf }}
# conan_remote_name: ${ inputs.conan_remote_name }
# conan_remote_url: ${ inputs.conan_remote_url }
# container: ghcr.io/xrplf/ci/${{ matrix.os.distro }}-${{ matrix.os.release }}:${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}
# runner: ${{ matrix.architecture.runner }}
# secrets:
# conan_remote_username: ${{ inputs.conan_remote_username }}
# conan_remote_password: ${{ inputs.conan_remote_password }}
# Build and test the binary using various configurations.
build-and-test:
needs:
- generate-outputs
- install-dependencies
runs-on: ${{ matrix.architecture.runner }}
container: ghcr.io/xrplf/ci/${{ matrix.os.distro }}-${{ matrix.os.release }}:${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}
strategy:
fail-fast: false
matrix:
architecture: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_architecture) }}
os: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_os) }}
build_type: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_build_type) }}
cmake_args: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_cmake_args) }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Build and test the binary
uses: ./.github/actions/build-test-nix
with:
build_dir: ${{ inputs.build_dir }}
build_type: ${{ matrix.build_type }}
cmake_args: ${{ matrix.cmake_args }}
cmake_generator: "Ninja"
conan_global_conf: ${{ needs.generate-outputs.outputs.conan_global_conf }}
conan_remote_name: ${{ inputs.conan_remote_name }}
conan_remote_url: ${{ inputs.conan_remote_url }}
conan_remote_username: ${{ secrets.conan_remote_username }}
conan_remote_password: ${{ secrets.conan_remote_password }}
linking: true

View File

@@ -1,131 +0,0 @@
# This workflow build and test the project on Linux and MacOS.
name: Build and test
on:
workflow_call:
inputs:
build_dir:
description: 'The directory where the build will take place.'
required: true
type: string
build_type:
description: 'The build type to use.'
required: true
type: string
cmake_args:
description: 'Additional arguments to pass to CMake.'
required: false
type: string
cmake_generator:
description: 'The CMake generator to use for the build.'
required: true
type: string
cmake_target:
description: 'The CMake target to build.'
required: false
type: string
default: 'all'
conan_global_conf:
description: 'The contents of the global Conan configuration.'
required: true
type: string
conan_remote_name:
description: 'The name of the Conan remote to use.'
required: true
type: string
conan_remote_url:
description: 'The URL of the Conan remote to use.'
required: true
type: string
container:
description: 'The container image to use for the job.'
required: true
type: string
runner:
description: 'A string representing the runner to use.'
required: true
type: string
secrets:
conan_remote_username:
description: 'The username for logging into the Conan remote.'
required: true
conan_remote_password:
description: 'The password for logging into the Conan remote.'
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-nix
cancel-in-progress: true
defaults:
run:
shell: bash
# Install the Conan dependencies for the specified configuration. The ones that
# are not in the remote cache will be built from source and added to the cache.
# This action assumes that the Conan profiles have already been installed and
# that the user has logged into the specified remote, see the 'conan-configure'
# action.
jobs:
build-and-test:
runs-on: ${{ inputs.runner }}
container: ${{ inputs.container }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Check configuration
run: |
echo "Checking path"
echo ${PATH} | tr ':' '\n'
echo "Checking environment variables."
env | sort
- name: Check versions
run: |
echo "Checking CMake version."
cmake --version
echo "Checking compiler version."
${CC} --version
- name: Configure Conan
uses: ./.github/actions/conan-configure
with:
conan_global_conf: ${{ inputs.conan_global_conf }}
conan_remote_name: ${{ inputs.conan_remote_name }}
conan_remote_url: ${{ inputs.conan_remote_url }}
conan_remote_username: ${{ inputs.conan_remote_username }}
conan_remote_password: ${{ inputs.conan_remote_password }}
- name: Configure CMake
working-directory: ${{ inputs.build_dir }}
run: |
cmake \
${{ inputs.cmake_generator && format('-G "{0}"', inputs.cmake_generator) || '' }} \
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake \
-DCMAKE_BUILD_TYPE=${{ inputs.build_type }} \
-Dtests=TRUE \
-Dxrpld=TRUE \
${{ inputs.cmake_args }} \
..
- name: Build the binary
working-directory: ${{ inputs.build_dir }}
run: |
cmake --build . \
--config ${{ inputs.build_type }} \
--parallel $(nproc) \
--target ${{ inputs.cmake_target }}
- name: Check linking
if: startsWith(inputs.runner, 'ubuntu-')
working-directory: ${{ inputs.build_dir }}
run: |
ldd ./rippled
if [ "$(ldd ./rippled | grep -E '(libstdc\+\+|libgcc)' | wc -l)" -eq 0 ]; then
echo 'The binary is statically linked.'
else
echo 'The binary is dynamically linked.'
exit 1
fi
- name: Test the binary
working-directory: ${{ inputs.build_dir }}
run: |
./rippled --unittest --unittest-jobs $(nproc)
ctest -j $(nproc) --output-on-failure

View File

@@ -163,29 +163,33 @@ jobs:
conan_remote_username: ${{ secrets.conan_remote_username }}
conan_remote_password: ${{ secrets.conan_remote_password }}
# # Build and test the binary using various configurations.
# build-and-test:
# needs:
# - generate-outputs
# - install-dependencies
# uses: ./.github/workflows/build-nix.yml
# strategy:
# fail-fast: false
# matrix:
# architecture: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_architecture) }}
# os: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_os) }}
# build_type: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_build_type) }}
# cmake_args: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_cmake_args) }}
# with:
# build_dir: ${{ inputs.build_dir }}
# build_type: ${{ matrix.build_type }}
# cmake_args: ${{ matrix.cmake_args }}
# cmake_generator: "Ninja"
# conan_global_conf: ${{ needs.generate-outputs.outputs.conan_global_conf }}
# conan_remote_name: ${ inputs.conan_remote_name }
# conan_remote_url: ${ inputs.conan_remote_url }
# container: ghcr.io/xrplf/ci/${{ matrix.os.distro }}-${{ matrix.os.release }}:${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}
# runner: ${{ matrix.architecture.runner }}
# secrets:
# conan_remote_username: ${{ inputs.conan_remote_username }}
# conan_remote_password: ${{ inputs.conan_remote_password }}
# Build and test the binary using various configurations.
build-and-test:
needs:
- generate-outputs
- install-dependencies
runs-on: ${{ matrix.architecture.runner }}
container: ghcr.io/xrplf/ci/${{ matrix.os.distro }}-${{ matrix.os.release }}:${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}
strategy:
fail-fast: false
matrix:
architecture: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_architecture) }}
os: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_os) }}
build_type: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_build_type) }}
cmake_args: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_cmake_args) }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Build and test the binary
uses: ./.github/actions/build-test-nix
with:
build_dir: ${{ inputs.build_dir }}
build_type: ${{ matrix.build_type }}
cmake_args: ${{ matrix.cmake_args }}
cmake_generator: "Ninja"
conan_global_conf: ${{ needs.generate-outputs.outputs.conan_global_conf }}
conan_remote_name: ${{ inputs.conan_remote_name }}
conan_remote_url: ${{ inputs.conan_remote_url }}
conan_remote_username: ${{ secrets.conan_remote_username }}
conan_remote_password: ${{ secrets.conan_remote_password }}
linking: true