|
1 | | -name: Reusable build |
| 1 | +name: Build |
2 | 2 | on: |
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 |
| 3 | + push: |
| 4 | + branches: [master, release/*, develop] |
| 5 | + pull_request: |
| 6 | + branches: [master, release/*, develop] |
| 7 | + workflow_dispatch: |
10 | 8 |
|
11 | | - container: |
12 | | - description: "The container object as a JSON string (leave empty to run natively)" |
13 | | - required: true |
14 | | - type: string |
15 | | - default: "" |
16 | | - |
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 |
26 | | - |
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 |
| 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 |
68 | 19 |
|
69 | | - sanitizer: |
70 | | - description: Sanitizer to use |
71 | | - required: false |
72 | | - type: string |
73 | | - default: 'false' |
| 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 |
74 | 39 |
|
75 | | -jobs: |
76 | 40 | build: |
77 | | - name: Build ${{ inputs.container != '' && 'in container' || 'natively' }} |
78 | | - runs-on: ${{ inputs.runs_on }} |
79 | | - container: ${{ inputs.container != '' && fromJson(inputs.container) || null }} |
| 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/build_impl.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 }} |
80 | 116 |
|
81 | 117 | steps: |
82 | 118 | - name: Clean workdir |
83 | 119 | if: ${{ runner.os == 'macOS' }} |
84 | 120 | uses: kuznetsss/workspace-cleanup@1.0 |
85 | 121 |
|
86 | | - - uses: actions/checkout@v4 |
| 122 | + - uses: actions/download-artifact@v4 |
87 | 123 | with: |
88 | | - fetch-depth: 0 |
| 124 | + name: clio_tests_${{ runner.os }}_${{ matrix.build_type }}_${{ matrix.conan_profile }} |
89 | 125 |
|
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.disable_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 |
| 126 | + - name: Run clio_tests |
131 | 127 | run: | |
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 && !inputs.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 && !inputs.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 }} |
| 128 | + chmod +x ./clio_tests |
| 129 | + ./clio_tests |
0 commit comments