-
-
Notifications
You must be signed in to change notification settings - Fork 67
Added CI script for running Test Suite on RISC-V #480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdds a new GitHub Actions workflow to build and test the project for riscv64 under QEMU (cross-compilation, cache, install toolchain, run tests) and updates the existing CMake CI to run on pushes to Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Push/PR
participant GH as GitHub Actions
participant Runner as ubuntu-latest
participant Cache as Actions Cache
participant Apt as apt
participant CMake as CMake/Ninja
participant QEMU as qemu-riscv64-static
participant Art as Upload Artifact
Dev->>GH: Push to main or riscv-tests / PR to main
GH->>Runner: Start riscv-tests job
Runner->>Runner: Checkout repo
Runner->>Cache: Hash sources, attempt restore
alt cache hit
Cache-->>Runner: restore build/
else cache miss
Runner->>Apt: install qemu, riscv toolchain, cmake, ninja
end
Runner->>CMake: configure cross-build (riscv64, static flags)
Runner->>CMake: build with Ninja
Runner->>QEMU: run tests via qemu-riscv64-static (parallel where applicable)
alt tests fail
Runner->>Art: upload build/Testing and CMake logs
else
Runner-->>GH: job success
end
sequenceDiagram
autonumber
participant CI as CMake CI
participant Old as ctest (serial)
participant New as ctest (parallel)
CI->>Old: `ctest -C ${{env.BUILD_TYPE}} --output-on-failure`
note right of Old: Serial test execution
CI->>New: `ctest --parallel $(nproc) -C ${{env.BUILD_TYPE}} --output-on-failure`
note right of New: Parallel across CPU cores
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (3)
.github/workflows/riscv-tests.yml (3)
21-25: Broaden cache key inputs to avoid stale restores.Include common C/C++/CMake extensions.
- echo "key=riscv-tests-${{ hashFiles('**/*.cpp', '**/*.h', '**/*.c', '**/CMakeLists.txt') }}" >> $GITHUB_OUTPUT + echo "key=riscv-tests-${{ hashFiles('**/*.[ch]', '**/*.[ch]pp', '**/*.cxx', '**/*.cc', '**/*.hh', '**/*.hpp', '**/CMakeLists.txt', '**/*.cmake') }}" >> $GITHUB_OUTPUT
9-12: Use BUILD_TYPE env or drop it.Currently unused; wire it into configure/build (see above) for consistency.
33-37: Minor: prefer apt-get and no-recommends for leaner runners.Not blocking; consider aligning with the toolchain step.
- sudo apt update - sudo apt install -y qemu-user-static libc6-dev-riscv64-cross libstdc++6-riscv64-cross libgcc-s1-riscv64-cross parallel + sudo apt-get update + sudo apt-get install -y --no-install-recommends qemu-user-static libc6-dev-riscv64-cross libstdc++6-riscv64-cross libgcc-s1-riscv64-cross
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
.github/workflows/riscv-tests.yml(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/riscv-tests.yml
28-28: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (1)
.github/workflows/riscv-tests.yml (1)
67-76: Artifacts: verify CTest logs exist after switching to ctest.After adopting ctest, these paths are correct. If you keep ad‑hoc runners, Testing/ may not exist.
Would you like me to add a fallback to upload build logs (e.g., build/**/LastTest.log) if Testing/ is absent?
.github/workflows/riscv-tests.yml
Outdated
| - name: Restore build cache | ||
| id: cache-build | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: riscv-tests | ||
| key: ${{ steps.cache-key.outputs.key }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix cache action version and path (v3 is broken; caching wrong directory).
- actions/cache@v3 no longer runs on GitHub-hosted runners.
- You’re caching a non-existent path (riscv-tests) while building into build.
Apply:
- - name: Restore build cache
- id: cache-build
- uses: actions/cache@v3
- with:
- path: riscv-tests
- key: ${{ steps.cache-key.outputs.key }}
+ - name: Restore build cache
+ id: cache-build
+ uses: actions/cache@v4
+ with:
+ path: build
+ key: ${{ runner.os }}-riscv-build-${{ steps.cache-key.outputs.key }}
+ restore-keys: |
+ ${{ runner.os }}-riscv-build-📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - name: Restore build cache | |
| id: cache-build | |
| uses: actions/cache@v3 | |
| with: | |
| path: riscv-tests | |
| key: ${{ steps.cache-key.outputs.key }} | |
| - name: Restore build cache | |
| id: cache-build | |
| uses: actions/cache@v4 | |
| with: | |
| path: build | |
| key: ${{ runner.os }}-riscv-build-${{ steps.cache-key.outputs.key }} | |
| restore-keys: | | |
| ${{ runner.os }}-riscv-build- |
🧰 Tools
🪛 actionlint (1.7.7)
28-28: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🤖 Prompt for AI Agents
In .github/workflows/riscv-tests.yml around lines 26 to 31, the workflow is
using actions/cache@v3 (which doesn't run on GitHub-hosted runners) and is
caching the wrong directory "riscv-tests"; change the action to a supported
version (actions/cache@v2) and update the cached path to the actual build output
directory ("build") so the cache key restores the correct files; keep the
existing key input unchanged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/cmake.yml (1)
42-48: Fix cross-platform parallelism: $(nproc) breaks on Windows/macOS shells.Matrix includes windows-latest and macos-latest; $(nproc) is Linux/GNU only and the default shell differs per OS. Force bash and use a portable core count.
Apply:
- name: Test working-directory: ${{github.workspace}}/build # 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 --parallel $(nproc) -C ${{env.BUILD_TYPE}} --output-on-failure + shell: bash + run: | + CORES="$(getconf _NPROCESSORS_ONLN 2>/dev/null || nproc || echo 2)" + ctest --parallel "$CORES" -C ${{env.BUILD_TYPE}} --output-on-failure
♻️ Duplicate comments (1)
.github/workflows/riscv-tests.yml (1)
41-60: Un-gate build on cache and fix malformed CMake command (duplicate of earlier feedback).
- cache-hit gating skips necessary (incremental) builds and can run stale binaries.
- Command has stray “cmake -B build cmake -B build”; missing “-S .”.
Apply:
- - 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 \ + - name: Configure and Build for RISC-V + run: | + cmake -G Ninja -S . -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_CROSSCOMPILING_EMULATOR="qemu-riscv64-static;-L;/usr/riscv64-linux-gnu" \ -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" cmake --build build --config ${{ env.BUILD_TYPE }}
🧹 Nitpick comments (4)
.github/workflows/riscv-tests.yml (4)
61-65: CTesting looks good; add config and env for clearer logs.Small tweaks improve clarity and parity with cmake.yml.
Apply:
- - name: Run tests - run: | - cd build - ctest --parallel $(nproc) --output-on-failure + - name: Run tests + env: + CTEST_OUTPUT_ON_FAILURE: "1" + run: | + cd build + ctest -C ${{ env.BUILD_TYPE }} --parallel "$(nproc)" --output-on-failure
13-17: Add concurrency group to avoid duplicate runs per ref.Prevents overlapping jobs on force-pushes.
Apply:
riscv-tests: runs-on: ubuntu-latest timeout-minutes: 45 + concurrency: + group: riscv-${{ github.ref }} + cancel-in-progress: true
35-40: Harden apt usage for CI determinism.Use apt-get, update, and noninteractive to reduce flakes.
Apply:
- - 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 + - name: Setup runtime dependencies and RISC-V toolchain + env: + DEBIAN_FRONTEND: noninteractive + run: | + sudo apt-get update + sudo apt-get 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
21-34: Consider stronger cache keying and lighter-weight caches.CMake build dirs are brittle to cache; prefer ccache or key on toolchain/runner to avoid ABI mismatches.
Example:
- Include runner OS version and compiler versions in key:
- key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.versions.outputs.gcc }}-${{ steps.cache-key.outputs.key }}
- Or switch to ccache:
- install ccache and add -DCMAKE_CXX_COMPILER_LAUNCHER=ccache; cache ~/.cache/ccache.
I can draft the steps if you want them in this PR.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
.github/workflows/cmake.yml(2 hunks).github/workflows/riscv-tests.yml(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (1)
.github/workflows/cmake.yml (1)
5-5: Confirm reduced push triggers to main only.If you rely on push CI for feature branches (beyond PR CI), this change will stop those runs. Verify branch protection rules and workflows relying on push status.
riscv-tests.ymlGitHub workflow script in.github/workflows/enabling RISC-V testing on a static QEMU RISC-V64 VM via cross-compilation.Summary by CodeRabbit
Tests
Chores