Skip to content

Commit cc1da5a

Browse files
authored
test: Add build_and_test reusable workflow (#2048)
1 parent de05593 commit cc1da5a

File tree

7 files changed

+275
-226
lines changed

7 files changed

+275
-226
lines changed

.github/actions/build_clio/action.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
name: Build clio
22
description: Build clio in build directory
3+
34
inputs:
4-
target:
5-
description: Build target name
5+
targets:
6+
description: Space-separated build target names
67
default: all
78
subtract_threads:
89
description: An option for the action get_number_of_threads. See get_number_of_threads
910
required: true
1011
default: "0"
12+
1113
runs:
1214
using: composite
1315
steps:
@@ -17,8 +19,8 @@ runs:
1719
with:
1820
subtract_threads: ${{ inputs.subtract_threads }}
1921

20-
- name: Build Clio
22+
- name: Build targets
2123
shell: bash
2224
run: |
2325
cd build
24-
cmake --build . --parallel ${{ steps.number_of_threads.outputs.threads_number }} --target ${{ inputs.target }}
26+
cmake --build . --parallel ${{ steps.number_of_threads.outputs.threads_number }} --target ${{ inputs.targets }}

.github/workflows/build.yml

+9-48
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Build
2+
23
on:
34
push:
45
branches: [master, release/*, develop]
@@ -7,8 +8,9 @@ on:
78
workflow_dispatch:
89

910
jobs:
10-
build:
11-
name: Build
11+
build-and-test:
12+
name: Build and Test
13+
1214
strategy:
1315
fail-fast: false
1416
matrix:
@@ -42,63 +44,22 @@ jobs:
4244
build_type: Release
4345
code_coverage: false
4446
static: false
45-
uses: ./.github/workflows/build_impl.yml
47+
48+
uses: ./.github/workflows/build_and_test.yml
4649
with:
4750
runs_on: ${{ matrix.os }}
4851
container: ${{ matrix.container }}
4952
conan_profile: ${{ matrix.conan_profile }}
5053
build_type: ${{ matrix.build_type }}
5154
code_coverage: ${{ matrix.code_coverage }}
5255
static: ${{ matrix.static }}
53-
unit_tests: true
54-
integration_tests: true
56+
run_unit_tests: true
57+
run_integration_tests: false
5558
clio_server: true
5659

57-
test:
58-
name: Run Tests
59-
needs: build
60-
strategy:
61-
fail-fast: false
62-
matrix:
63-
include:
64-
- os: heavy
65-
conan_profile: gcc
66-
build_type: Release
67-
container:
68-
image: ghcr.io/xrplf/clio-ci:latest
69-
- os: heavy
70-
conan_profile: clang
71-
build_type: Release
72-
container:
73-
image: ghcr.io/xrplf/clio-ci:latest
74-
- os: heavy
75-
conan_profile: clang
76-
build_type: Debug
77-
container:
78-
image: ghcr.io/xrplf/clio-ci:latest
79-
- os: macos15
80-
conan_profile: default_apple_clang
81-
build_type: Release
82-
runs-on: ${{ matrix.os }}
83-
container: ${{ matrix.container }}
84-
85-
steps:
86-
- name: Clean workdir
87-
if: ${{ runner.os == 'macOS' }}
88-
uses: kuznetsss/workspace-cleanup@80b9863b45562c148927c3d53621ef354e5ae7ce #v1.0
89-
90-
- uses: actions/download-artifact@v4
91-
with:
92-
name: clio_tests_${{ runner.os }}_${{ matrix.build_type }}_${{ matrix.conan_profile }}
93-
94-
- name: Run clio_tests
95-
run: |
96-
chmod +x ./clio_tests
97-
./clio_tests
98-
9960
check_config:
10061
name: Check Config Description
101-
needs: build
62+
needs: build-and-test
10263
runs-on: heavy
10364
container:
10465
image: ghcr.io/xrplf/clio-ci:latest

.github/workflows/build_and_test.yml

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Reusable build and test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
runs_on:
7+
description: Runner to run the job on
8+
required: true
9+
type: string
10+
11+
container:
12+
description: "The container object as a JSON string (leave empty to run natively)"
13+
required: true
14+
type: string
15+
16+
conan_profile:
17+
description: Conan profile to use
18+
required: true
19+
type: string
20+
21+
build_type:
22+
description: Build type
23+
required: true
24+
type: string
25+
26+
disable_cache:
27+
description: Whether ccache and conan cache should be disabled
28+
required: false
29+
type: boolean
30+
default: false
31+
32+
code_coverage:
33+
description: Whether to enable code coverage
34+
required: true
35+
type: boolean
36+
default: false
37+
38+
static:
39+
description: Whether to build static binaries
40+
required: true
41+
type: boolean
42+
default: true
43+
44+
run_unit_tests:
45+
description: Whether to run unit tests
46+
required: true
47+
type: boolean
48+
49+
run_integration_tests:
50+
description: Whether to run integration tests
51+
required: true
52+
type: boolean
53+
default: false
54+
55+
clio_server:
56+
description: Whether to build clio_server
57+
required: true
58+
type: boolean
59+
60+
targets:
61+
description: Space-separated build target names
62+
required: false
63+
type: string
64+
default: all
65+
66+
sanitizer:
67+
description: Sanitizer to use
68+
required: false
69+
type: string
70+
default: "false"
71+
72+
jobs:
73+
build:
74+
uses: ./.github/workflows/build_impl.yml
75+
with:
76+
runs_on: ${{ inputs.runs_on }}
77+
container: ${{ inputs.container }}
78+
conan_profile: ${{ inputs.conan_profile }}
79+
build_type: ${{ inputs.build_type }}
80+
disable_cache: ${{ inputs.disable_cache }}
81+
code_coverage: ${{ inputs.code_coverage }}
82+
static: ${{ inputs.static }}
83+
clio_server: ${{ inputs.clio_server }}
84+
targets: ${{ inputs.targets }}
85+
sanitizer: ${{ inputs.sanitizer }}
86+
87+
test:
88+
needs: build
89+
# TODO: We don't upload tests if code coverage is enabled
90+
if: ${{ !inputs.code_coverage }}
91+
uses: ./.github/workflows/test_impl.yml
92+
with:
93+
runs_on: ${{ inputs.runs_on }}
94+
container: ${{ inputs.container }}
95+
conan_profile: ${{ inputs.conan_profile }}
96+
build_type: ${{ inputs.build_type }}
97+
run_unit_tests: ${{ inputs.run_unit_tests }}
98+
run_integration_tests: ${{ inputs.run_integration_tests }}
99+
sanitizer: ${{ inputs.sanitizer }}

.github/workflows/build_impl.yml

+8-27
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
name: Reusable build
2+
23
on:
34
workflow_call:
45
inputs:
56
runs_on:
67
description: Runner to run the job on
78
required: true
89
type: string
9-
default: heavy
1010

1111
container:
1212
description: "The container object as a JSON string (leave empty to run natively)"
1313
required: true
1414
type: string
15-
default: ""
1615

1716
conan_profile:
1817
description: Conan profile to use
@@ -28,49 +27,31 @@ on:
2827
description: Whether ccache and conan cache should be disabled
2928
required: false
3029
type: boolean
31-
default: false
3230

3331
code_coverage:
3432
description: Whether to enable code coverage
3533
required: true
3634
type: boolean
37-
default: false
3835

3936
static:
4037
description: Whether to build static binaries
4138
required: true
4239
type: boolean
43-
default: true
44-
45-
unit_tests:
46-
description: Whether to run unit tests
47-
required: true
48-
type: boolean
49-
default: false
50-
51-
integration_tests:
52-
description: Whether to run integration tests
53-
required: true
54-
type: boolean
55-
default: false
5640

5741
clio_server:
5842
description: Whether to build clio_server
5943
required: true
6044
type: boolean
61-
default: true
6245

63-
target:
64-
description: Build target name
46+
targets:
47+
description: Space-separated build target names
6548
required: false
6649
type: string
67-
default: all
6850

6951
sanitizer:
7052
description: Sanitizer to use
7153
required: false
7254
type: string
73-
default: "false"
7455

7556
jobs:
7657
build:
@@ -121,7 +102,7 @@ jobs:
121102
- name: Build Clio
122103
uses: ./.github/actions/build_clio
123104
with:
124-
target: ${{ inputs.target }}
105+
targets: ${{ inputs.targets }}
125106

126107
- name: Show ccache's statistics
127108
if: ${{ !inputs.disable_cache }}
@@ -134,11 +115,11 @@ jobs:
134115
cat /tmp/ccache.stats
135116
136117
- name: Strip unit_tests
137-
if: ${{ inputs.unit_tests && !inputs.code_coverage && inputs.sanitizer == 'false' }}
118+
if: ${{ !inputs.code_coverage && inputs.sanitizer == 'false' }}
138119
run: strip build/clio_tests
139120

140121
- name: Strip integration_tests
141-
if: ${{ inputs.integration_tests && !inputs.code_coverage }}
122+
if: ${{ !inputs.code_coverage }}
142123
run: strip build/clio_integration_tests
143124

144125
- name: Upload clio_server
@@ -149,14 +130,14 @@ jobs:
149130
path: build/clio_server
150131

151132
- name: Upload clio_tests
152-
if: ${{ inputs.unit_tests && !inputs.code_coverage }}
133+
if: ${{ !inputs.code_coverage }}
153134
uses: actions/upload-artifact@v4
154135
with:
155136
name: clio_tests_${{ runner.os }}_${{ inputs.build_type }}_${{ inputs.conan_profile }}
156137
path: build/clio_tests
157138

158139
- name: Upload clio_integration_tests
159-
if: ${{ inputs.integration_tests && !inputs.code_coverage }}
140+
if: ${{ !inputs.code_coverage }}
160141
uses: actions/upload-artifact@v4
161142
with:
162143
name: clio_integration_tests_${{ runner.os }}_${{ inputs.build_type }}_${{ inputs.conan_profile }}

0 commit comments

Comments
 (0)