diff --git a/.github/actions/conan-configure/action.yml b/.github/actions/conan-configure/action.yml index b95597ba23..5eae57897b 100644 --- a/.github/actions/conan-configure/action.yml +++ b/.github/actions/conan-configure/action.yml @@ -5,22 +5,6 @@ inputs: description: 'The contents of the global Conan configuration file.' 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 - type: string - conan_remote_password: - description: 'The password for logging into the Conan remote.' - required: true - type: string # 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 @@ -43,14 +27,14 @@ runs: - name: Add Conan remote shell: bash run: | - if conan remote list | grep -q '${{ inputs.conan_remote_name }}'; then - conan remote remove ${{ inputs.conan_remote_name }} - echo "Removed Conan remote '${{ inputs.conan_remote_name }}'." + if conan remote list | grep -q '${{ vars.CONAN_REMOTE_NAME }}'; then + conan remote remove ${{ vars.CONAN_REMOTE_NAME }} + echo "Removed Conan remote '${{ vars.CONAN_REMOTE_NAME }}'." fi - conan remote add --index 0 ${{ inputs.conan_remote_name }} ${{ inputs.conan_remote_url }} - echo "Added new conan remote '${{ inputs.conan_remote_name }}' at ${{ inputs.conan_remote_url }}." + conan remote add --index 0 ${{ vars.CONAN_REMOTE_NAME }} ${{ vars.CONAN_REMOTE_URL }} + echo "Added new conan remote '${{ vars.CONAN_REMOTE_NAME }}' at ${{ vars.CONAN_REMOTE_URL }}." - name: Log into Conan remote shell: bash run: | - conan remote login ${{ inputs.conan_remote_name }} ${{ inputs.conan_remote_username }} --password "${{ inputs.conan_remote_password }}" + conan remote login ${{ vars.CONAN_REMOTE_NAME }} ${{ vars.CONAN_USERNAME }} --password "${{ secrets.CONAN_PASSWORD }}" conan remote list-users diff --git a/.github/actions/generate-matrix/action.yml b/.github/actions/generate-matrix/action.yml new file mode 100644 index 0000000000..460ddd3aaa --- /dev/null +++ b/.github/actions/generate-matrix/action.yml @@ -0,0 +1,47 @@ +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 + 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 }} diff --git a/.github/workflows/build-debian.yml b/.github/workflows/build-debian.yml index 6ad1bd2f16..16d06f2058 100644 --- a/.github/workflows/build-debian.yml +++ b/.github/workflows/build-debian.yml @@ -9,21 +9,6 @@ on: 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 }} @@ -139,9 +124,21 @@ env: ] jobs: + # Expose environment variables used by other jobs. This is a workaround, as + # environment variables cannot be passed as inputs to reusable workflows. They + # can, however, be passed as inputs to actions. + expose-env: + runs-on: ubuntu-latest + steps: + - name: Expose environment variables + run: echo "" + outputs: + conan_global_conf: ${{ env.CONAN_GLOBAL_CONF }} + # Generate the strategy matrix. generate-matrix: - uses: ./.github/workflows/generate-matrix.yml + runs-on: ubuntu-latest + uses: ./.github/actions/generate-matrix.yml with: architecture: ${{ env.STRATEGY_MATRIX_ARCHITECTURE }} os: ${{ env.STRATEGY_MATRIX_OS }} @@ -151,6 +148,7 @@ jobs: # Install and cache the dependencies using various configurations. install-dependencies: needs: + - expose-env - generate-matrix uses: ./.github/workflows/install-dependencies.yml strategy: @@ -162,18 +160,15 @@ jobs: with: build_dir: ${{ inputs.build_dir }} build_type: ${{ strategy.matrix.build_type }} - conan_global_conf: ${{ env.CONAN_GLOBAL_CONF }} - conan_remote_name: ${{ inputs.conan_remote_name }} - conan_remote_url: ${{ inputs.conan_remote_url }} + conan_global_conf: ${{ needs.expose-env.outputs.conan_global_conf }} container: ghcr.io/xrplf/ci/${{ strategy.matrix.os.distro }}-${{ strategy.matrix.os.release }}:${{ strategy.matrix.os.compiler_name }}-${{ strategy.matrix.os.compiler_version }} runner: ${{ strategy.matrix.architecture.runner }} secrets: - 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: + - expose-env - generate-matrix - install-dependencies uses: ./.github/workflows/build-nix.yml @@ -189,11 +184,6 @@ jobs: build_type: ${{ strategy.matrix.build_type }} cmake_args: ${{ strategy.matrix.cmake_args }} cmake_generator: "Ninja" - conan_global_conf: ${{ env.CONAN_GLOBAL_CONF }} - conan_remote_name: ${{ inputs.conan_remote_name }} - conan_remote_url: ${{ inputs.conan_remote_url }} + conan_global_conf: ${{ needs.expose-env.outputs.conan_global_conf }} container: ghcr.io/xrplf/ci/${{ strategy.matrix.os.distro }}-${{ strategy.matrix.os.release }}:${{ strategy.matrix.os.compiler_name }}-${{ strategy.matrix.os.compiler_version }} runner: ${{ strategy.matrix.architecture.runner }} - secrets: - conan_remote_username: ${{ secrets.CONAN_REMOTE_USERNAME }} - conan_remote_password: ${{ secrets.CONAN_REMOTE_PASSWORD }} diff --git a/.github/workflows/build-nix.yml b/.github/workflows/build-nix.yml index 538757e48d..1bdc502914 100644 --- a/.github/workflows/build-nix.yml +++ b/.github/workflows/build-nix.yml @@ -29,14 +29,6 @@ on: 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 @@ -45,13 +37,6 @@ on: 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 }} @@ -91,10 +76,6 @@ jobs: 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: ${{ secrets.conan_remote_username }} - conan_remote_password: ${{ secrets.conan_remote_password }} - name: Configure CMake working-directory: ${{ inputs.build_dir }} run: | diff --git a/.github/workflows/build-rhel.yml b/.github/workflows/build-rhel.yml index dad6439862..257540cc99 100644 --- a/.github/workflows/build-rhel.yml +++ b/.github/workflows/build-rhel.yml @@ -92,9 +92,20 @@ env: ] jobs: + # Expose environment variables used by other jobs. This is a workaround, as + # environment variables cannot be passed as inputs to reusable workflows. + expose-env: + runs-on: ubuntu-latest + steps: + - name: Expose environment variables + run: echo "" + outputs: + conan_global_conf: ${{ env.CONAN_GLOBAL_CONF }} + # Generate the strategy matrix. generate-matrix: - uses: ./.github/workflows/generate-matrix.yml + runs-on: ubuntu-latest + uses: ./.github/actions/generate-matrix.yml with: architecture: ${{ env.STRATEGY_MATRIX_ARCHITECTURE }} os: ${{ env.STRATEGY_MATRIX_OS }} @@ -104,6 +115,7 @@ jobs: # Install and cache the dependencies using various configurations. install-dependencies: needs: + - expose-env - generate-matrix uses: ./.github/workflows/install-dependencies.yml strategy: @@ -115,18 +127,15 @@ jobs: with: build_dir: ${{ inputs.build_dir }} build_type: ${{ strategy.matrix.build_type }} - conan_global_conf: ${{ env.CONAN_GLOBAL_CONF }} - conan_remote_name: ${{ inputs.conan_remote_name }} - conan_remote_url: ${{ inputs.conan_remote_url }} + conan_global_conf: ${{ needs.expose-env.outputs.conan_global_conf }} container: ghcr.io/xrplf/ci/${{ strategy.matrix.os.distro }}-${{ strategy.matrix.os.release }}:${{ strategy.matrix.os.compiler_name }}-${{ strategy.matrix.os.compiler_version }} runner: ${{ strategy.matrix.architecture.runner }} secrets: - 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: + - expose-env - generate-matrix - install-dependencies uses: ./.github/workflows/build-nix.yml @@ -142,11 +151,6 @@ jobs: build_type: ${{ strategy.matrix.build_type }} cmake_args: ${{ strategy.matrix.cmake_args }} cmake_generator: "Ninja" - conan_global_conf: ${{ env.CONAN_GLOBAL_CONF }} - conan_remote_name: ${{ inputs.conan_remote_name }} - conan_remote_url: ${{ inputs.conan_remote_url }} + conan_global_conf: ${{ needs.expose-env.outputs.conan_global_conf }} container: ghcr.io/xrplf/ci/${{ strategy.matrix.os.distro }}-${{ strategy.matrix.os.release }}:${{ strategy.matrix.os.compiler_name }}-${{ strategy.matrix.os.compiler_version }} runner: ${{ strategy.matrix.architecture.runner }} - secrets: - conan_remote_username: ${{ secrets.CONAN_REMOTE_USERNAME }} - conan_remote_password: ${{ secrets.CONAN_REMOTE_PASSWORD }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dbabeab3c4..e155d2e248 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,23 +19,7 @@ defaults: run: shell: bash -env: - # The Conan remote where the dependencies will be cached. - CONAN_REMOTE_NAME: xrplf - CONAN_REMOTE_URL: https://conan.ripplex.io - jobs: - # This job exposes the environment variables that will be used by other jobs. - # It is a workaround for the env-context not being available in the 'with' - # steps when calling other workflows. - env-vars: - runs-on: ubuntu-latest - steps: - - run: echo "Exposing environment variables." - outputs: - conan_remote_name: ${{ env.CONAN_REMOTE_NAME }} - conan_remote_url: ${{ env.CONAN_REMOTE_URL }} - check-clang-format: if: github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'DraftRunCI') uses: ./.github/workflows/check-clang-format.yml @@ -46,66 +30,31 @@ jobs: debian: needs: - - env-vars - check-clang-format - check-levelization uses: ./.github/workflows/build-debian.yml - with: - conan_remote_name: ${{ needs.env-vars.outputs.conan_remote_name }} - conan_remote_url: ${{ needs.env-vars.outputs.conan_remote_url }} - secrets: - conan_username: ${{ secrets.CONAN_USERNAME }} - conan_password: ${{ secrets.CONAN_PASSWORD }} # rhel: # needs: -# - env-vars # - check-clang-format # - check-levelization # uses: ./.github/workflows/build-rhel.yml -# with: -# conan_remote_name: ${{ needs.env-vars.outputs.conan_remote_name }} -# conan_remote_url: ${{ needs.env-vars.outputs.conan_remote_url }} -# secrets: -# conan_username: ${{ secrets.CONAN_USERNAME }} -# conan_password: ${{ secrets.CONAN_PASSWORD }} # # ubuntu: # needs: -# - env-vars # - check-clang-format # - check-levelization # uses: ./.github/workflows/build-ubuntu.yml -# with: -# conan_remote_name: ${{ needs.env-vars.outputs.conan_remote_name }} -# conan_remote_url: ${{ needs.env-vars.outputs.conan_remote_url }} -# secrets: -# conan_username: ${{ secrets.CONAN_USERNAME }} -# conan_password: ${{ secrets.CONAN_PASSWORD }} # # macos: # needs: -# - env-vars # - check-clang-format # - check-levelization # uses: ./.github/workflows/build-macos.yml -# with: -# conan_remote_name: ${{ needs.env-vars.outputs.conan_remote_name }} -# conan_remote_url: ${{ needs.env-vars.outputs.conan_remote_url }} -# secrets: -# conan_username: ${{ secrets.CONAN_USERNAME }} -# conan_password: ${{ secrets.CONAN_PASSWORD }} # # windows: # needs: -# - env-vars # - check-clang-format # - check-levelization # uses: ./.github/workflows/build-windows.yml -# with: -# conan_remote_name: ${{ needs.env-vars.outputs.conan_remote_name }} -# conan_remote_url: ${{ needs.env-vars.outputs.conan_remote_url }} -# secrets: -# conan_username: ${{ secrets.CONAN_USERNAME }} -# conan_password: ${{ secrets.CONAN_PASSWORD }}