env is unavailable to pass to reusable workflows in 'with'

This commit is contained in:
Bart Thomee
2025-07-27 11:53:43 -04:00
parent 7acf9f517d
commit a3a5e57e18
6 changed files with 86 additions and 131 deletions

View File

@@ -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 }}

View File

@@ -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: |

View File

@@ -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 }}

View File

@@ -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 }}