Skip to content

knoepfel building and testing Framework-R-D/phlex #2664

knoepfel building and testing Framework-R-D/phlex

knoepfel building and testing Framework-R-D/phlex #2664

Workflow file for this run

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]
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: ""
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 == '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' ||
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
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: Extract repository name
id: repo_name
env:
REPO_FULL_NAME: ${{ needs.setup.outputs.repo }}
run: echo "name=${REPO_FULL_NAME##*/}" >> "$GITHUB_OUTPUT"
- 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' && format('-D{0}_ENABLE_ASAN=ON', steps.repo_name.outputs.name) || '' }}
${{ matrix.sanitizer == 'tsan' && format('-D{0}_ENABLE_TSAN=ON', steps.repo_name.outputs.name) || '' }}
- 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'
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
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