diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 985e11f65..bc419e193 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -2,7 +2,7 @@ name: CMake on: push: - branches: [ riscv, main ] + branches: [ main ] pull_request: branches: [ main ] @@ -44,7 +44,7 @@ jobs: # Execute tests defined by the CMake configuration. # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail #run: ctest -V -C ${{env.BUILD_TYPE}} - run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure + run: ctest --parallel $(nproc) -C ${{env.BUILD_TYPE}} --output-on-failure - name: Rerun failed tests if: failure() diff --git a/.github/workflows/riscv-tests.yml b/.github/workflows/riscv-tests.yml new file mode 100644 index 000000000..41f1998f1 --- /dev/null +++ b/.github/workflows/riscv-tests.yml @@ -0,0 +1,74 @@ +name: RISC-V Tests + +on: + push: + branches: [ main, riscv-tests ] + pull_request: + branches: [ main ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + riscv-tests: + runs-on: ubuntu-latest + timeout-minutes: 45 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Generate cache key + id: cache-key + run: | + echo "key=riscv-tests-${{ hashFiles('**/*.cpp', '**/*.h', '**/*.c', '**/CMakeLists.txt') }}" >> $GITHUB_OUTPUT + + - name: Restore build cache + id: cache-build + uses: actions/cache@v4 + with: + path: build + key: ${{ runner.os }}-riscv-tests-${{ steps.cache-key.outputs.key }} + restore-keys: + ${{ runner.os }}-riscv-tests- + + - name: Setup runtime dependencies and RISC-V toolchain + run: | + sudo apt update + sudo apt install -y --no-install-recommends qemu-user-static libc6-dev-riscv64-cross libstdc++6-riscv64-cross libgcc-s1-riscv64-cross \ + cmake ninja-build gcc-riscv64-linux-gnu g++-riscv64-linux-gnu parallel + + - name: Configure and Build for RISC-V + if: steps.cache-build.outputs.cache-hit != 'true' + run: | + mkdir -p build + cmake -G Ninja -B build cmake -B build \ + -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ + -DUNIVRSL_BUILD_CI=ON \ + -DCMAKE_SYSTEM_NAME=Linux \ + -DCMAKE_SYSTEM_PROCESSOR=riscv64 \ + -DCMAKE_C_COMPILER=riscv64-linux-gnu-gcc \ + -DCMAKE_CXX_COMPILER=riscv64-linux-gnu-g++ \ + -DCMAKE_FIND_ROOT_PATH=/usr/riscv64-linux-gnu \ + -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \ + -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ + -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ + -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \ + -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" + cmake --build build --config ${{ env.BUILD_TYPE }} + + - name: Run tests + run: | + cd build + parallel --halt now,fail=1 qemu-riscv64-static -L /usr/riscv64-linux-gnu/ ::: $(find ./static -type f -executable -printf '%p ') + + - name: Upload test logs + if: failure() + uses: actions/upload-artifact@v4 + with: + name: test-logs + path: | + ${{github.workspace}}/build/Testing + ${{github.workspace}}/build/CMakeCache.txt + ${{github.workspace}}/build/CMakeFiles/CMakeOutput.log + ${{github.workspace}}/build/CMakeFiles/CMakeError.log