-
Notifications
You must be signed in to change notification settings - Fork 2
Add reusable build/test, coverage, and miri workflows #18
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
Merged
theswiftfox
merged 1 commit into
eclipse-opensovd:main
from
bburda42dot:feat/reusable-workflows
Mar 20, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| name: Build and Test | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| rust-version: | ||
| description: "Rust toolchain version (default: stable)" | ||
| type: string | ||
| default: "stable" | ||
| cargo-locked: | ||
| description: "Use --locked flag for cargo commands" | ||
| type: boolean | ||
| default: true | ||
| cargo-test-args: | ||
| description: "Additional arguments for cargo test" | ||
| type: string | ||
| default: "--workspace" | ||
| bazel-enabled: | ||
| description: "Enable Bazel build and test jobs" | ||
| type: boolean | ||
| default: false | ||
| bazel-build-targets: | ||
| description: "Bazel build targets" | ||
| type: string | ||
| default: "//..." | ||
| bazel-test-targets: | ||
| description: "Bazel test targets" | ||
| type: string | ||
| default: "//..." | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| cargo-build-test: | ||
| name: Cargo Build & Test | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Rust toolchain | ||
| uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
alexmohr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| with: | ||
| toolchain: ${{ inputs.rust-version }} | ||
|
|
||
| - name: Build all crates | ||
alexmohr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| run: cargo build ${{ inputs.cargo-locked && '--locked' || '' }} --workspace | ||
|
|
||
| - name: Run tests | ||
| run: cargo test ${{ inputs.cargo-locked && '--locked' || '' }} ${{ inputs.cargo-test-args }} | ||
|
|
||
| bazel-build-test: | ||
| name: Bazel Build & Test | ||
| if: ${{ inputs.bazel-enabled }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Bazel | ||
| uses: bazel-contrib/setup-bazel@0.14.0 | ||
| with: | ||
| bazelisk-cache: true | ||
| disk-cache: ${{ github.workflow }}-bazel | ||
| repository-cache: true | ||
|
|
||
| - name: Bazel build | ||
| run: bazel build ${{ inputs.bazel-build-targets }} | ||
|
|
||
| - name: Bazel test | ||
| run: bazel test ${{ inputs.bazel-test-targets }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| name: Coverage | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| rust-version: | ||
| description: "Rust toolchain version (default: nightly)" | ||
| type: string | ||
| default: "nightly" | ||
| cargo-locked: | ||
| description: "Use --locked flag for cargo commands" | ||
| type: boolean | ||
| default: true | ||
| coverage-threshold: | ||
| description: "Minimum line coverage percentage (0 to disable enforcement)" | ||
| type: number | ||
| default: 0 | ||
| exclude-crates: | ||
| description: "Space-separated list of crates to exclude from coverage" | ||
| type: string | ||
| default: "" | ||
| ignore-filename-regex: | ||
| description: "Regex for filenames to ignore in coverage" | ||
| type: string | ||
| default: "" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| coverage: | ||
| name: Code Coverage | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| IGNORE_REGEX: ${{ inputs.ignore-filename-regex }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Rust toolchain | ||
| uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
| with: | ||
| toolchain: ${{ inputs.rust-version }} | ||
| components: llvm-tools-preview | ||
|
|
||
| - name: Install cargo-llvm-cov | ||
| uses: taiki-e/install-action@cargo-llvm-cov | ||
|
|
||
| - name: Build exclude flags | ||
| id: flags | ||
| shell: bash | ||
| run: | | ||
| LOCKED="${{ inputs.cargo-locked && '--locked' || '' }}" | ||
| EXCLUDES="" | ||
| for crate in ${{ inputs.exclude-crates }}; do | ||
| EXCLUDES="$EXCLUDES --exclude $crate" | ||
| done | ||
| echo "locked=$LOCKED" >> "$GITHUB_OUTPUT" | ||
| echo "excludes=$EXCLUDES" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Generate coverage (LCOV) | ||
| shell: bash | ||
| run: | | ||
| ARGS=(--workspace ${{ steps.flags.outputs.locked }} ${{ steps.flags.outputs.excludes }}) | ||
| if [ -n "$IGNORE_REGEX" ]; then | ||
| ARGS+=(--ignore-filename-regex "$IGNORE_REGEX") | ||
| fi | ||
| cargo llvm-cov "${ARGS[@]}" --lcov --output-path lcov.info | ||
|
|
||
| - name: Generate coverage summary | ||
| id: coverage | ||
| shell: bash | ||
| run: | | ||
| ARGS=(--workspace ${{ steps.flags.outputs.locked }} ${{ steps.flags.outputs.excludes }}) | ||
| if [ -n "$IGNORE_REGEX" ]; then | ||
| ARGS+=(--ignore-filename-regex "$IGNORE_REGEX") | ||
| fi | ||
| cargo llvm-cov "${ARGS[@]}" --json --no-run --output-path coverage.json | ||
| TOTAL_LINE_COV=$(jq '.data[0].totals.lines.percent' coverage.json) | ||
| rm -f coverage.json | ||
|
|
||
| REPORT=$(cargo llvm-cov "${ARGS[@]}" --no-run 2>&1) | ||
| echo "$REPORT" | ||
|
|
||
| echo "total_coverage=$TOTAL_LINE_COV" >> "$GITHUB_OUTPUT" | ||
| echo "### Coverage Report" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "**Total line coverage: ${TOTAL_LINE_COV}%**" >> "$GITHUB_STEP_SUMMARY" | ||
| echo "" >> "$GITHUB_STEP_SUMMARY" | ||
| echo '```' >> "$GITHUB_STEP_SUMMARY" | ||
| echo "$REPORT" >> "$GITHUB_STEP_SUMMARY" | ||
| echo '```' >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
| - name: Upload coverage artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: coverage-lcov | ||
| path: lcov.info | ||
| retention-days: 30 | ||
|
|
||
| - name: Enforce coverage threshold | ||
| if: ${{ inputs.coverage-threshold > 0 }} | ||
| shell: bash | ||
| run: | | ||
| COVERAGE="${{ steps.coverage.outputs.total_coverage }}" | ||
| THRESHOLD="${{ inputs.coverage-threshold }}" | ||
| echo "Coverage: ${COVERAGE}%, Threshold: ${THRESHOLD}%" | ||
| if (( $(echo "$COVERAGE < $THRESHOLD" | bc -l) )); then | ||
| echo "::error::Coverage ${COVERAGE}% is below threshold ${THRESHOLD}%" | ||
| exit 1 | ||
| fi | ||
| echo "Coverage ${COVERAGE}% meets threshold ${THRESHOLD}%" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: 2026 The Contributors to Eclipse OpenSOVD (see CONTRIBUTORS) | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| name: Miri | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| rust-nightly-version: | ||
| description: "Rust nightly version to use (e.g. nightly or nightly-2025-07-14)" | ||
| type: string | ||
| default: "nightly" | ||
| cargo-locked: | ||
| description: "Use --locked flag for cargo commands" | ||
| type: boolean | ||
| default: true | ||
| exclude-crates: | ||
| description: "Space-separated list of crates to exclude from Miri" | ||
| type: string | ||
| default: "" | ||
| miri-flags: | ||
| description: "Extra MIRIFLAGS environment variable" | ||
| type: string | ||
| default: "-Zmiri-disable-isolation" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| cargo-miri: | ||
| name: Miri (Undefined Behavior Check) | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| MIRIFLAGS: ${{ inputs.miri-flags }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Rust toolchain | ||
| uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
| with: | ||
| toolchain: ${{ inputs.rust-nightly-version }} | ||
| components: miri, rust-src | ||
|
|
||
| - name: Build exclude flags | ||
| id: flags | ||
| shell: bash | ||
| run: | | ||
| LOCKED="${{ inputs.cargo-locked && '--locked' || '' }}" | ||
| EXCLUDES="" | ||
| for crate in ${{ inputs.exclude-crates }}; do | ||
| EXCLUDES="$EXCLUDES --exclude $crate" | ||
| done | ||
| echo "locked=$LOCKED" >> "$GITHUB_OUTPUT" | ||
| echo "excludes=$EXCLUDES" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Run Miri | ||
| run: | | ||
| cargo miri test --workspace \ | ||
| ${{ steps.flags.outputs.locked }} \ | ||
| ${{ steps.flags.outputs.excludes }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.