Skip to content

greenc-FNAL building and testing Phlex #760

greenc-FNAL building and testing Phlex

greenc-FNAL building and testing Phlex #760

Workflow file for this run

name: CMake Build and Test
run-name: "${{ github.actor }} building and testing Phlex"
on:
pull_request:
branches: [ main, develop ]
issue_comment:
types: [created]
push:
branches: [ main, develop ]
workflow_dispatch:
inputs:
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 all except clang/none and clang/valgrind.
required: false
default: ''
permissions:
contents: read
pull-requests: read
env:
BUILD_TYPE: Release
CICOLOR_FORCE: 1
jobs:
pre-check:
if: >
github.event_name == 'workflow_dispatch' ||
github.event_name == 'pull_request' ||
(
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
(github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'OWNER') &&
startsWith(github.event.comment.body, '@phlexbot build')
)
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
outputs:
is_act: ${{ steps.detect_act.outputs.is_act }}
pr_details: ${{ steps.pr.outputs.result }}
sha: ${{ steps.pr.outputs.sha || github.sha }}
repo: ${{ steps.pr.outputs.repo || github.repository }}
steps:
- name: Get PR details for comment trigger
if: github.event_name == 'issue_comment'
id: pr
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
return {
ref: pr.data.head.ref,
sha: pr.data.head.sha,
base_sha: pr.data.base.sha
};
- name: Detect act environment
id: detect_act
uses: Framework-R-D/phlex/.github/actions/detect-act-env@main
detect-changes:
needs: pre-check
if: >
needs.pre-check.result == 'success' &&
(github.event_name == 'pull_request' || github.event_name == 'push') &&
needs.pre-check.outputs.is_act != 'true'
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
has_changes: ${{ steps.filter.outputs.matched }}
steps:
- name: Check out source code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
path: phlex-src
- name: Detect C++ and CMake changes
id: filter
uses: Framework-R-D/phlex/.github/actions/detect-relevant-changes@main
with:
repo-path: phlex-src
base-ref: ${{ github.event.pull_request.base.sha || github.event.before }}
head-ref: ${{ github.event.pull_request.head.sha || github.sha }}
file-type: |
cpp
cmake
- name: Report detection outcome
run: |
if [ "${{ steps.filter.outputs.matched }}" != "true" ]; then
echo "::notice::No C++ or CMake changes detected; build will be skipped."
else
echo "::group::C++ and CMake relevant files"
printf '%s\n' "${{ steps.filter.outputs.matched_files }}"
echo "::endgroup::"
fi
generate-matrix:
needs: pre-check
if: needs.pre-check.result == 'success'
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: ${{ github.event.inputs.build-combinations }}
comment-body: ${{ github.event.comment.body }}
build:
needs: [pre-check, detect-changes, generate-matrix]
if: >
needs.pre-check.result == 'success' &&
(
github.event_name == 'workflow_dispatch' ||
github.event_name == 'issue_comment' ||
needs.pre-check.outputs.is_act == 'true' ||
(needs.detect-changes.result == 'success' && needs.detect-changes.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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
path: phlex-src
ref: ${{ needs.pre-check.outputs.sha }}
repository: ${{ needs.pre-check.outputs.repo }}
- name: Setup build environment
uses: Framework-R-D/phlex/.github/actions/setup-build-env@main
- name: Announce CMake configuration
run: echo "➡️ Configuring CMake..."
- name: Configure CMake
id: configure
uses: Framework-R-D/phlex/.github/actions/configure-cmake@main
with:
build-type: ${{ env.BUILD_TYPE }}
cpp-compiler: ${{ matrix.compiler == 'gcc' && 'g++' || 'clang++' }}
extra-options: |
${{ matrix.sanitizer == 'asan' && '-DPHLEX_ENABLE_ASAN=ON' || '' }}
${{ matrix.sanitizer == 'tsan' && '-DPHLEX_ENABLE_TSAN=ON' || '' }}
- name: Build
id: build
uses: Framework-R-D/phlex/.github/actions/build-cmake@main
- name: Run tests
if: matrix.sanitizer != 'valgrind'
run: |
. /entrypoint.sh
cd "$GITHUB_WORKSPACE/phlex-build"
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'
run: |
. /entrypoint.sh
cd "$GITHUB_WORKSPACE/phlex-build"
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: [pre-check, detect-changes]
if: >
needs.pre-check.result == 'success' &&
github.event_name != 'workflow_dispatch' &&
needs.pre-check.outputs.is_act != 'true' &&
needs.detect-changes.result == 'success' &&
needs.detect-changes.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."