From 087a6044fd840903360cc40383e9d657b80b616c Mon Sep 17 00:00:00 2001 From: Bart Thomee <11445373+bthomee@users.noreply.github.com> Date: Sun, 27 Jul 2025 16:59:13 -0400 Subject: [PATCH] Add Ubuntu and MacOS --- .github/workflows/build-debian.yml | 2 +- .github/workflows/build-macos.yml | 152 ++++++++++++++++++++ .github/workflows/build-rhel.yml | 2 +- .github/workflows/build-ubuntu.yml | 221 +++++++++++++++++++++++++++++ 4 files changed, 375 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build-macos.yml create mode 100644 .github/workflows/build-ubuntu.yml diff --git a/.github/workflows/build-debian.yml b/.github/workflows/build-debian.yml index 6d869c5777..da008f2576 100644 --- a/.github/workflows/build-debian.yml +++ b/.github/workflows/build-debian.yml @@ -162,7 +162,7 @@ jobs: # Install and cache the dependencies, and then build and test the binary using # various configurations. - build-and-test: + build-test: needs: - generate-outputs runs-on: ${{ matrix.architecture.runner }} diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml new file mode 100644 index 0000000000..6e4232b920 --- /dev/null +++ b/.github/workflows/build-macos.yml @@ -0,0 +1,152 @@ +# This workflow builds and tests the binary on various MacOS configurations. +name: MacOS + +on: + workflow_call: + inputs: + build_dir: + description: 'The directory where to build.' + required: false + type: string + default: '.build' + 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 + 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 }}-debian + cancel-in-progress: true + +defaults: + run: + shell: bash + +env: + # Global configuration for Conan. This is used to set the number of parallel + # downloads, uploads, and build jobs. The verbosity is set to verbose to + # provide more information during the build process. + CONAN_GLOBAL_CONF: | + core.download:parallel={{ os.cpu_count() }} + core.upload:parallel={{ os.cpu_count() }} + tools.build:jobs={{ (os.cpu_count() * 4/5) | int }} + tools.build:verbosity=verbose + tools.compilation:verbosity=verbose + # GitHub does not allow us to specify a reusable matrix strategy, so to avoid + # duplication, we define it here using environment variables and create the + # matrix in the first job. +# STRATEGY_MATRIX_RUNNER: >- +# [ +# "mac-runner-m1" +# ] +# STRATEGY_MATRIX_BUILD_TYPE: >- +# [ +# "Debug", +# "Release" +# ] +# STRATEGY_MATRIX_CMAKE_ARGS: >- +# [ +# "-DUnity=OFF", +# "-DUnity=ON" +# ] + STRATEGY_MATRIX_RUNNER: >- + [ + "mac-runner-m1" + ] + STRATEGY_MATRIX_BUILD_TYPE: >- + [ + "Debug" + ] + STRATEGY_MATRIX_CMAKE_ARGS: >- + [ + "-DUnity=ON" + ] + +jobs: + # Generate the strategy matrix and expose environment variables to be used by + # following jobs. Exposing env vars this way is needed as they cannot be + # directly passed as inputs to reusable workflows (although they can be passed + # as inputs to actions). + generate-outputs: + runs-on: ubuntu-latest + steps: + - name: Generate outputs + id: generate + run: | + echo "strategy_matrix_runner=$(jq -c <<< '${{ env.STRATEGY_MATRIX_RUNNER }}')" >> "$GITHUB_OUTPUT" + echo "strategy_matrix_build_type=$(jq -c <<< '${{ env.STRATEGY_MATRIX_BUILD_TYPE }}')" >> "$GITHUB_OUTPUT" + echo "strategy_matrix_cmake_args=$(jq -c <<< '${{ env.STRATEGY_MATRIX_CMAKE_ARGS }}')" >> "$GITHUB_OUTPUT" + outputs: + conan_global_conf: ${{ env.CONAN_GLOBAL_CONF }} + strategy_matrix_runner: ${{ steps.generate.outputs.strategy_matrix_runner }} + strategy_matrix_build_type: ${{ steps.generate.outputs.strategy_matrix_build_type }} + strategy_matrix_cmake_args: ${{ steps.generate.outputs.strategy_matrix_cmake_args }} + + # Install and cache the dependencies, and then build and test the binary using + # various configurations. + build-test: + needs: + - generate-outputs + runs-on: [self-hosted, macOS, ${{ matrix.architecture.runner }}] + strategy: + fail-fast: false + max-parallel: 4 + matrix: + runner: ${{ fromJson(needs.generate-outputs.outputs.strategy_matrix_runner) }} + 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: Check configuration + shell: bash + run: | + echo "Checking path" + echo ${PATH} | tr ':' '\n' + + echo "Checking environment variables." + env | sort + - name: Check versions + shell: bash + run: | + echo "Checking CMake version." + cmake --version + + echo "Checking compiler version." + ${CC} --version + + echo "Checking Conan version." + conan --version + - name: Configure Conan + uses: ./.github/actions/configure-conan + 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: ${{ secrets.conan_remote_username }} + conan_remote_password: ${{ secrets.conan_remote_password }} + - name: Install dependencies + uses: ./.github/actions/install-dependencies + with: + build_dir: ${{ inputs.build_dir }} + build_type: ${{ matrix.build_type }} + conan_remote_name: ${{ inputs.conan_remote_name }} + - 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' + link_check: false diff --git a/.github/workflows/build-rhel.yml b/.github/workflows/build-rhel.yml index 8237650a66..14dc3e93f1 100644 --- a/.github/workflows/build-rhel.yml +++ b/.github/workflows/build-rhel.yml @@ -139,7 +139,7 @@ jobs: # Install and cache the dependencies, and then build and test the binary using # various configurations. - build-and-test: + build-test: needs: - generate-outputs runs-on: ${{ matrix.architecture.runner }} diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml new file mode 100644 index 0000000000..a2aebe068b --- /dev/null +++ b/.github/workflows/build-ubuntu.yml @@ -0,0 +1,221 @@ +# This workflow builds and tests the binary on various Ubuntu configurations. +name: Ubuntu + +on: + workflow_call: + inputs: + build_dir: + description: 'The directory where to build.' + required: false + type: string + default: '.build' + 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 + 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 }}-rhel + cancel-in-progress: true + +defaults: + run: + shell: bash + +env: + # Global configuration for Conan. This is used to set the number of parallel + # downloads, uploads, and build jobs. The verbosity is set to verbose to + # provide more information during the build process. + CONAN_GLOBAL_CONF: | + core.download:parallel={{ os.cpu_count() }} + core.upload:parallel={{ os.cpu_count() }} + tools.build:jobs={{ (os.cpu_count() * 4/5) | int }} + tools.build:verbosity=verbose + tools.compilation:verbosity=verbose + # GitHub does not allow us to specify a reusable matrix strategy, so to avoid + # duplication, we define it here using environment variables and create the + # matrix in the first job. The matrix defined below should be kept in sync + # with https://github.com/XRPLF/ci/blob/main/.github/workflows/ubuntu.yml. +# STRATEGY_MATRIX_ARCHITECTURE: >- +# [ +# { +# "platform": "linux/amd64", +# "runner": "ubuntu-24.04" +# }, +# { +# "platform": "linux/arm64", +# "runner": "ubuntu-24.04-arm" +# } +# ] +# STRATEGY_MATRIX_OS: >- +# [ +# { +# "distro": "ubuntu", +# "release": "jammy", +# "compiler_name": "gcc", +# "compiler_version": "12" +# }, +# { +# "distro": "ubuntu", +# "release": "noble", +# "compiler_name": "gcc", +# "compiler_version": "13" +# }, +# { +# "distro": "ubuntu", +# "release": "noble", +# "compiler_name": "gcc", +# "compiler_version": "14" +# }, +# { +# "distro": "ubuntu", +# "release": "noble", +# "compiler_name": "clang", +# "compiler_version": "16" +# }, +# { +# "distro": "ubuntu", +# "release": "noble", +# "compiler_name": "clang", +# "compiler_version": "17" +# }, +# { +# "distro": "ubuntu", +# "release": "noble", +# "compiler_name": "clang", +# "compiler_version": "18" +# }, +# { +# "distro": "ubuntu", +# "release": "noble", +# "compiler_name": "clang", +# "compiler_version": "19" +# }, +# ] +# STRATEGY_MATRIX_BUILD_TYPE: >- +# [ +# "Debug", +# "Release" +# ] +# STRATEGY_MATRIX_CMAKE_ARGS: >- +# [ +# "-DUnity=OFF", +# "-DUnity=ON" +# ] + STRATEGY_MATRIX_ARCHITECTURE: >- + [ + { + "platform": "linux/amd64", + "runner": "ubuntu-24.04" + } + ] + STRATEGY_MATRIX_OS: >- + [ + { + "distro": "ubuntu", + "release": "jammy", + "compiler_name": "gcc", + "compiler_version": "12" + } + ] + STRATEGY_MATRIX_BUILD_TYPE: >- + [ + "Debug" + ] + STRATEGY_MATRIX_CMAKE_ARGS: >- + [ + "-DUnity=ON" + ] + +jobs: + # Generate the strategy matrix and expose environment variables to be used by + # following jobs. Exposing env vars this way is needed as they cannot be + # directly passed as inputs to reusable workflows (although they can be passed + # as inputs to actions). + generate-outputs: + runs-on: ubuntu-latest + steps: + - name: Generate outputs + id: generate + run: | + echo "strategy_matrix_architecture=$(jq -c <<< '${{ env.STRATEGY_MATRIX_ARCHITECTURE }}')" >> "$GITHUB_OUTPUT" + echo "strategy_matrix_os=$(jq -c <<< '${{ env.STRATEGY_MATRIX_OS }}')" >> "$GITHUB_OUTPUT" + echo "strategy_matrix_build_type=$(jq -c <<< '${{ env.STRATEGY_MATRIX_BUILD_TYPE }}')" >> "$GITHUB_OUTPUT" + echo "strategy_matrix_cmake_args=$(jq -c <<< '${{ env.STRATEGY_MATRIX_CMAKE_ARGS }}')" >> "$GITHUB_OUTPUT" + outputs: + conan_global_conf: ${{ env.CONAN_GLOBAL_CONF }} + strategy_matrix_architecture: ${{ steps.generate.outputs.strategy_matrix_architecture }} + strategy_matrix_os: ${{ steps.generate.outputs.strategy_matrix_os }} + strategy_matrix_build_type: ${{ steps.generate.outputs.strategy_matrix_build_type }} + strategy_matrix_cmake_args: ${{ steps.generate.outputs.strategy_matrix_cmake_args }} + + # Install and cache the dependencies, and then build and test the binary using + # various configurations. + build-test: + needs: + - generate-outputs + 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 + max-parallel: 4 + 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: Check configuration + shell: bash + run: | + echo "Checking path" + echo ${PATH} | tr ':' '\n' + + echo "Checking environment variables." + env | sort + - name: Check versions + shell: bash + run: | + echo "Checking CMake version." + cmake --version + + echo "Checking compiler version." + ${CC} --version + + echo "Checking Conan version." + conan --version + - name: Configure Conan + uses: ./.github/actions/configure-conan + 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: ${{ secrets.conan_remote_username }} + conan_remote_password: ${{ secrets.conan_remote_password }} + - name: Install dependencies + uses: ./.github/actions/install-dependencies + with: + build_dir: ${{ inputs.build_dir }} + build_type: ${{ matrix.build_type }} + conan_remote_name: ${{ inputs.conan_remote_name }} + - 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' + link_check: true