Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/build-cmake/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ runs:
BUILD_PATH: ${{ inputs.build-path }}
TARGET: ${{ inputs.target }}
PARALLEL_JOBS: ${{ inputs.parallel-jobs }}
CICOLOR_FORCE: 1
37 changes: 23 additions & 14 deletions .github/actions/configure-cmake/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,30 @@ runs:
cd "$GITHUB_WORKSPACE/$BUILD_PATH"
SOURCE_DIR="$GITHUB_WORKSPACE/$SOURCE_PATH"
echo "Configuring with CMake preset: $PRESET"

# Base CMake options
CMAKE_ARGS=(
--preset="$PRESET" "$SOURCE_DIR"
-G "$GENERATOR"
-DCMAKE_COLOR_DIAGNOSTICS=ON
-DCMAKE_CXX_COMPILER="$CPP_COMPILER"
-DPHLEX_USE_FORM="$ENABLE_FORM"
-DFORM_USE_ROOT_STORAGE="$FORM_ROOT_STORAGE"
)

# Add build type if specified
if [ -n "$BUILD_TYPE" ]; then
cmake --preset="$PRESET" "$SOURCE_DIR" \
-G "$GENERATOR" \
-DCMAKE_CXX_COMPILER="$CPP_COMPILER" \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DPHLEX_USE_FORM="$ENABLE_FORM" \
-DFORM_USE_ROOT_STORAGE="$FORM_ROOT_STORAGE" \
$EXTRA_OPTIONS
else
cmake --preset="$PRESET" "$SOURCE_DIR" \
-G "$GENERATOR" \
-DCMAKE_CXX_COMPILER="$CPP_COMPILER" \
-DPHLEX_USE_FORM="$ENABLE_FORM" \
-DFORM_USE_ROOT_STORAGE="$FORM_ROOT_STORAGE" \
$EXTRA_OPTIONS
CMAKE_ARGS+=(-DCMAKE_BUILD_TYPE="$BUILD_TYPE")
fi

# Add extra options
if [ -n "$EXTRA_OPTIONS" ]; then
CMAKE_ARGS+=($EXTRA_OPTIONS)
fi

# Run CMake
cmake "${CMAKE_ARGS[@]}"

echo "Source directory: $SOURCE_DIR"
echo "Build directory: $(pwd)"
echo "Generator: $GENERATOR"
Expand All @@ -79,3 +87,4 @@ runs:
CPP_COMPILER: ${{ inputs.cpp-compiler }}
PRESET: ${{ inputs.preset }}
BUILD_TYPE: ${{ inputs.build-type }}
CICOLOR_FORCE: 1
20 changes: 20 additions & 0 deletions .github/actions/detect-act-env/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Detect act environment
description: 'Detects if the workflow is running in the act environment'
outputs:
is_act:
description: "True if running in act, false otherwise"
value: ${{ steps.detect_act.outputs.is_act }}
runs:
using: "composite"
steps:
- name: Detect act environment
id: detect_act
shell: bash
env:
ACTOR: ${{ github.actor }}
run: |
if [ "$ACTOR" = "nektos/act" ] || [ "${ACT:-}" = "true" ] || [ "${ACT:-}" = "1" ]; then
echo "is_act=true" >> $GITHUB_OUTPUT
else
echo "is_act=false" >> $GITHUB_OUTPUT
fi
1 change: 1 addition & 0 deletions .github/actions/detect-relevant-changes/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ runs:
declare -A DEFAULT_TYPE_PATTERNS
DEFAULT_TYPE_PATTERNS[cpp]=$'*.cpp\n*.hpp'
DEFAULT_TYPE_PATTERNS[cmake]=$'CMakeLists.txt\n*.cmake'
DEFAULT_TYPE_PATTERNS[python]=$'*.py'

parse_list() {
local input="$1"
Expand Down
27 changes: 27 additions & 0 deletions .github/actions/get-pr-info/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Get PR Info'
description: 'Gets PR information for workflows triggered by an issue comment'
outputs:
ref:
description: 'The head ref of the PR'
value: ${{ steps.get_pr_info.outputs.ref }}
sha:
description: 'The head SHA of the PR'
value: ${{ steps.get_pr_info.outputs.sha }}
repo:
description: 'The full name of the head repository'
value: ${{ steps.get_pr_info.outputs.repo }}
runs:
using: "composite"
steps:
- id: get_pr_info
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
});
core.setOutput('ref', pr.data.head.ref);
core.setOutput('sha', pr.data.head.sha);
core.setOutput('repo', pr.data.head.repo.full_name);
54 changes: 42 additions & 12 deletions .github/workflows/clang-format-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,31 @@ permissions:

on:
pull_request:
branches: [ main ]
branches: [ main, develop ]
workflow_dispatch:

jobs:
detect-clang-format-changes:
pre-check:
runs-on: ubuntu-latest
outputs:
is_act: ${{ steps.detect_act.outputs.is_act }}
steps:
- name: Detect act environment
id: detect_act
uses: Framework-R-D/phlex/.github/actions/detect-act-env@main

detect-changes:
needs: pre-check
if: github.event_name != 'workflow_dispatch' && needs.pre-check.outputs.is_act != 'true'
runs-on: ubuntu-latest
permissions:
contents: read
packages: read

outputs:
has_changes: ${{ steps.filter.outputs.matched }}
changed_files: ${{ steps.filter.outputs.matched_files }}

steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
fetch-depth: 0
path: phlex-src
Expand All @@ -48,32 +56,54 @@ jobs:
fi

clang-format-check:
needs: detect-clang-format-changes
if: ${{ (needs.detect-clang-format-changes.outputs.has_changes == 'true') || (github.event_name == 'workflow_dispatch') || (env.ACT == 'true') }}
needs: [pre-check, detect-changes]
if: >
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: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
path: phlex-src

- name: Announce clang-format check
run: echo "➡️ Running clang-format check..."

- name: Run clang-format lint
id: lint
uses: DoozyX/clang-format-lint-action@bcb4eb2cb0d707ee4f3e5cc3b456eb075f12cf73 # v0.20
with:
source: "./phlex-src"
clangFormatVersion: 20
extensions: cpp,hpp,cpp.in,hpp.in
continue-on-error: true

- name: Evaluate clang-format result
if: always()
run: |
if [[ ${{ steps.lint.outcome }} == 'success' ]]; then
echo "✅ clang-format check passed."
else
echo "::error::clang-format check failed. Please review the output above for details."
exit 1
fi

clang-format-check-skipped:
needs: detect-clang-format-changes
if: ${{ (needs.detect-clang-format-changes.outputs.has_changes != 'true') && (github.event_name != 'workflow_dispatch') && (env.ACT != 'true') }}
needs: [pre-check, detect-changes]
if: >
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++ changes detected
run: echo "No clang-format relevant changes detected; check skipped."
run: echo "::notice::No clang-format relevant changes detected; check skipped."
49 changes: 24 additions & 25 deletions .github/workflows/clang-format-fix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,42 @@ permissions:
contents: write

jobs:
check:
parse-command:
runs-on: ubuntu-latest
name: Check for phlexbot token
name: Parse bot command
if: ${{ github.event.issue.pull_request }}

outputs:
match_result: ${{ steps.check_comment.outputs.match_result }}
ref_name: ${{ steps.check_comment.outputs.ref_name }}
repo_name: ${{ steps.check_comment.outputs.repo_name }}
should_run: ${{ steps.check_comment.outputs.should_run }}
ref: ${{ steps.get_pr.outputs.ref }}
sha: ${{ steps.get_pr.outputs.sha }}
repo: ${{ steps.get_pr.outputs.repo }}

steps:
- id: check_comment
name: Check comment
name: Check comment for trigger phrase
run: |
match_result=$(echo "$COMMENT_BODY" | grep -qEe '^@phlexbot[[:space:]]+format\b' && echo match || echo non_match)
echo match_result="$match_result" >> $GITHUB_OUTPUT

ISSUE_NUMBER=${{ github.event.issue.number }}
REPO="${{ github.repository }}"
gh api "repos/$REPO/pulls/$ISSUE_NUMBER" > pr.json
echo "ref_name=$(jq -r .head.ref pr.json)" >> $GITHUB_OUTPUT
echo "repo_name=$(jq -r .head.repo.full_name pr.json)" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}
COMMENT_BODY: ${{ github.event.comment.body }}
if [[ "${{ github.event.comment.author_association }}" == "COLLABORATOR" || "${{ github.event.comment.author_association }}" == "OWNER" ]] && \
[[ $(echo "${{ github.event.comment.body }}" | grep -qEe '^@phlexbot[[:space:]]+format\b' && echo 'true') ]]; then
echo "should_run=true" >> $GITHUB_OUTPUT
else
echo "should_run=false" >> $GITHUB_OUTPUT
fi
- name: Get PR Info
if: steps.check_comment.outputs.should_run == 'true'
id: get_pr
uses: ./actions/get-pr-info

apply_formatting:
runs-on: ubuntu-latest
name: Apply formatting
needs: check
if: ${{ needs.check.outputs.match_result == 'match' && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'OWNER') }}
needs: parse-command
if: ${{ needs.parse-command.outputs.should_run == 'true' }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
path: phlex-src
ref: ${{ needs.check.outputs.ref_name }}
repository: ${{ needs.check.outputs.repo_name }}
ref: ${{ needs.parse-command.outputs.ref }}
repository: ${{ needs.parse-command.outputs.repo }}
token: ${{ secrets.WORKFLOW_PAT }}

- uses: DoozyX/clang-format-lint-action@bcb4eb2cb0d707ee4f3e5cc3b456eb075f12cf73 # v0.20
Expand All @@ -68,14 +67,14 @@ jobs:

- name: Formatting changes committed and pushed
if: ${{ steps.add_and_commit.outputs.committed == 'true' && steps.add_and_commit.outputs.pushed == 'true'}}
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
with:
message: |
Code-formatting changes pushed (commit ${{ steps.add_and_commit.outputs.commit_sha }})

- name: No formatting changes to make
if: ${{ steps.add_and_commit.outputs.committed == 'false' }}
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
with:
message: |
No code-formatting changes to make
Loading
Loading