Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
18 changes: 5 additions & 13 deletions .github/workflows/clang-format-fix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,25 @@ jobs:
parse-command:
runs-on: ubuntu-latest
name: Parse bot command
if: ${{ github.event.issue.pull_request }}
if: >
github.event.issue.pull_request &&
(github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'OWNER') &&
startsWith(github.event.comment.body, '@phlexbot format')
outputs:
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 for trigger phrase
run: |
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
Comment thread
greenc-FNAL marked this conversation as resolved.
Outdated

apply_formatting:
runs-on: ubuntu-latest
name: Apply formatting
needs: parse-command
if: ${{ needs.parse-command.outputs.should_run == 'true' }}
if: ${{ needs.parse-command.result == 'success' }}
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
Expand Down
84 changes: 4 additions & 80 deletions .github/workflows/clang-tidy-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,13 @@ permissions:
on:
pull_request:
branches: [ main, develop ]
issue_comment:
types:
- created
workflow_dispatch:

jobs:
pre-check:
runs-on: ubuntu-latest
if: >
github.event_name == 'workflow_dispatch' ||
github.event_name == 'pull_request' ||
(github.event_name == 'issue_comment' && github.event.issue.pull_request)

outputs:
is_act: ${{ steps.detect_act.outputs.is_act }}
should_run: ${{ steps.check_comment.outputs.match_result == 'match' }}
tidy_checks: ${{ steps.check_comment.outputs.tidy_checks }}
ref_name: ${{ steps.check_comment.outputs.ref_name }}
repo_name: ${{ steps.check_comment.outputs.repo_name }}

steps:
- name: Detect act environment
id: detect_act
uses: Framework-R-D/phlex/.github/actions/detect-act-env@main

- id: check_comment
if: github.event_name == 'issue_comment'
name: Check comment
run: |
match_result=$(echo "$COMMENT_BODY" | grep -qE '^@phlexbot[[:space:]]+tidy-check\b' && echo match || echo non_match)

# Extract any tokens after 'tidy-check'
checks_line=$(echo "$COMMENT_BODY" | sed -nE 's/^@phlexbot[[:space:]]+tidy-check[[:space:]]+(.*)/\1/p' | tr -d '\r')
tidy_checks=""
if [ -n "$checks_line" ]; then
# Normalize separators: comma or whitespace -> single comma-separated list
tidy_checks=$(echo "$checks_line" | tr ',' ' ' | xargs -n1 | paste -sd, -)
fi

echo "match_result=$match_result" >> $GITHUB_OUTPUT
echo "tidy_checks=$tidy_checks" >> $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 }}

detect-changes:
needs: pre-check
if: >
github.event_name == 'pull_request' &&
needs.pre-check.outputs.is_act != 'true'
github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -101,32 +52,21 @@ jobs:
fi

clang-tidy-check:
needs: [pre-check, detect-changes]
needs: [detect-changes]
if: >
github.event_name == 'workflow_dispatch' ||
needs.pre-check.outputs.is_act == 'true' ||
(github.event_name == 'pull_request' && needs.detect-changes.result == 'success' && needs.detect-changes.outputs.has_changes == 'true') ||
(github.event_name == 'issue_comment' && needs.pre-check.outputs.should_run == 'true' && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'OWNER'))
(github.event_name == 'pull_request' && needs.detect-changes.result == 'success' && needs.detect-changes.outputs.has_changes == 'true')

runs-on: ubuntu-24.04

container:
image: ghcr.io/framework-r-d/phlex-ci:latest

steps:
- name: Checkout code (PR)
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
path: phlex-src

- name: Checkout code (comment)
if: github.event_name == 'issue_comment'
- name: Checkout code
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
path: phlex-src
ref: ${{ needs.pre-check.outputs.ref_name }}
repository: ${{ needs.pre-check.outputs.repo_name }}

- name: Setup build environment
uses: Framework-R-D/phlex/.github/actions/setup-build-env@main
Expand All @@ -138,8 +78,6 @@ jobs:
extra-options: "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_SCAN_FOR_MODULES=OFF"

- name: Run clang-tidy using CMake target
env:
PHLEX_TIDY_CHECKS: ${{ needs.pre-check.outputs.tidy_checks }}
shell: bash
run: |
. /entrypoint.sh
Expand Down Expand Up @@ -191,17 +129,3 @@ jobs:
clang_tidy_fixes: phlex-build/clang-tidy-fixes.yaml
github_token: ${{ secrets.GITHUB_TOKEN }}

clang-tidy-check-skipped:
needs: [tidy-pre-check, detect-clang-tidy-changes]
if: >
github.event_name == 'pull_request' &&
needs.tidy-pre-check.outputs.is_act != 'true' &&
needs.detect-clang-tidy-changes.result == 'success' &&
needs.detect-clang-tidy-changes.outputs.has_changes != 'true'
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: No relevant clang-tidy changes detected
run: echo "::notice::No clang-tidy relevant changes detected; check skipped."
29 changes: 12 additions & 17 deletions .github/workflows/clang-tidy-fix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,34 @@ jobs:
parse-command:
runs-on: ubuntu-latest
name: Parse bot command
if: ${{ github.event.issue.pull_request }}
if: >
github.event.issue.pull_request &&
(github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'OWNER') &&
startsWith(github.event.comment.body, '@phlexbot tidy-fix')
outputs:
should_run: ${{ steps.check_comment.outputs.should_run }}
tidy_checks: ${{ steps.check_comment.outputs.tidy_checks }}
tidy_checks: ${{ steps.parse_comment.outputs.tidy_checks }}
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 for trigger phrase
- id: parse_comment
name: Parse comment for tidy checks
run: |
if [[ "${{ github.event.comment.author_association }}" == "COLLABORATOR" || "${{ github.event.comment.author_association }}" == "OWNER" ]] && \
[[ $(echo "${{ github.event.comment.body }}" | grep -qEe '^@phlexbot[[:space:]]+tidy-fix\b' && echo 'true') ]]; then
echo "should_run=true" >> $GITHUB_OUTPUT
checks_line=$(echo "${{ github.event.comment.body }}" | sed -nE 's/^@phlexbot[[:space:]]+tidy-fix[[:space:]]+(.*)/\1/p' | tr -d '\r')
if [ -n "$checks_line" ]; then
tidy_checks=$(echo "$checks_line" | tr ',' ' ' | xargs -n1 | paste -sd, -)
echo "tidy_checks=$tidy_checks" >> $GITHUB_OUTPUT
fi
else
echo "should_run=false" >> $GITHUB_OUTPUT
checks_line=$(echo "${{ github.event.comment.body }}" | sed -nE 's/^@phlexbot[[:space:]]+tidy-fix[[:space:]]+(.*)/\1/p' | tr -d '\r')
if [ -n "$checks_line" ]; then
tidy_checks=$(echo "$checks_line" | tr ',' ' ' | xargs -n1 | paste -sd, -)
echo "tidy_checks=$tidy_checks" >> $GITHUB_OUTPUT
fi
- name: Get PR Info
if: steps.check_comment.outputs.should_run == 'true'
id: get_pr
uses: ./actions/get-pr-info
Comment thread
greenc-FNAL marked this conversation as resolved.
Outdated

apply_tidy_fixes:
runs-on: ubuntu-24.04
name: Apply clang-tidy fixes
needs: parse-command
if: ${{ needs.parse-command.outputs.should_run == 'true' }}
if: ${{ needs.parse-command.result == 'success' }}

container:
image: ghcr.io/framework-r-d/phlex-ci:latest
Expand Down
27 changes: 9 additions & 18 deletions .github/workflows/cmake-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,21 @@ jobs:
if: >
github.event_name == 'workflow_dispatch' ||
github.event_name == 'pull_request' ||
(github.event_name == 'issue_comment' && github.event.issue.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 }}
should_run: ${{ steps.check.outputs.triggered }}
pr_details: ${{ steps.pr.outputs.result }}

steps:
- name: Check trigger condition
id: check
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ] || [ "${{ github.event_name }}" = "pull_request" ]; then
echo "triggered=true" >> $GITHUB_OUTPUT
elif echo "$COMMENT_BODY" | grep -qE '^@phlexbot[[:space:]]+build\b'; then
echo "triggered=true" >> $GITHUB_OUTPUT
else
echo "triggered=false" >> $GITHUB_OUTPUT
fi
env:
COMMENT_BODY: ${{ github.event.comment.body }}

- name: Get PR details for comment trigger
if: github.event_name == 'issue_comment'
id: pr
Expand All @@ -70,7 +61,7 @@ jobs:
detect-changes:
needs: pre-check
if: >
needs.pre-check.outputs.should_run == 'true' &&
needs.pre-check.result == 'success' &&
github.event_name != 'workflow_dispatch' &&
needs.pre-check.outputs.is_act != 'true'
runs-on: ubuntu-latest
Expand Down Expand Up @@ -111,7 +102,7 @@ jobs:
build:
needs: [pre-check, detect-changes]
if: >
needs.pre-check.outputs.should_run == 'true' &&
needs.pre-check.result == 'success' &&
(
github.event_name == 'workflow_dispatch' ||
needs.pre-check.outputs.is_act == 'true' ||
Expand Down Expand Up @@ -154,7 +145,7 @@ jobs:
cmake-build-skipped:
needs: [pre-check, detect-changes]
if: >
needs.pre-check.outputs.should_run == 'true' &&
needs.pre-check.result == 'success' &&
github.event_name != 'workflow_dispatch' &&
needs.pre-check.outputs.is_act != 'true' &&
needs.detect-changes.result == 'success' &&
Expand Down
18 changes: 5 additions & 13 deletions .github/workflows/cmake-format-fix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,25 @@ jobs:
parse-command:
runs-on: ubuntu-latest
name: Parse bot command
if: ${{ github.event.issue.pull_request }}
if: >
github.event.issue.pull_request &&
(github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'OWNER') &&
startsWith(github.event.comment.body, '@phlexbot format')
outputs:
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 for trigger phrase
run: |
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
Comment thread
greenc-FNAL marked this conversation as resolved.
Outdated

apply_cmake_formatting:
runs-on: ubuntu-latest
name: Apply CMake formatting
needs: parse-command
if: ${{ needs.parse-command.outputs.should_run == 'true' }}
if: ${{ needs.parse-command.result == 'success' }}
steps:
- name: Checkout code
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
Expand Down
Loading