Skip to content

Commit 41a330f

Browse files
committed
Reusable CI: Allow specifying targets, defines, link and variant for B2 builds
1 parent f662fe5 commit 41a330f

1 file changed

Lines changed: 35 additions & 19 deletions

File tree

.github/workflows/reusable.yml

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@ permissions:
1919
on:
2020
workflow_call:
2121
inputs:
22+
b2_targets:
23+
description: "B2 targets to build, e.g. 'libs/foo/test//bar'. Defaults to auto-detecting the tests"
24+
required: false
25+
type: string
26+
default: ''
27+
b2_defines:
28+
description: "Preprocessor defines to add"
29+
required: false
30+
type: string
31+
default: ''
32+
b2_link:
33+
description: "Build shared and/or static"
34+
required: false
35+
type: string
36+
default: 'shared,static'
37+
b2_variant:
38+
description: "Variants/Optimization level(s) to build"
39+
required: false
40+
type: string
41+
default: 'debug,release'
2242
branch_coverage:
2343
description: "Collect branch coverage instead of line coverage. Enabled by default."
2444
required: false
@@ -113,8 +133,6 @@ concurrency:
113133
env:
114134
GIT_FETCH_JOBS: 8
115135
NET_RETRY_COUNT: 5
116-
B2_VARIANT: debug,release
117-
B2_LINK: shared,static
118136
LCOV_BRANCH_COVERAGE: ${{ inputs.branch_coverage && '1' || '0' }}
119137
CODECOV_NAME: Github Actions
120138

@@ -433,15 +451,11 @@ jobs:
433451
ENABLE_REFLECTION: ${{ matrix.reflection }}
434452
B2_SANITIZE: ${{matrix.sanitize}}
435453
B2_STDLIB: ${{matrix.stdlib}}
436-
# Optional. Variables set here (to non-empty) will override the top-level environment variables
437-
B2_DEFINES: ${{matrix.defines}}
438-
B2_VARIANT: ${{matrix.variant}}
439-
B2_LINK: ${{matrix.link}}
454+
B2_DEFINES: ${{inputs.b2_defines}}
455+
B2_LINK: ${{inputs.b2_link}}
456+
B2_VARIANT: ${{inputs.b2_variant}}
440457
XCODE_APP: ${{matrix.xcode_app}}
441-
# More entries can be added in the same way, see the B2_ARGS assignment in ci/enforce.sh for the possible keys.
442-
# Set the (B2) target(s) to build, defaults to the test folder of the current library
443-
# Can alternatively be done like this in the build step or in the build command of the build step, e.g. `run: B2_TARGETS=libs/$SELF/doc ci/build.sh`
444-
# B2_TARGETS: libs/foo/test//bar
458+
445459

446460
- name: Setup coverage collection
447461
if: matrix.coverage
@@ -450,6 +464,8 @@ jobs:
450464
- name: Run tests
451465
if: '!matrix.coverity'
452466
run: ci/build.sh
467+
env:
468+
B2_TARGETS: ${{inputs.b2_targets}}
453469
# inherits environment from install.sh step
454470

455471
- name: Show config.log
@@ -596,9 +612,9 @@ jobs:
596612
B2_TARGET_OS: ${{matrix.target-os}}
597613
B2_CXXSTD: ${{matrix.cxxstd}}
598614
B2_ADDRESS_MODEL: ${{matrix.address-model}}
599-
B2_DEFINES: ${{matrix.defines}}
600-
B2_VARIANT: ${{matrix.variant}}
601-
B2_LINK: ${{matrix.link}}
615+
B2_DEFINES: ${{inputs.b2_defines}}
616+
B2_LINK: ${{inputs.b2_link}}
617+
B2_VARIANT: ${{inputs.b2_variant}}
602618

603619
- name: Collect coverage
604620
shell: powershell
@@ -608,9 +624,9 @@ jobs:
608624
B2_TOOLSET: ${{matrix.toolset}}
609625
B2_CXXSTD: ${{matrix.cxxstd}}
610626
B2_ADDRESS_MODEL: ${{matrix.address-model}}
611-
B2_DEFINES: ${{matrix.defines}}
612-
B2_VARIANT: ${{matrix.variant}}
613-
B2_LINK: ${{matrix.link}}
627+
B2_DEFINES: ${{inputs.b2_defines}}
628+
B2_LINK: ${{inputs.b2_link}}
629+
B2_VARIANT: ${{inputs.b2_variant}}
614630

615631
- name: Upload coverage
616632
if: matrix.coverage
@@ -719,9 +735,9 @@ jobs:
719735
B2_CXXSTD: ${{matrix.cxxstd}}
720736
B2_SANITIZE: ${{matrix.sanitize}}
721737
B2_STDLIB: ${{matrix.stdlib}}
722-
B2_DEFINES: ${{matrix.defines}}
723-
B2_VARIANT: ${{matrix.variant}}
724-
B2_LINK: ${{matrix.link}}
738+
B2_DEFINES: ${{inputs.defines}}
739+
B2_LINK: ${{inputs.link}}
740+
B2_VARIANT: ${{inputs.variant}}
725741

726742
- name: Run tests
727743
run: ci/build.sh

0 commit comments

Comments
 (0)