diff --git a/.github/actions/gitlint/action.yml b/.github/actions/gitlint/action.yml deleted file mode 100644 index cb16e6ff02..0000000000 --- a/.github/actions/gitlint/action.yml +++ /dev/null @@ -1,44 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2024 Contributors to the Eclipse Foundation -# -# 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 -# -# SPDX-License-Identifier: Apache-2.0 -# ******************************************************************************* - -name: "Gitlint Action" -description: "An action to install and run Gitlint on PR commits" -inputs: - pr-number: - description: "Pull Request number used to fetch commits" - required: true - base-branch: - description: "Base branch to compare commits against (default: origin/main)" - default: "origin/main" - required: false -runs: - using: "docker" - image: "jorisroovers/gitlint:0.19.1" - entrypoint: /bin/sh - args: - - -c - - | - git config --global --add safe.directory /github/workspace && \ - git fetch origin +refs/heads/main:refs/remotes/origin/main && \ - git fetch origin +refs/pull/${{ inputs.pr-number }}/head && \ - # Fetch the upstream .gitlint config from eclipse-score/score - git clone --depth 1 https://github.com/eclipse-score/score.git /tmp/score-gitlint && \ - if ! gitlint --config /tmp/score-gitlint/.gitlint --commits origin/main..HEAD; then \ - echo -e "\nWARNING: Your commit message does not follow the required format." && \ - echo "Formatting rules: https://eclipse-score.github.io/score/main/contribute/general/git.html#commit-message-format" && \ - echo -e "To fix your commit message, run:\n" && \ - echo " git commit --amend" && \ - echo "Then update your commit (fix gitlint warnings). Finally, force-push:" && \ - echo " git push --force-with-lease" && \ - exit 1; \ - fi diff --git a/.github/ci.yml b/.github/ci.yml new file mode 100644 index 0000000000..876e50a45d --- /dev/null +++ b/.github/ci.yml @@ -0,0 +1,66 @@ +# Copyright (c) 2026 Contributors to the Eclipse Foundation +# +# 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 +# +# SPDX-License-Identifier: Apache-2.0 + +# Select this module's Linux checks, quality policy and Docs in this file. +# Each named build/test profile runs independently with reports collected centrally. +# Profiles default to Linux x86_64, the repository root and test target `//...`. +# Maintain Bazel configs and target selections here; shared CI handles execution. +# QNX remains in its separate workflow and credential boundary. +# Configuration reference: https://github.com/eclipse-score/cicd-workflows/blob/central-workflow/.github/workflows/on-pr.md +schema-version: 2 +tests: + # Build the selected examples/libraries first, then test the full workspace. + linux-native: + bazel-configs: x86_64-linux + bazel-build-targets: //examples/... //score/... + # Sanitizers are enabled by the Bazel configs, independently of profile names. + # These profiles test //... without a preceding all-target build because of + # the module issues linked below. + # https://github.com/eclipse-score/lifecycle/issues/476 + asan-ubsan-lsan: + bazel-configs: x86_64-linux,asan_ubsan_lsan + # https://github.com/eclipse-score/lifecycle/issues/474 + tsan: + bazel-configs: x86_64-linux,tsan +# This module target owns the combined C++/Rust coverage pipeline. +# Shared CI runs it with COVERAGE_THRESHOLD=66 and collects coverage_artifacts +# for the HTML artifact and Docs; maintain language-specific coverage logic here. +coverage: + bazel-target: //quality/coverage:run_coverage + coverage-threshold: 66 + # release.yml downloads this artifact by name. + artifact-name: coverage-html +# Compile the selected targets for ARM without trying to execute ARM tests. +builds: + linux-cross: + name: compiler + bazel-configs: arm64-linux + bazel-build-targets: //examples/... //score/... + architecture: aarch64 +# Enable the shared Cargo Clippy check with the version in rust-toolchain.toml. +# An empty mapping enables the check with standard settings. +clippy: {} +# Check PR commit messages using the repository Gitlint policy. +gitlint: true +# Run the module's CodeQL Bazel analysis and publish the selected reports. +# Unsuppressed findings fail CI; adjust the report list as analysis policy evolves. +codeql: + bazel-configs: x86_64-linux + reports: [cert-cpp-l1, cert-c-l1, cpp-code-scanning, code-complexity] + fail-on-findings: true +# Build //:docs with coverage and the explicitly selected native test reports. +# The explicit selection avoids mixing sanitizer results into the regular report. +# Also run //:docs_check and //:docs_link_check before the final Docs build. +# The existing publishing workflow deploys the finished github-pages artifact. +docs: + tests: linux-native-tests + check: true + link-check: true diff --git a/.github/workflows/_codeql.yml b/.github/workflows/_codeql.yml index 3c6da128b1..9c3f8c5de1 100644 --- a/.github/workflows/_codeql.yml +++ b/.github/workflows/_codeql.yml @@ -28,96 +28,19 @@ on: type: string default: "false" +# Keep scheduled/manual analysis independent of the PR workflow. Execution and +# analysis policy are shared with the CodeQL profile in .github/ci.yml. jobs: codeql-linux: - name: Run CodeQL analysis (Linux) - runs-on: ubuntu-24.04 + name: CodeQL permissions: contents: read - actions: write + actions: read security-events: write - steps: - - uses: actions/checkout@v7 - - - name: Setup Bazel with shared caching - uses: eclipse-score/cicd-actions/setup-bazel-cache@cache - with: - disk-cache-key: ${{ github.job }}-codeql - enable-profiling: false - - - name: Fetch dependencies (--nobuild) - if: inputs.fetch-only == 'true' - run: bazel build --config=x86_64-linux --nobuild //... - - - name: Run CodeQL analysis (Linux) - if: inputs.fetch-only != 'true' - id: run-codeql - run: | - set -euo pipefail - - # As a first step, we only active the non-misra ruleset - bazel run --config=x86_64-linux //quality/static_analysis:codeql_lint -- \ - --output-dir /tmp/codeql-results/linux \ - --output-prefix codeql-nightly \ - --report cert-cpp-l1 cert-c-l1 cpp-code-scanning code-complexity \ - --target $(bazel query 'kind("cc_library|cc_binary", //score/...)') - - - name: Deduplicate and upload SARIF - if: ${{ !cancelled() && inputs.fetch-only != 'true' && steps.run-codeql.outcome == 'success' }} - id: merge-codeql - env: - GH_TOKEN: ${{ github.token }} - run: | - set -euo pipefail - - mkdir -p /tmp/codeql-results/publish - - # Deduplicate SARIF results using the SARIF Multitool - bazel run --config=x86_64-linux @sarif_multitool//:sarif_multitool_cli -- \ - merge /tmp/codeql-results/linux/codeql-nightly.sarif \ - --merge-empty-logs \ - --output-file /tmp/codeql-results/publish/codeql-nightly.sarif - - - name: Upload SARIF to GitHub Code Scanning - if: ${{ !cancelled() && steps.merge-codeql.outcome == 'success' }} - continue-on-error: true - uses: github/codeql-action/upload-sarif@v4 - with: - sarif_file: /tmp/codeql-results/publish/codeql-nightly.sarif - category: codeql-nightly - - - name: Upload SARIF results - if: ${{ !cancelled() && steps.merge-codeql.outcome == 'success' }} - uses: actions/upload-artifact@v7 - with: - name: codeql-sarif-results - path: /tmp/codeql-results/publish/codeql-nightly.sarif - retention-days: 30 - - - name: Fail on unsuppressed findings - if: ${{ !cancelled() && inputs.fail-on-findings == 'true' && steps.merge-codeql.outcome == 'success' }} - run: | - set -euo pipefail - - # A finding counts as suppressed if it carries any SARIF suppression - # (e.g. in-source `// codeql[...]` comments). - jq -r ' - [.runs[].results[]? | select((.suppressions // []) | length == 0)] - | .[] - | "\(.ruleId // "unknown-rule"): \(.message.text // "") (\(.locations[0].physicalLocation.artifactLocation.uri // "?"):\(.locations[0].physicalLocation.region.startLine // "?"))" - ' /tmp/codeql-results/publish/codeql-nightly.sarif | tee /tmp/codeql-results/unsuppressed.txt - - count=$(wc -l < /tmp/codeql-results/unsuppressed.txt) - if [ "${count}" -gt 0 ]; then - echo "::error::CodeQL reported ${count} finding(s) without a suppression." - exit 1 - fi - - - name: Upload compliance reports - if: ${{ !cancelled() && inputs.fetch-only != 'true' }} - uses: actions/upload-artifact@v7 - with: - name: codeql-compliance-reports - path: /tmp/codeql-results/linux/analysis_reports/ - retention-days: 30 - if-no-files-found: warn + uses: eclipse-score/cicd-workflows/.github/workflows/configured-quality.yml@central-workflow + with: + config: .github/ci.yml + only-codeql: true + fetch-only: ${{ inputs.fetch-only == 'true' }} + # Nightly analysis historically reports findings without failing. + fail-on-findings: ${{ inputs.fail-on-findings || 'false' }} diff --git a/.github/workflows/code_coverage.yml b/.github/workflows/code_coverage.yml deleted file mode 100644 index d62c5a8f03..0000000000 --- a/.github/workflows/code_coverage.yml +++ /dev/null @@ -1,61 +0,0 @@ -# ******************************************************************************* -# Copyright (c) 2026 Contributors to the Eclipse Foundation -# -# 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 -# -# SPDX-License-Identifier: Apache-2.0 -# ******************************************************************************* -# -# Reusable unified LLVM source-based coverage (C++ and Rust in one report), - -name: Code coverage - -on: - workflow_call: - inputs: - coverage-threshold: - description: 'Minimum effective line coverage percentage to enforce.' - type: number - default: 66 - artifact-name: - description: 'Name of the uploaded coverage report artifact.' - type: string - default: coverage-html - retention-days: - description: 'Retention period for the uploaded coverage artifact.' - type: number - default: 10 - -jobs: - coverage: - name: Coverage - runs-on: ubuntu-24.04 - permissions: - contents: read - steps: - - name: Checkout code - uses: actions/checkout@v7 - - - name: Setup Bazel with shared caching - uses: eclipse-score/cicd-actions/setup-bazel-cache@e2a2a587a759b681632040ec1e1294015a0405f5 # setup-bazel-cache/v0.1.0 - with: - disk-cache-key: ${{ github.job }} - - - name: Generate coverage report and enforce threshold - env: - COVERAGE_THRESHOLD: ${{ inputs.coverage-threshold }} - run: | - bazel run //quality/coverage:run_coverage - - - name: Upload coverage report - if: always() - uses: actions/upload-artifact@v7 - with: - name: ${{ inputs.artifact-name }} - path: coverage_artifacts - retention-days: ${{ inputs.retention-days }} diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml index b02f7264d2..f4742a2ab1 100644 --- a/.github/workflows/on-pr.yml +++ b/.github/workflows/on-pr.yml @@ -27,193 +27,24 @@ on: jobs: common: - name: Common checks + name: Central CI permissions: contents: read - uses: eclipse-score/cicd-workflows/.github/workflows/on-pr.yml@on-pr/v0.0.0 - - # We don't use eclipse-score/cicd-workflows/.github/workflows/tests.yml - # because it is more resource efficient to build and test in the same job. - # Also the cache name in the template is not configurable. - build: - name: Build and test ${{ matrix.name }} - runs-on: ubuntu-24.04 - strategy: - fail-fast: false - matrix: - include: - - name: x86_64-linux - bazel-args: --config=x86_64-linux - build: true - test: true - - name: arm64-linux - bazel-args: --config=arm64-linux - build: true - test: false # Cannot run on x86_64 - - name: asan_ubsan_lsan - bazel-args: --config=x86_64-linux --config=asan_ubsan_lsan - build: false # https://github.com/eclipse-score/lifecycle/issues/476 - test: true - - name: tsan - bazel-args: --config=x86_64-linux --config=tsan - build: false # https://github.com/eclipse-score/lifecycle/issues/474 - test: true - permissions: - contents: read - steps: - - name: Checkout code - uses: actions/checkout@v7 - - - name: Setup Bazel with shared caching - uses: eclipse-score/cicd-actions/setup-bazel-cache@e2a2a587a759b681632040ec1e1294015a0405f5 # setup-bazel-cache/v0.1.0 - with: - disk-cache-key: ${{ github.job }}-${{ matrix.name }} - - - name: Build with Bazel - if: matrix.build - run: | - bazel build \ - --lockfile_mode=error \ - ${{ matrix.bazel-args }} \ - //examples/... \ - //score/... - - - name: Test with Bazel - if: matrix.test - run: | - bazel test \ - --lockfile_mode=error \ - ${{ matrix.bazel-args }} \ - //... - - - name: Upload test logs - if: always() - uses: actions/upload-artifact@v7 - with: - name: bazel-testlogs-${{ matrix.name }} - path: bazel-testlogs/ - retention-days: 7 - - clippy: - name: Clippy - runs-on: ubuntu-24.04 - permissions: - contents: read - steps: - - uses: actions/checkout@v7 - with: - fetch-depth: 0 - - - name: Cache Cargo registry, git deps & target - uses: actions/cache@v6 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-lint-clippy-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-lint-clippy- - - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: 1.90.0 - override: true - components: clippy - - - name: check clippy errors - uses: actions-rs/cargo@v1 - with: - command: clippy - args: --all-features --all-targets --workspace -- -D warnings - - coverage: - name: Coverage - uses: ./.github/workflows/code_coverage.yml - permissions: - contents: read - - codeql: - name: CodeQL - uses: ./.github/workflows/_codeql.yml - permissions: - contents: read - actions: write + # Only SARIF publication uses these grants; checks run read-only. + actions: read security-events: write + # Module policy and check selection live in ci.yml. + uses: eclipse-score/cicd-workflows/.github/workflows/on-pr.yml@central-workflow with: - fail-on-findings: "true" - - docs-check: - name: Check documentation - uses: eclipse-score/cicd-workflows/.github/workflows/docs-verify.yml@8d80e8df150cae21d53cbc8031d0f970648f7a67 # v0.0.3 - permissions: - pull-requests: write - contents: read - with: - bazel-docs-verify-target: "--lockfile_mode=error //:docs_check" - - docs-link-check: - name: Check links in documentation - uses: eclipse-score/cicd-workflows/.github/workflows/docs-verify.yml@8d80e8df150cae21d53cbc8031d0f970648f7a67 # v0.0.3 - permissions: - pull-requests: write - contents: read - with: - bazel-docs-verify-target: "--lockfile_mode=error //:docs_link_check" - - docs-build: - name: Build documentation - needs: - - build - uses: eclipse-score/cicd-workflows/.github/workflows/docs.yml@8d80e8df150cae21d53cbc8031d0f970648f7a67 # v0.0.3 - permissions: - contents: read - with: - # the bazel-target depends on your repo specific docs_targets configuration (e.g. "suffix") - bazel-target: | - --lockfile_mode=error \ - //:docs \ - -- \ - --github_user=${{ github.repository_owner }} \ - --github_repo=${{ github.event.repository.name }} - retention-days: 3 - tests-report-artifact: bazel-testlogs-x86_64-linux - - gitlint: - name: Check commit messages - runs-on: ubuntu-24.04 - if: ${{ github.event_name == 'pull_request' }} - permissions: - contents: read - steps: - - name: Checkout code - uses: actions/checkout@v7 - with: - fetch-depth: 0 - - name: Run Gitlint Action - uses: ./.github/actions/gitlint - with: - pr-number: ${{ github.event.number }} - base-branch: ${{ github.event.pull_request.base.ref }} + workflow-config-yaml: .github/ci.yml ready: name: Ready to merge - needs: - - common - - build - - docs-check - - docs-link-check - - docs-build - - clippy - - coverage - - codeql - - gitlint + needs: common runs-on: ubuntu-slim permissions: {} if: ${{ !cancelled() && (github.event_name == 'pull_request' || github.event_name == 'merge_group') }} steps: - name: Fail if any required job did not succeed - if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') + if: needs.common.result != 'success' run: false