greenc-FNAL building and testing Framework-R-D/phlex #2905
Workflow file for this run
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
| name: CMake Build and Test | |
| run-name: "${{ github.actor }} building and testing ${{ github.repository }}" | |
| "on": | |
| pull_request: | |
| issue_comment: | |
| types: [created] | |
| push: | |
| branches: [main, develop] | |
| schedule: | |
| - cron: "7 18 * * 6" | |
| workflow_dispatch: | |
| inputs: | |
| ref: | |
| description: "The branch, ref, or SHA to checkout. Defaults to the repository's default branch." | |
| required: false | |
| type: string | |
| build-combinations: | |
| description: | | |
| A space- or comma-separated list of build combinations to run. | |
| Syntax examples: | |
| - `gcc/asan clang/tsan` (run only these two) | |
| - `all` (run all combinations) | |
| - `all -clang/none -clang/valgrind` (run all except specified) | |
| - `+clang/none +clang/valgrind` (run default matrix plus specified) | |
| Default (if empty): Run `gcc/none` | |
| required: false | |
| default: "" | |
| perfetto-heap-profile: | |
| description: "Enable heap profiling for Perfetto runs" | |
| required: false | |
| type: boolean | |
| default: false | |
| perfetto-cpu-profile: | |
| description: "Enable CPU profiling for Perfetto runs" | |
| required: false | |
| type: boolean | |
| default: true | |
| workflow_call: | |
| inputs: | |
| checkout-path: | |
| description: "Path to check out code to" | |
| required: false | |
| type: string | |
| build-path: | |
| description: "Path for build artifacts" | |
| required: false | |
| type: string | |
| skip-relevance-check: | |
| description: "Bypass relevance check" | |
| required: false | |
| type: boolean | |
| default: false | |
| build-combinations: | |
| description: "A space- or comma-separated list of build combinations to run" | |
| required: false | |
| type: string | |
| ref: | |
| description: "The branch, ref, or SHA to checkout" | |
| required: false | |
| type: string | |
| repo: | |
| description: "The repository to checkout from" | |
| required: false | |
| type: string | |
| pr-base-sha: | |
| description: "Base SHA of the PR for relevance check" | |
| required: false | |
| type: string | |
| pr-head-sha: | |
| description: "Head SHA of the PR for relevance check" | |
| required: false | |
| type: string | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| env: | |
| BUILD_TYPE: Release | |
| CICOLOR_FORCE: 1 | |
| jobs: | |
| setup: | |
| if: > | |
| github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' || github.event_name == 'push' || | |
| github.event_name == 'schedule' || github.event_name == 'workflow_call' || ( | |
| github.event_name == 'issue_comment' && | |
| github.event.issue.pull_request && | |
| contains(fromJSON('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association) && | |
| startsWith(github.event.comment.body, format('@{0}bot build', github.event.repository.name)) | |
| ) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: read | |
| outputs: | |
| is_act: ${{ steps.setup.outputs.is_act }} | |
| ref: ${{ steps.setup.outputs.ref }} | |
| repo: ${{ steps.setup.outputs.repo }} | |
| base_sha: ${{ steps.setup.outputs.base_sha }} | |
| pr_number: ${{ steps.setup.outputs.pr_number }} | |
| checkout_path: ${{ steps.setup.outputs.checkout_path }} | |
| build_path: ${{ steps.setup.outputs.build_path }} | |
| has_changes: ${{ steps.setup.outputs.has_changes }} | |
| steps: | |
| - name: Workflow setup | |
| id: setup | |
| uses: Framework-R-D/phlex/.github/actions/workflow-setup@main | |
| with: | |
| ref: ${{ inputs.ref }} | |
| repo: ${{ inputs.repo }} | |
| pr-base-sha: ${{ inputs.pr-base-sha }} | |
| checkout-path: ${{ inputs.checkout-path }} | |
| build-path: ${{ inputs.build-path }} | |
| head-ref: ${{ inputs.pr-head-sha }} | |
| file-type: | | |
| cpp | |
| cmake | |
| generate-matrix: | |
| needs: setup | |
| if: > | |
| needs.setup.result == 'success' && ( | |
| github.event_name == 'workflow_dispatch' || | |
| inputs.skip-relevance-check || | |
| needs.setup.outputs.has_changes == 'true' | |
| ) | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.generate.outputs.matrix }} | |
| steps: | |
| - id: generate | |
| uses: Framework-R-D/phlex/.github/actions/generate-build-matrix@main | |
| with: | |
| user-input: ${{ inputs.build-combinations || github.event.inputs.build-combinations }} | |
| comment-body: ${{ github.event.comment.body }} | |
| build: | |
| needs: [setup, generate-matrix] | |
| if: > | |
| always() && needs.setup.result == 'success' && ( | |
| github.event_name == 'workflow_dispatch' || | |
| github.event_name == 'schedule' || | |
| inputs.skip-relevance-check || | |
| needs.setup.outputs.has_changes == 'true' | |
| ) | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }} | |
| container: | |
| image: ghcr.io/framework-r-d/phlex-ci:latest | |
| options: --cap-add=SYS_PTRACE | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| path: ${{ needs.setup.outputs.checkout_path }} | |
| ref: ${{ needs.setup.outputs.ref }} | |
| repository: ${{ needs.setup.outputs.repo }} | |
| persist-credentials: false | |
| - name: Setup build environment | |
| uses: Framework-R-D/phlex/.github/actions/setup-build-env@main | |
| with: | |
| build-path: ${{ needs.setup.outputs.build_path }} | |
| - name: Announce CMake configuration | |
| run: echo "➡️ Configuring CMake..." | |
| - name: Configure CMake | |
| id: configure | |
| uses: Framework-R-D/phlex/.github/actions/configure-cmake@main | |
| with: | |
| source-path: ${{ needs.setup.outputs.checkout_path }} | |
| build-path: ${{ needs.setup.outputs.build_path }} | |
| build-type: ${{ env.BUILD_TYPE }} | |
| cpp-compiler: ${{ matrix.compiler == 'gcc' && 'g++' || 'clang++' }} | |
| extra-options: | | |
| ${{ matrix.sanitizer == 'asan' && '-DENABLE_ASAN=ON' || '' }} | |
| ${{ matrix.sanitizer == 'tsan' && '-DENABLE_TSAN=ON' || '' }} | |
| ${{ matrix.sanitizer == 'perfetto' && '-DENABLE_PERFETTO=ON' || '' }} | |
| - name: Build | |
| id: build | |
| uses: Framework-R-D/phlex/.github/actions/build-cmake@main | |
| with: | |
| build-path: ${{ needs.setup.outputs.build_path }} | |
| - name: Run tests | |
| if: matrix.sanitizer != 'valgrind' && matrix.sanitizer != 'perfetto' | |
| working-directory: ${{ needs.setup.outputs.build_path }} | |
| run: | | |
| . /entrypoint.sh | |
| echo "➡️ Running tests..." | |
| echo "::group::Running ctest" | |
| if ctest --progress --output-on-failure -j "$(nproc)"; then | |
| echo "::endgroup::" | |
| echo "✅ All tests passed." | |
| else | |
| echo "::endgroup::" | |
| echo "::error:: Some tests failed." | |
| exit 1 | |
| fi | |
| - name: Run Valgrind tests | |
| if: matrix.sanitizer == 'valgrind' | |
| working-directory: ${{ needs.setup.outputs.build_path }} | |
| run: | | |
| . /entrypoint.sh | |
| echo "➡️ Running Valgrind tests..." | |
| echo "::group::Running ctest -T memcheck" | |
| if ctest -T memcheck; then | |
| echo "::endgroup::" | |
| echo "✅ Valgrind tests passed." | |
| else | |
| echo "::endgroup::" | |
| echo "⚠️ Valgrind tests failed, but the workflow will continue." | |
| fi | |
| - name: Run Perfetto profiling | |
| if: matrix.sanitizer == 'perfetto' | |
| working-directory: ${{ needs.setup.outputs.build_path }} | |
| env: | |
| PERFETTO_HEAP_PROFILE: ${{ github.event.inputs.perfetto-heap-profile || 'false' }} | |
| PERFETTO_CPU_PROFILE: | |
| ${{ (github.event.inputs.perfetto-cpu-profile != null && github.event.inputs.perfetto-cpu-profile) || true | |
| }} | |
| run: | | |
| . /entrypoint.sh | |
| echo "➡️ Running tests with Perfetto profiling..." | |
| # Set perf_event_paranoid for CPU profiling | |
| if [ "$PERFETTO_CPU_PROFILE" = "true" ]; then | |
| echo "Configuring perf_event_paranoid for CPU profiling" | |
| echo -1 | tee /proc/sys/kernel/perf_event_paranoid 2>/dev/null || echo "Warning: Could not set perf_event_paranoid" | |
| fi | |
| # Configure profiling based on environment | |
| TRACEBOX_ARGS=() | |
| if [ "$PERFETTO_HEAP_PROFILE" = "true" ]; then | |
| echo "Enabling heap profiling" | |
| TRACEBOX_ARGS+=(--app "*" --heapprofd) | |
| fi | |
| if [ "$PERFETTO_CPU_PROFILE" = "true" ]; then | |
| echo "Enabling CPU profiling" | |
| TRACEBOX_ARGS+=(--cpu-freq --cpu-idle --cpu-sched) | |
| fi | |
| # Run tests with or without tracebox wrapper | |
| TEST_RESULT=0 | |
| if [ "${#TRACEBOX_ARGS[@]}" -gt 0 ]; then | |
| echo "::group::Running ctest with tracebox" | |
| tracebox "${TRACEBOX_ARGS[@]}" -o "perfetto-trace.pftrace" -- ctest --progress --output-on-failure -j "$(nproc)" || TEST_RESULT=$? | |
| else | |
| echo "::group::Running ctest with Perfetto SDK tracing" | |
| ctest --progress --output-on-failure -j "$(nproc)" || TEST_RESULT=$? | |
| fi | |
| echo "::endgroup::" | |
| if [ "${TEST_RESULT:-0}" -eq 0 ]; then | |
| echo "✅ Perfetto profiling completed." | |
| else | |
| echo "::error:: Perfetto profiling failed." | |
| exit 1 | |
| fi | |
| - name: Upload Perfetto traces | |
| if: matrix.sanitizer == 'perfetto' | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | |
| with: | |
| name: perfetto-traces-${{ matrix.compiler }} | |
| path: | | |
| ${{ needs.setup.outputs.build_path }}/**/*.pftrace | |
| retention-days: 30 | |
| if-no-files-found: warn | |
| cmake-build-skipped: | |
| needs: [setup] | |
| if: > | |
| needs.setup.result == 'success' && github.event_name != 'workflow_dispatch' && !inputs.skip-relevance-check && | |
| needs.setup.outputs.is_act != 'true' && needs.setup.outputs.has_changes != 'true' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: No relevant C++ or CMake changes detected | |
| run: echo "::notice::No relevant C++ or CMake changes detected; build skipped." | |
| build-complete: | |
| needs: [setup, build] | |
| if: > | |
| always() && github.event_name == 'issue_comment' && needs.setup.result == 'success' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Comment on build completion | |
| uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1 | |
| with: | |
| # yamllint disable rule:line-length | |
| message: | | |
| Build and test workflow completed. | |
| **Result:** ${{ needs.build.result == 'success' && '✅ All builds and tests passed.' | |
| || needs.build.result == 'failure' && '❌ Some builds or tests failed.' | |
| || needs.build.result == 'cancelled' && '⚠️ Build was cancelled before completion.' | |
| || needs.build.result == 'skipped' && 'ℹ️ No relevant C++ or CMake changes detected; build skipped.' | |
| || format('ℹ️ Build job completed with status: {0}.', needs.build.result) }} | |
| See the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for detailed results. | |
| # yamllint enable |