|
| 1 | +name: Build and Test the Rust API |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [ develop ] |
| 5 | + pull_request: |
| 6 | + branches: [ develop ] |
| 7 | +env: |
| 8 | + default_build_dir: "build/" |
| 9 | + default_solver: "minisat2" |
| 10 | + |
| 11 | +# For now, we support two jobs: A Linux and a MacOS based one. |
| 12 | +# Both of the jobs use CMake, as we only support building the Rust |
| 13 | +# API with CMake (due to dependencies on CMake plugins). |
| 14 | +jobs: |
| 15 | + check-ubuntu-22_04-cmake-clang-rust: |
| 16 | + runs-on: ubuntu-22.04 |
| 17 | + env: |
| 18 | + CC: "ccache /usr/bin/clang-13" |
| 19 | + CXX: "ccache /usr/bin/clang++-13" |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v3 |
| 22 | + with: |
| 23 | + submodules: recursive |
| 24 | + - name: Fetch dependencies |
| 25 | + env: |
| 26 | + # This is needed in addition to -yq to prevent apt-get from asking for |
| 27 | + # user input |
| 28 | + DEBIAN_FRONTEND: noninteractive |
| 29 | + run: | |
| 30 | + sudo apt-get update |
| 31 | + sudo apt-get install --no-install-recommends -yq clang-13 clang++-13 maven flex bison libxml2-utils ccache |
| 32 | + - name: Log cargo/rust version |
| 33 | + run: cargo --version |
| 34 | + - name: Prepare ccache |
| 35 | + uses: actions/cache@v3 |
| 36 | + with: |
| 37 | + path: .ccache |
| 38 | + key: ${{ runner.os }}-22.04-cmake-clang-${{ github.ref }}-${{ github.sha }}-PR |
| 39 | + restore-keys: | |
| 40 | + ${{ runner.os }}-22.04-cmake-clang-${{ github.ref }} |
| 41 | + ${{ runner.os }}-22.04-cmake-clang |
| 42 | + - name: ccache environment |
| 43 | + run: | |
| 44 | + echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV |
| 45 | + echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV |
| 46 | + - name: Zero ccache stats and limit in size |
| 47 | + run: ccache -z --max-size=500M |
| 48 | + # In our experiments while building this action script, the Ubuntu 22.04 build was failing with |
| 49 | + # the compiler indicating that it wanted the libraries to be built with `-fPIE` while it was |
| 50 | + # trying to link the Rust project. This was remedied by adding the `Position Independent Code` |
| 51 | + # directive during CBMC build time. It's worth mentioning that this wasn't observed on our |
| 52 | + # local experiments on the same platform, but it seems to be doing no harm to the build overall |
| 53 | + # and allows us to test the Rust API on Linux without issues. |
| 54 | + - name: Configure using CMake |
| 55 | + run: cmake -S. -B${{env.default_build_dir}} -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_C_COMPILER=/usr/bin/clang-13 -DCMAKE_CXX_COMPILER=/usr/bin/clang++-13 -DWITH_RUST_API=ON |
| 56 | + - name: Build with CMake |
| 57 | + run: cmake --build ${{env.default_build_dir}} -j2 |
| 58 | + - name: Print ccache stats |
| 59 | + run: ccache -s |
| 60 | + # We won't be running any of the regular regression tests, as these are covered |
| 61 | + # by the other jobs already present in `pull-request-checks.yaml`. |
| 62 | + - name: Run Rust API tests |
| 63 | + run: | |
| 64 | + cd src/libcprover-rust;\ |
| 65 | + cargo clean;\ |
| 66 | + CBMC_BUILD_DIR=../../${{env.default_build_dir}} SAT_IMPL=${{env.default_solver}} cargo test -- --test-threads=1 |
| 67 | +
|
| 68 | +
|
| 69 | + check-macos-12-cmake-clang-rust: |
| 70 | + runs-on: macos-12 |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@v3 |
| 73 | + with: |
| 74 | + submodules: recursive |
| 75 | + - name: Fetch dependencies |
| 76 | + run: brew install cmake ninja maven flex bison ccache |
| 77 | + - name: Log cargo/rust version |
| 78 | + run: cargo --version |
| 79 | + - name: Prepare ccache |
| 80 | + uses: actions/cache@v3 |
| 81 | + with: |
| 82 | + path: .ccache |
| 83 | + key: ${{ runner.os }}-Release-${{ github.ref }}-${{ github.sha }}-PR-Rust-API |
| 84 | + restore-keys: | |
| 85 | + ${{ runner.os }}-Release-${{ github.ref }} |
| 86 | + ${{ runner.os }}-Release |
| 87 | + - name: ccache environment |
| 88 | + run: | |
| 89 | + echo "CCACHE_BASEDIR=$PWD" >> $GITHUB_ENV |
| 90 | + echo "CCACHE_DIR=$PWD/.ccache" >> $GITHUB_ENV |
| 91 | + - name: Zero ccache stats and limit in size |
| 92 | + run: ccache -z --max-size=500M |
| 93 | + - name: Configure using CMake |
| 94 | + run: cmake -S. -B${{env.default_build_dir}} -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DWITH_RUST_API=ON |
| 95 | + - name: Build with Ninja |
| 96 | + run: cd ${{env.default_build_dir}}; ninja -j3 |
| 97 | + - name: Print ccache stats |
| 98 | + run: ccache -s |
| 99 | + # We won't be running any of the regular regression tests, as these are covered |
| 100 | + # by the other jobs already present in `pull-request-checks.yaml`. |
| 101 | + - name: Run Rust API tests |
| 102 | + run: | |
| 103 | + cd src/libcprover-rust;\ |
| 104 | + cargo clean;\ |
| 105 | + CBMC_BUILD_DIR=../../${{env.default_build_dir}} SAT_IMPL=${{env.default_solver}} cargo test -- --test-threads=1 |
0 commit comments