|
| 1 | +# This action build and tests the binary. The Conan dependencies must have |
| 2 | +# already been installed (see the build-deps action). |
| 3 | +name: Build and Test |
| 4 | + |
| 5 | +# Note that actions do not support 'type' and all inputs are strings, see |
| 6 | +# https://docs.github.com/en/actions/reference/workflows-and-actions/metadata-syntax#inputs. |
| 7 | +inputs: |
| 8 | + build_dir: |
| 9 | + description: "The directory where to build." |
| 10 | + required: true |
| 11 | + build_only: |
| 12 | + description: 'Whether to only build or to build and test the code ("true", "false").' |
| 13 | + required: false |
| 14 | + default: "false" |
| 15 | + build_type: |
| 16 | + description: 'The build type to use ("Debug", "Release").' |
| 17 | + required: true |
| 18 | + cmake_args: |
| 19 | + description: "Additional arguments to pass to CMake." |
| 20 | + required: false |
| 21 | + default: "" |
| 22 | + cmake_target: |
| 23 | + description: "The CMake target to build." |
| 24 | + required: true |
| 25 | + codecov_token: |
| 26 | + description: "The Codecov token to use for uploading coverage reports." |
| 27 | + required: false |
| 28 | + default: "" |
| 29 | + os: |
| 30 | + description: 'The operating system to use for the build ("linux", "macos", "windows").' |
| 31 | + required: true |
| 32 | + |
| 33 | +runs: |
| 34 | + using: composite |
| 35 | + steps: |
| 36 | + - name: Configure CMake |
| 37 | + shell: bash |
| 38 | + working-directory: ${{ inputs.build_dir }} |
| 39 | + run: | |
| 40 | + echo 'Configuring CMake.' |
| 41 | + cmake \ |
| 42 | + -G '${{ inputs.os == 'windows' && 'Visual Studio 17 2022' || 'Ninja' }}' \ |
| 43 | + -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake \ |
| 44 | + -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} \ |
| 45 | + ${{ inputs.cmake_args }} \ |
| 46 | + .. |
| 47 | + - name: Build the binary |
| 48 | + shell: bash |
| 49 | + working-directory: ${{ inputs.build_dir }} |
| 50 | + run: | |
| 51 | + echo 'Building binary.' |
| 52 | + cmake \ |
| 53 | + --build . \ |
| 54 | + --config ${{ inputs.build_type }} \ |
| 55 | + --parallel $(nproc) \ |
| 56 | + --target ${{ inputs.cmake_target }} |
| 57 | + - name: Check linking |
| 58 | + if: ${{ inputs.os == 'linux' }} |
| 59 | + shell: bash |
| 60 | + working-directory: ${{ inputs.build_dir }} |
| 61 | + run: | |
| 62 | + echo 'Checking linking.' |
| 63 | + ldd ./rippled |
| 64 | + if [ "$(ldd ./rippled | grep -E '(libstdc\+\+|libgcc)' | wc -l)" -eq 0 ]; then |
| 65 | + echo 'The binary is statically linked.' |
| 66 | + else |
| 67 | + echo 'The binary is dynamically linked.' |
| 68 | + exit 1 |
| 69 | + fi |
| 70 | + - name: Verify voidstar |
| 71 | + if: ${{ contains(inputs.cmake_args, '-Dvoidstar=ON') }} |
| 72 | + shell: bash |
| 73 | + working-directory: ${{ inputs.build_dir }} |
| 74 | + run: | |
| 75 | + echo 'Verifying presence of instrumentation.' |
| 76 | + ./rippled --version | grep libvoidstar |
| 77 | + - name: Test the binary |
| 78 | + if: ${{ inputs.build_only == 'false' }} |
| 79 | + shell: bash |
| 80 | + working-directory: ${{ inputs.build_dir }}/${{ inputs.os == 'windows' && inputs.build_type || '' }} |
| 81 | + run: | |
| 82 | + echo 'Testing binary.' |
| 83 | + ./rippled --unittest --unittest-jobs $(nproc) |
| 84 | + ctest -j $(nproc) --output-on-failure |
| 85 | + - name: Upload coverage report |
| 86 | + if: ${{ inputs.cmake_target == 'coverage' }} |
| 87 | + uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3 |
| 88 | + with: |
| 89 | + disable_search: true |
| 90 | + disable_telem: true |
| 91 | + fail_ci_if_error: true |
| 92 | + files: ${{ inputs.build_dir }}/coverage.xml |
| 93 | + plugins: noop |
| 94 | + token: ${{ inputs.codecov_token }} |
| 95 | + verbose: true |
0 commit comments