Skip to content

Commit 3a2a89b

Browse files
committed
Address review comments
1 parent c0da077 commit 3a2a89b

File tree

7 files changed

+313
-325
lines changed

7 files changed

+313
-325
lines changed

.github/actions/build_clio/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inputs:
55
description: Build target name
66
default: all
77
substract_threads:
8-
description: See get_number_of_threads
8+
description: An option for the action get_number_of_threads. See get_number_of_threads
99
required: true
1010
default: '0'
1111
runs:

.github/actions/generate/action.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ inputs:
1616
description: Whether to build integration tests
1717
required: true
1818
default: 'true'
19-
lint:
20-
description: Whether to build with linter enabled
21-
required: true
22-
default: 'false'
2319
code_coverage:
2420
description: Whether conan's coverage option should be on or not
2521
required: true
@@ -46,10 +42,9 @@ runs:
4642
CODE_COVERAGE: "${{ inputs.code_coverage == 'true' && 'True' || 'False' }}"
4743
STATIC_OPTION: "${{ inputs.static == 'true' && 'True' || 'False' }}"
4844
INTEGRATION_TESTS_OPTION: "${{ inputs.build_integration_tests == 'true' && 'True' || 'False' }}"
49-
LINT_OPTION: "${{ inputs.lint == 'true' && 'True' || 'False' }}"
5045
run: |
5146
cd build
52-
conan install .. -of . -b $BUILD_OPTION -s build_type=${{ inputs.build_type }} -o clio:static="${STATIC_OPTION}" -o clio:tests=True -o clio:integration_tests="${INTEGRATION_TESTS_OPTION}" -o clio:lint="${LINT_OPTION}" -o clio:coverage="${CODE_COVERAGE}" --profile ${{ inputs.conan_profile }}
47+
conan install .. -of . -b $BUILD_OPTION -s build_type=${{ inputs.build_type }} -o clio:static="${STATIC_OPTION}" -o clio:tests=True -o clio:integration_tests="${INTEGRATION_TESTS_OPTION}" -o clio:lint=False -o clio:coverage="${CODE_COVERAGE}" --profile ${{ inputs.conan_profile }}
5348
5449
- name: Run cmake
5550
shell: bash

.github/workflows/build.yml

+178-115
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,192 @@
1-
name: Build
1+
name: Reusable build
22
on:
3-
push:
4-
branches: [master, release/*, develop]
5-
pull_request:
6-
branches: [master, release/*, develop]
7-
workflow_dispatch:
3+
workflow_call:
4+
inputs:
5+
runs_on:
6+
description: Runner to run the job on
7+
required: true
8+
type: string
9+
default: heavy
810

9-
jobs:
10-
check_format:
11-
name: Check format
12-
runs-on: ubuntu-20.04
13-
container:
14-
image: rippleci/clio_ci:latest
15-
steps:
16-
- name: Fix git permissions on Linux
17-
shell: bash
18-
run: git config --global --add safe.directory $PWD
11+
container:
12+
description: "The container object as a JSON string (leave empty to run natively)"
13+
required: true
14+
type: string
15+
default: ""
1916

20-
- uses: actions/checkout@v4
21-
- name: Run formatters
22-
id: run_formatters
23-
run: |
24-
./.githooks/check-format --diff
25-
shell: bash
26-
27-
check_docs:
28-
name: Check documentation
29-
runs-on: ubuntu-20.04
30-
container:
31-
image: rippleci/clio_ci:latest
32-
steps:
33-
- uses: actions/checkout@v4
34-
- name: Run linter
35-
id: run_linter
36-
run: |
37-
./.githooks/check-docs
38-
shell: bash
17+
conan_profile:
18+
description: Conan profile to use
19+
required: true
20+
type: string
21+
22+
build_type:
23+
description: Build type
24+
required: true
25+
type: string
3926

27+
disable_cache:
28+
description: Whether ccache and conan cache should be disabled
29+
required: false
30+
type: boolean
31+
default: false
32+
33+
code_coverage:
34+
description: Whether to enable code coverage
35+
required: true
36+
type: boolean
37+
default: false
38+
39+
static:
40+
description: Whether to build static binaries
41+
required: true
42+
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
56+
57+
clio_server:
58+
description: Whether to build clio_server
59+
required: true
60+
type: boolean
61+
default: true
62+
63+
target:
64+
description: Build target name
65+
required: false
66+
type: string
67+
default: all
68+
69+
sanitizer:
70+
description: Sanitizer to use
71+
required: false
72+
type: string
73+
default: 'false'
74+
75+
jobs:
4076
build:
41-
name: Build
42-
needs:
43-
- check_format
44-
- check_docs
45-
strategy:
46-
fail-fast: false
47-
matrix:
48-
include:
49-
- os: heavy
50-
conan_profile: gcc
51-
build_type: Release
52-
container: '{ "image": "rippleci/clio_ci:latest" }'
53-
code_coverage: false
54-
static: true
55-
- os: heavy
56-
conan_profile: gcc
57-
build_type: Debug
58-
container: '{ "image": "rippleci/clio_ci:latest" }'
59-
code_coverage: true
60-
static: true
61-
- os: heavy
62-
conan_profile: clang
63-
build_type: Release
64-
container: '{ "image": "rippleci/clio_ci:latest" }'
65-
code_coverage: false
66-
static: true
67-
- os: heavy
68-
conan_profile: clang
69-
build_type: Debug
70-
container: '{ "image": "rippleci/clio_ci:latest" }'
71-
code_coverage: false
72-
static: true
73-
- os: macos15
74-
build_type: Release
75-
code_coverage: false
76-
static: false
77-
uses: ./.github/workflows/reusable_build.yml
78-
with:
79-
runs_on: ${{ matrix.os }}
80-
container: ${{ matrix.container }}
81-
conan_profile: ${{ matrix.conan_profile }}
82-
build_type: ${{ matrix.build_type }}
83-
code_coverage: ${{ matrix.code_coverage }}
84-
static: ${{ matrix.static }}
85-
unit_tests: true
86-
integration_tests: true
87-
clio_server: true
88-
89-
test:
90-
name: Run Tests
91-
needs: build
92-
strategy:
93-
fail-fast: false
94-
matrix:
95-
include:
96-
- os: heavy
97-
conan_profile: gcc
98-
build_type: Release
99-
container:
100-
image: rippleci/clio_ci:latest
101-
- os: heavy
102-
conan_profile: clang
103-
build_type: Release
104-
container:
105-
image: rippleci/clio_ci:latest
106-
- os: heavy
107-
conan_profile: clang
108-
build_type: Debug
109-
container:
110-
image: rippleci/clio_ci:latest
111-
- os: macos15
112-
conan_profile: apple_clang_16
113-
build_type: Release
114-
runs-on: ${{ matrix.os }}
115-
container: ${{ matrix.container }}
77+
name: Build ${{ inputs.container != '' && 'in container' || 'natively' }}
78+
runs-on: ${{ inputs.runs_on }}
79+
container: ${{ inputs.container != '' && fromJson(inputs.container) || null }}
11680

11781
steps:
11882
- name: Clean workdir
11983
if: ${{ runner.os == 'macOS' }}
12084
uses: kuznetsss/workspace-cleanup@1.0
12185

122-
- uses: actions/download-artifact@v4
86+
- uses: actions/checkout@v4
12387
with:
124-
name: clio_tests_${{ runner.os }}_${{ matrix.build_type }}_${{ matrix.conan_profile }}
88+
fetch-depth: 0
12589

126-
- name: Run clio_tests
90+
- name: Prepare runner
91+
uses: ./.github/actions/prepare_runner
92+
with:
93+
disable_ccache: ${{ inputs.disable_cache }}
94+
95+
- name: Setup conan
96+
uses: ./.github/actions/setup_conan
97+
id: conan
98+
with:
99+
conan_profile: ${{ inputs.conan_profile }}
100+
101+
- name: Restore cache
102+
if: ${{ !inputs.disable_cache }}
103+
uses: ./.github/actions/restore_cache
104+
id: restore_cache
105+
with:
106+
conan_dir: ${{ env.CONAN_USER_HOME }}/.conan
107+
conan_profile: ${{ steps.conan.outputs.conan_profile }}
108+
ccache_dir: ${{ env.CCACHE_DIR }}
109+
build_type: ${{ inputs.build_type }}
110+
code_coverage: ${{ inputs.code_coverage }}
111+
112+
- name: Run conan and cmake
113+
uses: ./.github/actions/generate
114+
with:
115+
conan_profile: ${{ steps.conan.outputs.conan_profile }}
116+
conan_cache_hit: ${{ !inputs.restore_cache && steps.restore_cache.outputs.conan_cache_hit }}
117+
build_type: ${{ inputs.build_type }}
118+
code_coverage: ${{ inputs.code_coverage }}
119+
static: ${{ inputs.static }}
120+
sanitizer: ${{ inputs.sanitizer }}
121+
122+
- name: Build Clio
123+
uses: ./.github/actions/build_clio
124+
with:
125+
target: ${{ inputs.target }}
126+
127+
- name: Show ccache's statistics
128+
if: ${{ !inputs.disable_cache }}
129+
shell: bash
130+
id: ccache_stats
127131
run: |
128-
chmod +x ./clio_tests
129-
./clio_tests
132+
ccache -s > /tmp/ccache.stats
133+
miss_rate=$(cat /tmp/ccache.stats | grep 'Misses' | head -n1 | sed 's/.*(\(.*\)%).*/\1/')
134+
echo "miss_rate=${miss_rate}" >> $GITHUB_OUTPUT
135+
cat /tmp/ccache.stats
136+
137+
- name: Strip unit_tests
138+
if: ${{ inputs.unit_tests && !inputs.code_coverage && inputs.sanitizer == 'false' }}
139+
run: strip build/clio_tests
140+
141+
- name: Strip integration_tests
142+
if: ${{ inputs.integration_tests && !inputs.code_coverage }}
143+
run: strip build/clio_integration_tests
144+
145+
- name: Upload clio_server
146+
if: ${{ inputs.clio_server }}
147+
uses: actions/upload-artifact@v4
148+
with:
149+
name: clio_server_${{ runner.os }}_${{ inputs.build_type }}_${{ steps.conan.outputs.conan_profile }}
150+
path: build/clio_server
151+
152+
- name: Upload clio_tests
153+
if: ${{ inputs.unit_tests && !matrix.code_coverage }}
154+
uses: actions/upload-artifact@v4
155+
with:
156+
name: clio_tests_${{ runner.os }}_${{ inputs.build_type }}_${{ steps.conan.outputs.conan_profile }}
157+
path: build/clio_tests
158+
159+
- name: Upload clio_integration_tests
160+
if: ${{ inputs.integration_tests && !matrix.code_coverage }}
161+
uses: actions/upload-artifact@v4
162+
with:
163+
name: clio_integration_tests_${{ runner.os }}_${{ inputs.build_type }}_${{ steps.conan.outputs.conan_profile }}
164+
path: build/clio_integration_tests
165+
166+
- name: Save cache
167+
if: ${{ !inputs.disable_cache }}
168+
uses: ./.github/actions/save_cache
169+
with:
170+
conan_dir: ${{ env.CONAN_USER_HOME }}/.conan
171+
conan_hash: ${{ steps.restore_cache.outputs.conan_hash }}
172+
conan_cache_hit: ${{ steps.restore_cache.outputs.conan_cache_hit }}
173+
ccache_dir: ${{ env.CCACHE_DIR }}
174+
ccache_cache_hit: ${{ steps.restore_cache.outputs.ccache_cache_hit }}
175+
ccache_cache_miss_rate: ${{ steps.ccache_stats.outputs.miss_rate }}
176+
build_type: ${{ inputs.build_type }}
177+
code_coverage: ${{ inputs.code_coverage }}
178+
conan_profile: ${{ steps.conan.outputs.conan_profile }}
179+
180+
# TODO: This is not a part of build process but it is the easiest way to do it here.
181+
# It will be refactored in https://github.com/XRPLF/clio/issues/1075
182+
- name: Run code coverage
183+
if: ${{ inputs.code_coverage }}
184+
uses: ./.github/actions/code_coverage
185+
186+
upload_coverage_report:
187+
if: ${{ inputs.code_coverage }}
188+
name: Codecov
189+
needs: build
190+
uses: ./.github/workflows/upload_coverage_report.yml
191+
secrets:
192+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/nightly.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
build_type: Debug
2727
static: true
2828
container: '{ "image": "rippleci/clio_ci:latest" }'
29-
uses: ./.github/workflows/reusable_build.yml
29+
uses: ./.github/workflows/build.yml
3030
with:
3131
runs_on: ${{ matrix.os }}
3232
container: ${{ matrix.container }}
@@ -37,7 +37,7 @@ jobs:
3737
unit_tests: true
3838
integration_tests: true
3939
clio_server: true
40-
disable_ccache: true
40+
disable_cache: true
4141

4242
run_tests:
4343
needs: build

0 commit comments

Comments
 (0)