From da0713a8bd3ac6dd65cc7d4f27435c123e534c95 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 11 Mar 2026 20:30:04 +0000 Subject: [PATCH 01/10] Apply ruff fixes --- test/python/all_config.py | 10 +++++----- test/python/reducer.py | 8 ++------ test/python/sumit.py | 10 +++++----- test/python/test_coverage.py | 15 ++++++++------- test/python/test_mismatch.py | 8 +++++--- test/python/vectypes.py | 12 +++++++----- 6 files changed, 32 insertions(+), 31 deletions(-) diff --git a/test/python/all_config.py b/test/python/all_config.py index aeee3b37..0a4c1631 100644 --- a/test/python/all_config.py +++ b/test/python/all_config.py @@ -49,9 +49,9 @@ def __init__(self, config): assert len(config["some_objects"]) == 3 expected = [ - {'a': 'b', 'c': 'd', 'e': 'f'}, - {'g': 'h', 'i': 'j', 'k': 'l'}, - {'m': 'n', 'o': 'p', 'q': 'r'}, + {"a": "b", "c": "d", "e": "f"}, + {"g": "h", "i": "j", "k": "l"}, + {"m": "n", "o": "p", "q": "r"}, ] for i in range(3): assert config["some_objects"][i] == expected[i] @@ -60,10 +60,10 @@ def __init__(self, config): assert config["empty"] == () try: - config[42] # should raise + config[42] # should raise assert not "did not raise TypeError" except TypeError: - pass # all good as exception was raised + pass # all good as exception was raised def __call__(self, i: int, j: int) -> None: """Dummy routine to do something. diff --git a/test/python/reducer.py b/test/python/reducer.py index b32fe039..75b283e6 100644 --- a/test/python/reducer.py +++ b/test/python/reducer.py @@ -74,17 +74,13 @@ def PHLEX_REGISTER_ALGORITHMS(m, config): {"creator": "reduce0", "layer": "event", "suffix": "sum0"}, {"creator": "reduce1", "layer": "event", "suffix": "sum1"}, ] - m.transform( - add_sum01, name="reduce01", input_family=input_family01, output_products=["sum01"] - ) + m.transform(add_sum01, name="reduce01", input_family=input_family01, output_products=["sum01"]) input_family01 = [ {"creator": "reduce2", "layer": "event", "suffix": "sum2"}, {"creator": "reduce3", "layer": "event", "suffix": "sum3"}, ] - m.transform( - add_sum23, name="reduce23", input_family=input_family01, output_products=["sum23"] - ) + m.transform(add_sum23, name="reduce23", input_family=input_family01, output_products=["sum23"]) # once more (and the configuration will add a verifier) input_family_final = [ diff --git a/test/python/sumit.py b/test/python/sumit.py index 17eaef93..ae43e5ff 100644 --- a/test/python/sumit.py +++ b/test/python/sumit.py @@ -63,8 +63,8 @@ def PHLEX_REGISTER_ALGORITHMS(m, config): None """ m.transform(collectify, input_family=config["input"], output_products=["my_pyarray"]) - m.transform(sum_array, - input_family=[ - {"creator" : "collectify", "layer" : "event", "suffix" : "my_pyarray"} - ], - output_products=config["output"]) + m.transform( + sum_array, + input_family=[{"creator": "collectify", "layer": "event", "suffix": "my_pyarray"}], + output_products=config["output"], + ) diff --git a/test/python/test_coverage.py b/test/python/test_coverage.py index 33f82d33..52c844d8 100644 --- a/test/python/test_coverage.py +++ b/test/python/test_coverage.py @@ -42,13 +42,14 @@ def PHLEX_REGISTER_ALGORITHMS(m, config): """Register algorithms.""" # We need to transform scalar inputs to lists first # i, f1, d1 come from cppsource4py - tfs = ((collect_int, "input", "i", "l_int"), - (collect_float, "input", "f1", "l_float"), - (collect_double, "input", "d1", "l_double"), - (list_int_func, collect_int.__name__, "l_int", "sum_int"), - (list_float_func, collect_float.__name__, "l_float", "sum_float"), - (list_double_func, collect_double.__name__, "l_double", "sum_double") - ) + tfs = ( + (collect_int, "input", "i", "l_int"), + (collect_float, "input", "f1", "l_float"), + (collect_double, "input", "d1", "l_double"), + (list_int_func, collect_int.__name__, "l_int", "sum_int"), + (list_float_func, collect_float.__name__, "l_float", "sum_float"), + (list_double_func, collect_double.__name__, "l_double", "sum_double"), + ) for func, creator, suffix, output in tfs: input_family = [{"creator": creator, "layer": "event", "suffix": suffix}] diff --git a/test/python/test_mismatch.py b/test/python/test_mismatch.py index 2d188496..55eca0e7 100644 --- a/test/python/test_mismatch.py +++ b/test/python/test_mismatch.py @@ -10,6 +10,8 @@ def PHLEX_REGISTER_ALGORITHMS(m, config): """Register algorithms.""" # input_family has 1 element, but function takes 2 arguments # This should trigger the error in modulewrap.cpp - m.transform(mismatch_func, - input_family=[{"creator": "input", "layer": "event", "suffix": "a"}], - output_products=["sum"]) + m.transform( + mismatch_func, + input_family=[{"creator": "input", "layer": "event", "suffix": "a"}], + output_products=["sum"], + ) diff --git a/test/python/vectypes.py b/test/python/vectypes.py index de182aab..5cd46492 100644 --- a/test/python/vectypes.py +++ b/test/python/vectypes.py @@ -259,11 +259,13 @@ def PHLEX_REGISTER_ALGORITHMS(m, config): ) sum_kwargs = { - "input_family": [{ - "creator": list_collect.__name__ if use_lists else arr_collect.__name__, - "layer": "event", - "suffix": arr_name - }], + "input_family": [ + { + "creator": list_collect.__name__ if use_lists else arr_collect.__name__, + "layer": "event", + "suffix": arr_name, + } + ], "output_products": config[out_key], } if sum_name: From 95e53776e1c7898f00cc709dff34e36e41065912 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 11 Mar 2026 18:12:39 +0000 Subject: [PATCH 02/10] maintenance: Consolidate PR comment reaction handling This commit introduces a new reusable GitHub Action `.github/actions/complete-pr-comment` to handle removing the 'eyes' reaction and adding a completion reaction ('rocket' for success, 'confused' for failure) to triggering issue comments. Changes: - Created `.github/actions/complete-pr-comment/action.yaml` with robust error handling. - Updated `clang-tidy-fix.yaml` to include reaction handling (fixing the reported issue). - Refactored all other format fix workflows to use the new consolidated action. - Improved `format-all.yaml` to report the aggregate status of all formatting sub-jobs. Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> maintenance: Consolidate workflow reactions and setup logic This commit introduces a major refactoring of the CI workflows to reduce duplication, improve maintainability, and ensure consistent PR comment reactions. New Reusable Actions: - .github/actions/complete-pr-comment: Robustly handles PR comment reactions (removing 'eyes', adding 'rocket' on success or 'confused' on failure) with proper error handling. - .github/actions/prepare-fix-outputs: Consolidates the resolution of branch and repository information for workflows triggered by bot commands. - .github/actions/prepare-check-outputs: Consolidates environment detection and ref resolution for check-style workflows. Improvements: - Fixed missing completion reactions in clang-tidy-fix. - Refactored all 21 core workflow files to use the new actions, significantly reducing duplicated boilerplate. - Preserved all original authorization triggers and permissions. - Enhanced format-all.yaml to report an aggregate status. - Consistently used @main for internal action references as requested. Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> maintenance: Fix and consolidate PR comment reactions and workflow setup This commit addresses the missing 'rocket' emoji on completion of fix workflows and performs a major refactoring of the CI workflows to reduce duplication and improve maintainability. Key Changes: - Created `.github/actions/complete-pr-comment`: Robustly handles PR comment reactions (removing 'eyes', adding 'rocket' on success or 'confused' on failure) with proper error handling. - Created `.github/actions/prepare-fix-outputs`: Consolidates ref and repository resolution for bot-triggered workflows. - Created `.github/actions/prepare-check-outputs`: Consolidates environment detection and ref resolution for check workflows. - Refactored all 21 core workflow files to use these new actions. - Fixed specific issues in `clang-tidy-fix.yaml`, `codeql-analysis.yaml`, and `format-all.yaml` identified during review. - Removed temporary refactoring scripts. These changes ensure consistent behavior and significantly reduce YAML boilerplate. Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> Apply YAML formatter fixes --- .../actions/complete-pr-comment/action.yaml | 56 +++++++++++++++ .../actions/prepare-check-outputs/action.yaml | 72 +++++++++++++++++++ .../actions/prepare-fix-outputs/action.yaml | 53 ++++++++++++++ .github/workflows/actionlint-check.yaml | 23 +++--- .github/workflows/clang-format-check.yaml | 15 ++-- .github/workflows/clang-format-fix.yaml | 66 +++++------------ .github/workflows/clang-tidy-check.yaml | 23 +++--- .github/workflows/clang-tidy-fix.yaml | 30 +++++--- .github/workflows/cmake-build.yaml | 29 ++++---- .github/workflows/cmake-format-check.yaml | 23 +++--- .github/workflows/cmake-format-fix.yaml | 66 +++++------------ .github/workflows/codeql-analysis.yaml | 44 ++++++------ .github/workflows/coverage.yaml | 22 +++--- .github/workflows/format-all.yaml | 54 +++----------- .github/workflows/header-guards-check.yaml | 19 +++-- .github/workflows/header-guards-fix.yaml | 66 +++++------------ .github/workflows/jsonnet-format-check.yaml | 19 +++-- .github/workflows/jsonnet-format-fix.yaml | 66 +++++------------ .github/workflows/markdown-check.yaml | 19 +++-- .github/workflows/markdown-fix.yaml | 66 +++++------------ .github/workflows/python-check.yaml | 19 +++-- .github/workflows/python-fix.yaml | 65 +++++------------ .github/workflows/yaml-check.yaml | 15 ++-- .github/workflows/yaml-fix.yaml | 66 +++++------------ 24 files changed, 446 insertions(+), 550 deletions(-) create mode 100644 .github/actions/complete-pr-comment/action.yaml create mode 100644 .github/actions/prepare-check-outputs/action.yaml create mode 100644 .github/actions/prepare-fix-outputs/action.yaml diff --git a/.github/actions/complete-pr-comment/action.yaml b/.github/actions/complete-pr-comment/action.yaml new file mode 100644 index 00000000..ce857422 --- /dev/null +++ b/.github/actions/complete-pr-comment/action.yaml @@ -0,0 +1,56 @@ +name: "Complete PR Comment" +description: + "Removes the 'eyes' reaction and adds a completion reaction ('rocket' for success, 'confused' for failure) to the + triggering comment." +inputs: + status: + description: + "The status of the workflow. If 'success', a 'rocket' reaction is added. Otherwise, a 'confused' reaction is + added. Defaults to 'success'." + required: false + default: "success" + +runs: + using: "composite" + steps: + - name: Update PR Comment Reactions + if: github.event_name == 'issue_comment' + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + with: + script: | + const status = '${{ inputs.status }}'; + const completionReaction = (status === 'success') ? 'rocket' : 'confused'; + + // 1. Remove "eyes" reaction + try { + const { data: reactions } = await github.rest.reactions.listForIssueComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: context.payload.comment.id + }); + const eyesReaction = reactions.find( + (r) => r.content === 'eyes' && r.user && r.user.login === 'github-actions[bot]' + ); + if (eyesReaction) { + await github.rest.reactions.deleteForIssueComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: context.payload.comment.id, + reaction_id: eyesReaction.id + }); + } + } catch (e) { + core.warning(`Failed to remove "eyes" reaction: ${e.message}`); + } + + // 2. Add completion reaction + try { + await github.rest.reactions.createForIssueComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: context.payload.comment.id, + content: completionReaction + }); + } catch (e) { + core.warning(`Failed to add "${completionReaction}" reaction: ${e.message}`); + } diff --git a/.github/actions/prepare-check-outputs/action.yaml b/.github/actions/prepare-check-outputs/action.yaml new file mode 100644 index 00000000..dbed7690 --- /dev/null +++ b/.github/actions/prepare-check-outputs/action.yaml @@ -0,0 +1,72 @@ +name: "Prepare Check Outputs" +description: "Determines environment and target refs for check workflows." +inputs: + ref: + description: "Manual ref override" + required: false + repo: + description: "Manual repo override" + required: false + pr-base-sha: + description: "Manual base SHA override" + required: false +outputs: + is_act: + description: "Whether running in act" + value: ${{ steps.detect_act.outputs.is_act }} + ref: + description: "The resolved ref" + value: ${{ steps.resolve.outputs.ref }} + repo: + description: "The resolved repository" + value: ${{ steps.resolve.outputs.repo }} + base_sha: + description: "The resolved base SHA for diffing" + value: ${{ steps.resolve.outputs.base_sha }} + pr_number: + description: "The PR number if available" + value: ${{ steps.resolve.outputs.pr_number }} +runs: + using: "composite" + steps: + - name: Get PR Info + if: github.event_name == 'issue_comment' + id: get_pr + uses: Framework-R-D/phlex/.github/actions/get-pr-info@main + + - name: Detect act environment + id: detect_act + uses: Framework-R-D/phlex/.github/actions/detect-act-env@main + + - name: Resolve outputs + id: resolve + shell: bash + run: | + REF="${{ inputs.ref }}" + REPO="${{ inputs.repo }}" + BASE_SHA="${{ inputs.pr-base-sha }}" + PR_NUMBER="" + + if [ "${{ github.event_name }}" == "pull_request" ]; then + REF="${REF:-${{ github.sha }}}" + BASE_SHA="${BASE_SHA:-${{ github.event.pull_request.base.sha }}}" + PR_NUMBER="${{ github.event.pull_request.number }}" + elif [ "${{ github.event_name }}" == "issue_comment" ]; then + REF="${REF:-${{ steps.get_pr.outputs.ref }}}" + REPO="${REPO:-${{ steps.get_pr.outputs.repo }}}" + BASE_SHA="${BASE_SHA:-${{ steps.get_pr.outputs.base_sha }}}" + PR_NUMBER="${{ github.event.issue.number }}" + elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + REF="${REF:-${{ github.event.inputs.ref || github.ref }}}" + BASE_SHA="${BASE_SHA:-${{ github.event.before }}}" + else + REF="${REF:-${{ github.sha }}}" + BASE_SHA="${BASE_SHA:-${{ github.event.before }}}" + fi + + REPO="${REPO:-${{ github.repository }}}" + + echo "ref=$REF" >> "$GITHUB_OUTPUT" + echo "repo=$REPO" >> "$GITHUB_OUTPUT" + echo "base_sha=$BASE_SHA" >> "$GITHUB_OUTPUT" + echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT" diff --git a/.github/actions/prepare-fix-outputs/action.yaml b/.github/actions/prepare-fix-outputs/action.yaml new file mode 100644 index 00000000..6967977f --- /dev/null +++ b/.github/actions/prepare-fix-outputs/action.yaml @@ -0,0 +1,53 @@ +name: "Prepare Fix Outputs" +description: "Determines the target ref and repository for fix workflows triggered by various events." +inputs: + ref: + description: "Manual ref override" + required: false + repo: + description: "Manual repo override" + required: false +outputs: + ref: + description: "The resolved ref" + value: ${{ steps.resolve.outputs.ref }} + repo: + description: "The resolved repository" + value: ${{ steps.resolve.outputs.repo }} +runs: + using: "composite" + steps: + - name: Get PR Info + if: github.event_name == 'issue_comment' && (inputs.ref == '' || inputs.repo == '') + id: get_pr + uses: Framework-R-D/phlex/.github/actions/get-pr-info@main + + - name: Resolve outputs + id: resolve + shell: bash + run: | + REF="${{ inputs.ref }}" + REPO="${{ inputs.repo }}" + + if [ -z "$REF" ]; then + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + REF="${{ github.event.inputs.ref || github.ref_name }}" + elif [ "${{ github.event_name }}" == "issue_comment" ]; then + REF="${{ steps.get_pr.outputs.ref }}" + else + REF="${{ github.ref_name }}" + fi + fi + + if [ -z "$REPO" ]; then + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + REPO="${{ github.repository }}" + elif [ "${{ github.event_name }}" == "issue_comment" ]; then + REPO="${{ steps.get_pr.outputs.repo }}" + else + REPO="${{ github.repository }}" + fi + fi + + echo "ref=$REF" >> "$GITHUB_OUTPUT" + echo "repo=$REPO" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/actionlint-check.yaml b/.github/workflows/actionlint-check.yaml index 4bb2c38c..0ad0eae6 100644 --- a/.github/workflows/actionlint-check.yaml +++ b/.github/workflows/actionlint-check.yaml @@ -50,18 +50,19 @@ jobs: pre-check: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.detect_act.outputs.is_act }} - ref: - ${{ (github.event_name == 'workflow_call' && inputs.ref) || (github.event_name == 'workflow_dispatch' && - (github.event.inputs.ref || github.ref)) || github.sha }} - repo: ${{ (github.event_name == 'workflow_call' && inputs.repo) || github.repository }} - base_sha: - ${{ (github.event_name == 'workflow_call' && inputs.pr-base-sha) || github.event.pull_request.base.sha || - github.event.before }} + is_act: ${{ steps.prepare.outputs.is_act }} + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} + base_sha: ${{ steps.prepare.outputs.base_sha }} + pr_number: ${{ steps.prepare.outputs.pr_number }} steps: - - name: Detect act environment - id: detect_act - uses: Framework-R-D/phlex/.github/actions/detect-act-env@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main + with: + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} + pr-base-sha: ${{ inputs.pr-base-sha }} detect-changes: needs: pre-check diff --git a/.github/workflows/clang-format-check.yaml b/.github/workflows/clang-format-check.yaml index 97d809ee..32c3057d 100644 --- a/.github/workflows/clang-format-check.yaml +++ b/.github/workflows/clang-format-check.yaml @@ -18,14 +18,15 @@ jobs: pre-check: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.detect_act.outputs.is_act }} - ref: ${{ (github.event_name == 'workflow_dispatch' && (github.event.inputs.ref || github.ref)) || github.sha }} - repo: ${{ github.repository }} - base_sha: ${{ github.event.pull_request.base.sha || github.event.before }} + is_act: ${{ steps.prepare.outputs.is_act }} + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} + base_sha: ${{ steps.prepare.outputs.base_sha }} + pr_number: ${{ steps.prepare.outputs.pr_number }} steps: - - name: Detect act environment - id: detect_act - uses: Framework-R-D/phlex/.github/actions/detect-act-env@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main detect-changes: needs: pre-check diff --git a/.github/workflows/clang-format-fix.yaml b/.github/workflows/clang-format-fix.yaml index e19d86be..2b3fa1cc 100644 --- a/.github/workflows/clang-format-fix.yaml +++ b/.github/workflows/clang-format-fix.yaml @@ -8,7 +8,9 @@ run-name: "${{ github.actor }} fixing C++ code format" workflow_dispatch: inputs: ref: - description: "The branch name to checkout and push fixes to (must be a branch, not a commit SHA). Defaults to the repository's default branch." + description: + "The branch name to checkout and push fixes to (must be a branch, not a commit SHA). Defaults to the + repository's default branch." required: false type: string workflow_call: @@ -52,8 +54,7 @@ permissions: contents: write env: - local_checkout_path: - ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} + local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} jobs: pre-check: @@ -69,18 +70,15 @@ jobs: # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. # This covers repo owners, invited collaborators, and all org members. outputs: - ref: - ${{ inputs.ref || (github.event_name == 'workflow_dispatch' && - (github.event.inputs.ref || github.ref_name)) || steps.get_pr.outputs.ref }} - repo: - ${{ inputs.repo || (github.event_name == 'workflow_dispatch' && - github.repository) || steps.get_pr.outputs.repo }} - + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} steps: - - name: Get PR Info - if: github.event_name == 'issue_comment' && inputs.ref == '' - id: get_pr - uses: Framework-R-D/phlex/.github/actions/get-pr-info@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + with: + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} apply_formatting: runs-on: ubuntu-latest @@ -119,40 +117,8 @@ jobs: pr-info-repo: ${{ needs.pre-check.outputs.repo }} skip-comment: ${{ inputs.skip-comment || 'false' }} - - name: Remove eyes reaction - if: github.event_name == 'issue_comment' && inputs.skip-comment != 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - with: - script: | - try { - const { data: reactions } = await github.rest.reactions.listForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id - }); - const eyesReaction = reactions.find( - (r) => r.content === 'eyes' && r.user && r.user.login === 'github-actions[bot]' - ); - if (eyesReaction) { - await github.rest.reactions.deleteForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - reaction_id: eyesReaction.id - }); - } - } catch (_) { - // Reaction cleanup is best-effort; do not fail the workflow. - } - - - name: Add completion reaction - if: github.event_name == 'issue_comment' && inputs.skip-comment != 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + - name: Update PR comment reactions + if: always() && github.event_name == 'issue_comment' && inputs.skip-comment != 'true' + uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main with: - script: | - await github.rest.reactions.createForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - content: 'rocket' - }); + status: ${{ job.status }} diff --git a/.github/workflows/clang-tidy-check.yaml b/.github/workflows/clang-tidy-check.yaml index 0e9df1f4..e1a8ce52 100644 --- a/.github/workflows/clang-tidy-check.yaml +++ b/.github/workflows/clang-tidy-check.yaml @@ -27,22 +27,15 @@ jobs: ) runs-on: ubuntu-latest outputs: - is_act: ${{ steps.detect_act.outputs.is_act }} - ref: - ${{ (github.event_name == 'workflow_dispatch' && (github.event.inputs.ref || github.ref)) || - steps.pr.outputs.ref || github.sha }} - repo: ${{ steps.pr.outputs.repo || github.repository }} - base_sha: ${{ steps.pr.outputs.base_sha || github.event.pull_request.base.sha || github.event.before }} - pr_number: ${{ github.event.pull_request.number || github.event.issue.number }} + is_act: ${{ steps.prepare.outputs.is_act }} + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} + base_sha: ${{ steps.prepare.outputs.base_sha }} + pr_number: ${{ steps.prepare.outputs.pr_number }} steps: - - name: Get PR Info - if: github.event_name == 'issue_comment' - id: pr - uses: Framework-R-D/phlex/.github/actions/get-pr-info@main - - - name: Detect act environment - id: detect_act - uses: Framework-R-D/phlex/.github/actions/detect-act-env@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main detect-changes: needs: pre-check diff --git a/.github/workflows/clang-tidy-fix.yaml b/.github/workflows/clang-tidy-fix.yaml index 092ddd0d..56aa7c20 100644 --- a/.github/workflows/clang-tidy-fix.yaml +++ b/.github/workflows/clang-tidy-fix.yaml @@ -8,7 +8,9 @@ name: Clang-Tidy Fix workflow_dispatch: inputs: ref: - description: "The branch name to checkout and push fixes to (must be a branch, not a commit SHA). Defaults to the repository's default branch." + description: + "The branch name to checkout and push fixes to (must be a branch, not a commit SHA). Defaults to the + repository's default branch." required: false type: string tidy-checks: @@ -34,14 +36,11 @@ jobs: # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. # This covers repo owners, invited collaborators, and all org members. outputs: - ref: - ${{ (github.event_name == 'workflow_dispatch' && (github.event.inputs.ref || github.ref_name)) || - steps.get_pr.outputs.ref }} - repo: ${{ steps.get_pr.outputs.repo || github.repository }} + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} tidy_checks: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tidy-checks || steps.parse_comment.outputs.tidy_checks }} - steps: - id: parse_comment name: Parse comment for tidy checks @@ -56,10 +55,9 @@ jobs: tidy_checks="$(echo "$checks_line" | tr ',' ' ' | xargs -n1 | paste -sd, -)" echo "tidy_checks=$tidy_checks" >> "$GITHUB_OUTPUT" fi - - name: Get PR Info - if: github.event_name == 'issue_comment' - id: get_pr - uses: Framework-R-D/phlex/.github/actions/get-pr-info@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main apply_tidy_fixes: runs-on: ubuntu-24.04 @@ -208,3 +206,15 @@ jobs: with: clang_tidy_fixes: phlex-build/clang-tidy-fixes.yaml github_token: ${{ secrets.GITHUB_TOKEN }} + + complete-comment: + needs: [pre-check, apply_tidy_fixes, clang-tidy-pr-comments] + if: always() && needs.pre-check.result == 'success' + runs-on: ubuntu-latest + steps: + - name: Update PR comment reactions + uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main + with: + status: + ${{ (needs.apply_tidy_fixes.result == 'success' && needs.clang-tidy-pr-comments.result == 'success') && + 'success' || 'failure' }} diff --git a/.github/workflows/cmake-build.yaml b/.github/workflows/cmake-build.yaml index 34d7e6bb..c42dfbbb 100644 --- a/.github/workflows/cmake-build.yaml +++ b/.github/workflows/cmake-build.yaml @@ -92,24 +92,19 @@ jobs: packages: read outputs: - is_act: ${{ steps.detect_act.outputs.is_act }} - ref: - ${{ (github.event_name == 'workflow_call' && inputs.ref) || (github.event_name == 'workflow_dispatch' && - (github.event.inputs.ref || github.ref)) || steps.pr.outputs.ref || steps.pr.outputs.sha || github.sha }} - repo: ${{ (github.event_name == 'workflow_call' && inputs.repo) || steps.pr.outputs.repo || github.repository }} - base_sha: - ${{ (github.event_name == 'workflow_call' && inputs.pr-base-sha) || steps.pr.outputs.base_sha || - github.event.pull_request.base.sha || github.event.before }} - + is_act: ${{ steps.prepare.outputs.is_act }} + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} + base_sha: ${{ steps.prepare.outputs.base_sha }} + pr_number: ${{ steps.prepare.outputs.pr_number }} steps: - - name: Get PR Info - if: github.event_name == 'issue_comment' - id: pr - uses: Framework-R-D/phlex/.github/actions/get-pr-info@main - - - name: Detect act environment - id: detect_act - uses: Framework-R-D/phlex/.github/actions/detect-act-env@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main + with: + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} + pr-base-sha: ${{ inputs.pr-base-sha }} detect-changes: needs: pre-check diff --git a/.github/workflows/cmake-format-check.yaml b/.github/workflows/cmake-format-check.yaml index 377cf295..fa692c0e 100644 --- a/.github/workflows/cmake-format-check.yaml +++ b/.github/workflows/cmake-format-check.yaml @@ -50,18 +50,19 @@ jobs: pre-check: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.detect_act.outputs.is_act }} - ref: - ${{ (github.event_name == 'workflow_call' && inputs.ref) || (github.event_name == 'workflow_dispatch' && - (github.event.inputs.ref || github.ref)) || github.sha }} - repo: ${{ (github.event_name == 'workflow_call' && inputs.repo) || github.repository }} - base_sha: - ${{ (github.event_name == 'workflow_call' && inputs.pr-base-sha) || github.event.pull_request.base.sha || - github.event.before }} + is_act: ${{ steps.prepare.outputs.is_act }} + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} + base_sha: ${{ steps.prepare.outputs.base_sha }} + pr_number: ${{ steps.prepare.outputs.pr_number }} steps: - - name: Detect act environment - id: detect_act - uses: Framework-R-D/phlex/.github/actions/detect-act-env@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main + with: + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} + pr-base-sha: ${{ inputs.pr-base-sha }} detect-changes: needs: pre-check diff --git a/.github/workflows/cmake-format-fix.yaml b/.github/workflows/cmake-format-fix.yaml index 2bb6f639..402bd84d 100644 --- a/.github/workflows/cmake-format-fix.yaml +++ b/.github/workflows/cmake-format-fix.yaml @@ -8,7 +8,9 @@ run-name: "${{ github.actor }} fixing CMake format" workflow_dispatch: inputs: ref: - description: "The branch name to checkout and push fixes to (must be a branch, not a commit SHA). Defaults to the repository's default branch." + description: + "The branch name to checkout and push fixes to (must be a branch, not a commit SHA). Defaults to the + repository's default branch." required: false type: string workflow_call: @@ -52,8 +54,7 @@ permissions: contents: write env: - local_checkout_path: - ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} + local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} jobs: pre-check: @@ -69,18 +70,15 @@ jobs: # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. # This covers repo owners, invited collaborators, and all org members. outputs: - ref: - ${{ inputs.ref || (github.event_name == 'workflow_dispatch' && - (github.event.inputs.ref || github.ref_name)) || steps.get_pr.outputs.ref }} - repo: - ${{ inputs.repo || (github.event_name == 'workflow_dispatch' && - github.repository) || steps.get_pr.outputs.repo }} - + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} steps: - - name: Get PR Info - if: github.event_name == 'issue_comment' && inputs.ref == '' - id: get_pr - uses: Framework-R-D/phlex/.github/actions/get-pr-info@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + with: + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} apply_cmake_formatting: runs-on: ubuntu-latest @@ -126,40 +124,8 @@ jobs: pr-info-repo: ${{ needs.pre-check.outputs.repo }} skip-comment: ${{ inputs.skip-comment || 'false' }} - - name: Remove eyes reaction - if: github.event_name == 'issue_comment' && inputs.skip-comment != 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - with: - script: | - try { - const { data: reactions } = await github.rest.reactions.listForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id - }); - const eyesReaction = reactions.find( - (r) => r.content === 'eyes' && r.user && r.user.login === 'github-actions[bot]' - ); - if (eyesReaction) { - await github.rest.reactions.deleteForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - reaction_id: eyesReaction.id - }); - } - } catch (_) { - // Reaction cleanup is best-effort; do not fail the workflow. - } - - - name: Add completion reaction - if: github.event_name == 'issue_comment' && inputs.skip-comment != 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + - name: Update PR comment reactions + if: always() && github.event_name == 'issue_comment' && inputs.skip-comment != 'true' + uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main with: - script: | - await github.rest.reactions.createForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - content: 'rocket' - }); + status: ${{ job.status }} diff --git a/.github/workflows/codeql-analysis.yaml b/.github/workflows/codeql-analysis.yaml index a87081bd..6160dbc8 100644 --- a/.github/workflows/codeql-analysis.yaml +++ b/.github/workflows/codeql-analysis.yaml @@ -69,22 +69,28 @@ jobs: pre-check: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.detect_act.outputs.is_act }} - ref: - ${{ (github.event_name == 'workflow_call' && inputs.ref) || (github.event_name == 'workflow_dispatch' && - (github.event.inputs.ref || github.ref)) || github.sha }} - repo: ${{ (github.event_name == 'workflow_call' && inputs.repo) || github.repository }} - base_sha: - ${{ (github.event_name == 'workflow_call' && inputs.pr-base-sha) || github.event.pull_request.base.sha || - github.event.before }} + is_act: ${{ steps.prepare.outputs.is_act }} + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} + base_sha: ${{ steps.prepare.outputs.base_sha }} + pr_number: ${{ steps.prepare.outputs.pr_number }} skip_detection: ${{ steps.should_skip.outputs.skip }} - local_checkout_path: - ${{ (github.event_name == 'workflow_call' && inputs.checkout-path) || format('{0}-src', - github.event.repository.name) }} + local_checkout_path: ${{ steps.path.outputs.path }} steps: - - name: Detect act environment - id: detect_act - uses: Framework-R-D/phlex/.github/actions/detect-act-env@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main + with: + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} + pr-base-sha: ${{ inputs.pr-base-sha }} + + - name: Resolve checkout path + id: path + shell: bash + run: | + CHECKOUT_PATH="${{ (github.event_name == 'workflow_call' && inputs.checkout-path) || format('{0}-src', github.event.repository.name) }}" + echo "path=$CHECKOUT_PATH" >> "$GITHUB_OUTPUT" - name: Determine if detection should be skipped id: should_skip @@ -94,7 +100,7 @@ jobs: [ "${{ github.event_name }}" = "workflow_dispatch" ] || \ [ "${{ github.event_name }}" = "push" ] || \ { [ "${{ github.event_name }}" = "workflow_call" ] && [ -n "${{ inputs.language-matrix }}" ]; } || \ - [ "${{ steps.detect_act.outputs.is_act }}" = "true" ]; then + [ "${{ steps.prepare.outputs.is_act }}" = "true" ]; then echo "skip=true" >> "$GITHUB_OUTPUT" else echo "skip=false" >> "$GITHUB_OUTPUT" @@ -218,13 +224,7 @@ jobs: fi determine-languages: - needs: - [ - pre-check, - detect-changes-cpp, - detect-changes-python, - detect-changes-actions, - ] + needs: [pre-check, detect-changes-cpp, detect-changes-python, detect-changes-actions] if: always() && needs.pre-check.result == 'success' runs-on: ubuntu-latest outputs: diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index 8c8169ed..ccbb4ba1 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -41,21 +41,15 @@ jobs: # This covers repo owners, invited collaborators, and all org members. runs-on: ubuntu-latest outputs: - is_act: ${{ steps.detect_act.outputs.is_act }} - ref: - ${{ (github.event_name == 'workflow_dispatch' && (github.event.inputs.ref || github.ref)) || - steps.pr.outputs.ref || github.sha }} - repo: ${{ steps.pr.outputs.repo || github.repository }} - base_sha: ${{ steps.pr.outputs.base_sha || github.event.pull_request.base.sha || github.event.before }} + is_act: ${{ steps.prepare.outputs.is_act }} + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} + base_sha: ${{ steps.prepare.outputs.base_sha }} + pr_number: ${{ steps.prepare.outputs.pr_number }} steps: - - name: Get PR Info - if: github.event_name == 'issue_comment' - id: pr - uses: Framework-R-D/phlex/.github/actions/get-pr-info@main - - - name: Detect act environment - id: detect_act - uses: Framework-R-D/phlex/.github/actions/detect-act-env@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main detect-changes: needs: pre-check if: > diff --git a/.github/workflows/format-all.yaml b/.github/workflows/format-all.yaml index 53d99978..6f2702bd 100644 --- a/.github/workflows/format-all.yaml +++ b/.github/workflows/format-all.yaml @@ -19,12 +19,12 @@ jobs: "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association) && startsWith(github.event.comment.body, format('@{0}bot format', github.event.repository.name)) outputs: - ref: ${{ steps.get_pr.outputs.ref }} - repo: ${{ steps.get_pr.outputs.repo }} + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} steps: - - name: Get PR Info - id: get_pr - uses: Framework-R-D/phlex/.github/actions/get-pr-info@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main clang-format: needs: pre-check @@ -101,44 +101,6 @@ jobs: if: ${{ always() && needs.pre-check.result == 'success' }} runs-on: ubuntu-latest steps: - - name: Remove eyes reaction - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - with: - script: | - try { - const { data: reactions } = await github.rest.reactions.listForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id - }); - - const eyesReaction = reactions.find( - (r) => r.content === 'eyes' && r.user && r.user.login === 'github-actions[bot]' - ); - - if (eyesReaction && eyesReaction.id) { - await github.rest.reactions.deleteForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - reaction_id: eyesReaction.id - }); - } - } catch (_) { - // Reaction cleanup is best-effort; do not fail the workflow. - } - - - name: Add completion reaction - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - with: - script: | - await github.rest.reactions.createForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - content: 'rocket' - }); - - name: Collect results id: collect shell: bash @@ -231,3 +193,9 @@ jobs: uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1 with: message: ${{ steps.collect.outputs.message }} + + - name: Update PR comment reactions + if: always() + uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main + with: + status: ${{ job.status }} diff --git a/.github/workflows/header-guards-check.yaml b/.github/workflows/header-guards-check.yaml index 8c5ffe60..6a07ace1 100644 --- a/.github/workflows/header-guards-check.yaml +++ b/.github/workflows/header-guards-check.yaml @@ -50,18 +50,15 @@ jobs: pre-check: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.detect_act.outputs.is_act }} - ref: - ${{ (github.event_name == 'workflow_call' && inputs.ref) || (github.event_name == 'workflow_dispatch' && - (github.event.inputs.ref || github.ref)) || github.sha }} - repo: ${{ (github.event_name == 'workflow_call' && inputs.repo) || github.repository }} - base_sha: - ${{ (github.event_name == 'workflow_call' && inputs.pr-base-sha) || github.event.pull_request.base.sha || - github.event.before }} + is_act: ${{ steps.prepare.outputs.is_act }} + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} + base_sha: ${{ steps.prepare.outputs.base_sha }} + pr_number: ${{ steps.prepare.outputs.pr_number }} steps: - - name: Detect act environment - id: detect_act - uses: Framework-R-D/phlex/.github/actions/detect-act-env@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main detect-changes: needs: pre-check diff --git a/.github/workflows/header-guards-fix.yaml b/.github/workflows/header-guards-fix.yaml index 2c0f7fb6..ae09c2ce 100644 --- a/.github/workflows/header-guards-fix.yaml +++ b/.github/workflows/header-guards-fix.yaml @@ -43,7 +43,9 @@ run-name: "${{ github.actor }} fixing header guards" workflow_dispatch: inputs: ref: - description: "The branch name to checkout and push fixes to (must be a branch, not a commit SHA). Defaults to the repository's default branch." + description: + "The branch name to checkout and push fixes to (must be a branch, not a commit SHA). Defaults to the + repository's default branch." required: false type: string @@ -52,8 +54,7 @@ permissions: contents: write env: - local_checkout_path: - ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} + local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} jobs: pre-check: @@ -69,18 +70,15 @@ jobs: # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. # This covers repo owners, invited collaborators, and all org members. outputs: - ref: - ${{ inputs.ref || (github.event_name == 'workflow_dispatch' && - (github.event.inputs.ref || github.ref_name)) || steps.get_pr.outputs.ref }} - repo: - ${{ inputs.repo || (github.event_name == 'workflow_dispatch' && - github.repository) || steps.get_pr.outputs.repo }} - + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} steps: - - name: Get PR Info - if: github.event_name == 'issue_comment' && inputs.ref == '' - id: get_pr - uses: Framework-R-D/phlex/.github/actions/get-pr-info@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + with: + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} apply_fixes: runs-on: ubuntu-latest @@ -124,40 +122,8 @@ jobs: pr-info-repo: ${{ needs.pre-check.outputs.repo }} skip-comment: ${{ inputs.skip-comment || 'false' }} - - name: Remove eyes reaction - if: github.event_name == 'issue_comment' && inputs.skip-comment != 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - with: - script: | - try { - const { data: reactions } = await github.rest.reactions.listForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id - }); - const eyesReaction = reactions.find( - (r) => r.content === 'eyes' && r.user && r.user.login === 'github-actions[bot]' - ); - if (eyesReaction) { - await github.rest.reactions.deleteForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - reaction_id: eyesReaction.id - }); - } - } catch (_) { - // Reaction cleanup is best-effort; do not fail the workflow. - } - - - name: Add completion reaction - if: github.event_name == 'issue_comment' && inputs.skip-comment != 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + - name: Update PR comment reactions + if: always() && github.event_name == 'issue_comment' && inputs.skip-comment != 'true' + uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main with: - script: | - await github.rest.reactions.createForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - content: 'rocket' - }); + status: ${{ job.status }} diff --git a/.github/workflows/jsonnet-format-check.yaml b/.github/workflows/jsonnet-format-check.yaml index 91f7c95d..a76b9900 100644 --- a/.github/workflows/jsonnet-format-check.yaml +++ b/.github/workflows/jsonnet-format-check.yaml @@ -50,18 +50,15 @@ jobs: pre-check: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.detect_act.outputs.is_act }} - ref: - ${{ (github.event_name == 'workflow_call' && inputs.ref) || (github.event_name == 'workflow_dispatch' && - (github.event.inputs.ref || github.ref)) || github.sha }} - repo: ${{ (github.event_name == 'workflow_call' && inputs.repo) || github.repository }} - base_sha: - ${{ (github.event_name == 'workflow_call' && inputs.pr-base-sha) || github.event.pull_request.base.sha || - github.event.before }} + is_act: ${{ steps.prepare.outputs.is_act }} + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} + base_sha: ${{ steps.prepare.outputs.base_sha }} + pr_number: ${{ steps.prepare.outputs.pr_number }} steps: - - name: Detect act environment - id: detect_act - uses: Framework-R-D/phlex/.github/actions/detect-act-env@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main detect-changes: needs: pre-check diff --git a/.github/workflows/jsonnet-format-fix.yaml b/.github/workflows/jsonnet-format-fix.yaml index 5a02e4aa..8360f114 100644 --- a/.github/workflows/jsonnet-format-fix.yaml +++ b/.github/workflows/jsonnet-format-fix.yaml @@ -8,7 +8,9 @@ run-name: "${{ github.actor }} fixing Jsonnet format" workflow_dispatch: inputs: ref: - description: "The branch name to checkout and push fixes to (must be a branch, not a commit SHA). Defaults to the repository's default branch." + description: + "The branch name to checkout and push fixes to (must be a branch, not a commit SHA). Defaults to the + repository's default branch." required: false type: string workflow_call: @@ -52,8 +54,7 @@ permissions: contents: write env: - local_checkout_path: - ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} + local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} jobs: pre-check: @@ -69,18 +70,15 @@ jobs: # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. # This covers repo owners, invited collaborators, and all org members. outputs: - ref: - ${{ inputs.ref || (github.event_name == 'workflow_dispatch' && - (github.event.inputs.ref || github.ref_name)) || steps.get_pr.outputs.ref }} - repo: - ${{ inputs.repo || (github.event_name == 'workflow_dispatch' && - github.repository) || steps.get_pr.outputs.repo }} - + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} steps: - - name: Get PR Info - if: github.event_name == 'issue_comment' && inputs.ref == '' - id: get_pr - uses: Framework-R-D/phlex/.github/actions/get-pr-info@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + with: + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} apply_jsonnet_formatting: runs-on: ubuntu-latest @@ -125,40 +123,8 @@ jobs: pr-info-repo: ${{ needs.pre-check.outputs.repo }} skip-comment: ${{ inputs.skip-comment || 'false' }} - - name: Remove eyes reaction - if: github.event_name == 'issue_comment' && inputs.skip-comment != 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - with: - script: | - try { - const { data: reactions } = await github.rest.reactions.listForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id - }); - const eyesReaction = reactions.find( - (r) => r.content === 'eyes' && r.user && r.user.login === 'github-actions[bot]' - ); - if (eyesReaction) { - await github.rest.reactions.deleteForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - reaction_id: eyesReaction.id - }); - } - } catch (_) { - // Reaction cleanup is best-effort; do not fail the workflow. - } - - - name: Add completion reaction - if: github.event_name == 'issue_comment' && inputs.skip-comment != 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + - name: Update PR comment reactions + if: always() && github.event_name == 'issue_comment' && inputs.skip-comment != 'true' + uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main with: - script: | - await github.rest.reactions.createForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - content: 'rocket' - }); + status: ${{ job.status }} diff --git a/.github/workflows/markdown-check.yaml b/.github/workflows/markdown-check.yaml index e2b04050..35802c08 100644 --- a/.github/workflows/markdown-check.yaml +++ b/.github/workflows/markdown-check.yaml @@ -50,18 +50,15 @@ jobs: pre-check: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.detect_act.outputs.is_act }} - ref: - ${{ (github.event_name == 'workflow_call' && inputs.ref) || (github.event_name == 'workflow_dispatch' && - (github.event.inputs.ref || github.ref)) || github.sha }} - repo: ${{ (github.event_name == 'workflow_call' && inputs.repo) || github.repository }} - base_sha: - ${{ (github.event_name == 'workflow_call' && inputs.pr-base-sha) || github.event.pull_request.base.sha || - github.event.before }} + is_act: ${{ steps.prepare.outputs.is_act }} + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} + base_sha: ${{ steps.prepare.outputs.base_sha }} + pr_number: ${{ steps.prepare.outputs.pr_number }} steps: - - name: Detect act environment - id: detect_act - uses: Framework-R-D/phlex/.github/actions/detect-act-env@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main detect-changes: needs: pre-check diff --git a/.github/workflows/markdown-fix.yaml b/.github/workflows/markdown-fix.yaml index bee7f76e..f6a9c6ac 100644 --- a/.github/workflows/markdown-fix.yaml +++ b/.github/workflows/markdown-fix.yaml @@ -43,7 +43,9 @@ run-name: "${{ github.actor }} fixing Markdown format" workflow_dispatch: inputs: ref: - description: "The branch name to checkout and push fixes to (must be a branch, not a commit SHA). Defaults to the repository's default branch." + description: + "The branch name to checkout and push fixes to (must be a branch, not a commit SHA). Defaults to the + repository's default branch." required: false type: string @@ -52,8 +54,7 @@ permissions: contents: write env: - local_checkout_path: - ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} + local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} jobs: pre-check: @@ -69,18 +70,15 @@ jobs: # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. # This covers repo owners, invited collaborators, and all org members. outputs: - ref: - ${{ inputs.ref || (github.event_name == 'workflow_dispatch' && - (github.event.inputs.ref || github.ref_name)) || steps.get_pr.outputs.ref }} - repo: - ${{ inputs.repo || (github.event_name == 'workflow_dispatch' && - github.repository) || steps.get_pr.outputs.repo }} - + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} steps: - - name: Get PR Info - if: github.event_name == 'issue_comment' && inputs.ref == '' - id: get_pr - uses: Framework-R-D/phlex/.github/actions/get-pr-info@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + with: + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} apply_fixes: runs-on: ubuntu-latest @@ -127,40 +125,8 @@ jobs: pr-info-repo: ${{ needs.pre-check.outputs.repo }} skip-comment: ${{ inputs.skip-comment || 'false' }} - - name: Remove eyes reaction - if: github.event_name == 'issue_comment' && inputs.skip-comment != 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - with: - script: | - try { - const { data: reactions } = await github.rest.reactions.listForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id - }); - const eyesReaction = reactions.find( - (r) => r.content === 'eyes' && r.user && r.user.login === 'github-actions[bot]' - ); - if (eyesReaction) { - await github.rest.reactions.deleteForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - reaction_id: eyesReaction.id - }); - } - } catch (_) { - // Reaction cleanup is best-effort; do not fail the workflow. - } - - - name: Add completion reaction - if: github.event_name == 'issue_comment' && inputs.skip-comment != 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + - name: Update PR comment reactions + if: always() && github.event_name == 'issue_comment' && inputs.skip-comment != 'true' + uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main with: - script: | - await github.rest.reactions.createForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - content: 'rocket' - }); + status: ${{ job.status }} diff --git a/.github/workflows/python-check.yaml b/.github/workflows/python-check.yaml index 8724da18..fb76fe08 100644 --- a/.github/workflows/python-check.yaml +++ b/.github/workflows/python-check.yaml @@ -50,18 +50,15 @@ jobs: pre-check: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.detect_act.outputs.is_act }} - ref: - ${{ (github.event_name == 'workflow_call' && inputs.ref) || (github.event_name == 'workflow_dispatch' && - (github.event.inputs.ref || github.ref)) || github.sha }} - repo: ${{ (github.event_name == 'workflow_call' && inputs.repo) || github.repository }} - base_sha: - ${{ (github.event_name == 'workflow_call' && inputs.pr-base-sha) || github.event.pull_request.base.sha || - github.event.before }} + is_act: ${{ steps.prepare.outputs.is_act }} + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} + base_sha: ${{ steps.prepare.outputs.base_sha }} + pr_number: ${{ steps.prepare.outputs.pr_number }} steps: - - name: Detect act environment - id: detect_act - uses: Framework-R-D/phlex/.github/actions/detect-act-env@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main detect-changes: needs: pre-check diff --git a/.github/workflows/python-fix.yaml b/.github/workflows/python-fix.yaml index 1f2bcc05..b63efa2d 100644 --- a/.github/workflows/python-fix.yaml +++ b/.github/workflows/python-fix.yaml @@ -8,7 +8,9 @@ run-name: "${{ github.actor }} fixing Python code" workflow_dispatch: inputs: ref: - description: "The branch name to checkout and push fixes to (must be a branch, not a commit SHA). Defaults to the repository's default branch." + description: + "The branch name to checkout and push fixes to (must be a branch, not a commit SHA). Defaults to the + repository's default branch." required: false type: string workflow_call: @@ -52,8 +54,7 @@ permissions: contents: write env: - local_checkout_path: - ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} + local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} jobs: pre-check: @@ -69,17 +70,15 @@ jobs: # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. # This covers repo owners, invited collaborators, and all org members. outputs: - ref: - ${{ inputs.ref || (github.event_name == 'workflow_dispatch' && - (github.event.inputs.ref || github.ref_name)) || steps.get_pr.outputs.ref }} - repo: - ${{ inputs.repo || (github.event_name == 'workflow_dispatch' && - github.repository) || steps.get_pr.outputs.repo }} + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} steps: - - name: Get PR Info - if: github.event_name == 'issue_comment' && inputs.ref == '' - id: get_pr - uses: Framework-R-D/phlex/.github/actions/get-pr-info@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + with: + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} apply_fixes: runs-on: ubuntu-latest @@ -130,40 +129,8 @@ jobs: pr-info-repo: ${{ needs.pre-check.outputs.repo }} skip-comment: ${{ inputs.skip-comment || 'false' }} - - name: Remove eyes reaction - if: github.event_name == 'issue_comment' && inputs.skip-comment != 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - with: - script: | - try { - const { data: reactions } = await github.rest.reactions.listForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id - }); - const eyesReaction = reactions.find( - (r) => r.content === 'eyes' && r.user && r.user.login === 'github-actions[bot]' - ); - if (eyesReaction) { - await github.rest.reactions.deleteForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - reaction_id: eyesReaction.id - }); - } - } catch (_) { - // Reaction cleanup is best-effort; do not fail the workflow. - } - - - name: Add completion reaction - if: github.event_name == 'issue_comment' && inputs.skip-comment != 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + - name: Update PR comment reactions + if: always() && github.event_name == 'issue_comment' && inputs.skip-comment != 'true' + uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main with: - script: | - await github.rest.reactions.createForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - content: 'rocket' - }); + status: ${{ job.status }} diff --git a/.github/workflows/yaml-check.yaml b/.github/workflows/yaml-check.yaml index 1fa6129d..7c0d4855 100644 --- a/.github/workflows/yaml-check.yaml +++ b/.github/workflows/yaml-check.yaml @@ -17,14 +17,15 @@ jobs: pre-check: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.detect_act.outputs.is_act }} - ref: ${{ (github.event_name == 'workflow_dispatch' && (github.event.inputs.ref || github.ref)) || github.sha }} - repo: ${{ github.repository }} - base_sha: ${{ github.event.pull_request.base.sha || github.event.before }} + is_act: ${{ steps.prepare.outputs.is_act }} + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} + base_sha: ${{ steps.prepare.outputs.base_sha }} + pr_number: ${{ steps.prepare.outputs.pr_number }} steps: - - name: Detect act environment - id: detect_act - uses: Framework-R-D/phlex/.github/actions/detect-act-env@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main detect-changes: needs: pre-check diff --git a/.github/workflows/yaml-fix.yaml b/.github/workflows/yaml-fix.yaml index 36c9f5c5..a9ae09d0 100644 --- a/.github/workflows/yaml-fix.yaml +++ b/.github/workflows/yaml-fix.yaml @@ -8,7 +8,9 @@ name: YAML Fix workflow_dispatch: inputs: ref: - description: "The branch name to checkout and push fixes to (must be a branch, not a commit SHA). Defaults to the repository's default branch." + description: + "The branch name to checkout and push fixes to (must be a branch, not a commit SHA). Defaults to the + repository's default branch." required: false type: string workflow_call: @@ -52,8 +54,7 @@ permissions: contents: write env: - local_checkout_path: - ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} + local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} jobs: pre-check: @@ -69,18 +70,15 @@ jobs: # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. # This covers repo owners, invited collaborators, and all org members. outputs: - ref: - ${{ inputs.ref || (github.event_name == 'workflow_dispatch' && - (github.event.inputs.ref || github.ref_name)) || steps.get_pr.outputs.ref }} - repo: - ${{ inputs.repo || (github.event_name == 'workflow_dispatch' && - github.repository) || steps.get_pr.outputs.repo }} - + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} steps: - - name: Get PR Info - if: github.event_name == 'issue_comment' && inputs.ref == '' - id: get_pr - uses: Framework-R-D/phlex/.github/actions/get-pr-info@main + - name: Prepare outputs + id: prepare + uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + with: + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} apply_yaml_fixes: runs-on: ubuntu-latest @@ -127,40 +125,8 @@ jobs: pr-info-repo: ${{ needs.pre-check.outputs.repo }} skip-comment: ${{ inputs.skip-comment || 'false' }} - - name: Remove eyes reaction - if: github.event_name == 'issue_comment' && inputs.skip-comment != 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - with: - script: | - try { - const { data: reactions } = await github.rest.reactions.listForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id - }); - const eyesReaction = reactions.find( - (r) => r.content === 'eyes' && r.user && r.user.login === 'github-actions[bot]' - ); - if (eyesReaction) { - await github.rest.reactions.deleteForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - reaction_id: eyesReaction.id - }); - } - } catch (_) { - // Reaction cleanup is best-effort; do not fail the workflow. - } - - - name: Add completion reaction - if: github.event_name == 'issue_comment' && inputs.skip-comment != 'true' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + - name: Update PR comment reactions + if: always() && github.event_name == 'issue_comment' && inputs.skip-comment != 'true' + uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main with: - script: | - await github.rest.reactions.createForIssueComment({ - owner: context.repo.owner, - repo: context.repo.repo, - comment_id: context.payload.comment.id, - content: 'rocket' - }); + status: ${{ job.status }} From 0efb0a76015b1b97ab3378a7bd518c07d2af68b0 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 12 Mar 2026 02:41:42 +0000 Subject: [PATCH 03/10] maintenance: Aggressive workflow consolidation and fix reactions This commit performs an extensive refactoring of the repository's CI workflows to eliminate boilerplate, improve consistency, and fix missing PR comment reactions. Summary of Changes: - **New High-Level Actions**: - `workflow-setup`: Unifies ref resolution, environment detection, and change detection (~100 lines of reusable logic). - `post-clang-tidy-results`: Consolidates complex Clang-Tidy reporting and PR comment logic. - `collect-format-results`: Streamlines result aggregation in `format-all`. - `complete-pr-comment`: Ensures consistent "eyes" removal and "rocket"/"confused" reactions. - **Workflow Optimization**: - Refactored all 21 core workflows (8 checks, 7 fixes, 6 complex). - Replaced separate `pre-check` and `detect-changes` jobs with a single `setup` job in most workflows. - Removed hundreds of lines of redundant YAML boilerplate. - Ensured all bot-triggered workflows provide a completion reaction. - **Line Savings**: Net reduction of ~640 lines of YAML across the repository. This refactoring significantly reduces the maintenance burden while providing a more robust and responsive developer experience. Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> Apply YAML formatter fixes Temporary branch switch to allow CI testing maintenance: address all outstanding review comments on workflow consolidation PR (#414) * Initial plan * Address all outstanding review comments on workflow consolidation PR Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> * Improve clang-tidy error handling - Per https://github.com/Framework-R-D/phlex/pull/414#discussion_r2925514272 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Address description inconsistency - Per https://github.com/Framework-R-D/phlex/pull/414#discussion_r2925514335 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> Co-authored-by: Chris Green Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> maintenance: address all current review comments on workflow consolidation (#415) * Initial plan * maintenance: address all current review comments on workflow consolidation Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> maintenance: fix CI failures caused by relative local action references (#416) * Initial plan * maintenance: fix CI failures by using external action refs from current PR branch All `uses: ./.github/actions/...` relative path references fail because: 1. `setup` jobs use local actions before any checkout 2. `build`/`fix` jobs check out code to a subdirectory, not workspace root Replace all 65 local action refs with `Framework-R-D/phlex/.github/actions/...@copilot/sub-pr-411-another-one`. Workflow-to-workflow refs (`./.github/workflows/...`) remain as relative paths. Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> Reset local action use back to the PR branch Revert reusable action referenaces back to `@main` --- .../collect-format-results/action.yaml | 53 ++++ .../actions/complete-pr-comment/action.yaml | 6 +- .../post-clang-tidy-results/action.yaml | 79 ++++++ .../actions/prepare-check-outputs/action.yaml | 25 ++ .../actions/prepare-fix-outputs/action.yaml | 13 + .../actions/run-change-detection/action.yaml | 68 +++++ .github/actions/workflow-setup/action.yaml | 121 +++++++++ .github/workflows/actionlint-check.yaml | 93 ++----- .github/workflows/clang-format-check.yaml | 87 ++----- .github/workflows/clang-format-fix.yaml | 36 +-- .github/workflows/clang-tidy-check.yaml | 233 +++--------------- .github/workflows/clang-tidy-fix.yaml | 108 ++++---- .github/workflows/cmake-build.yaml | 127 +++------- .github/workflows/cmake-format-check.yaml | 90 ++----- .github/workflows/cmake-format-fix.yaml | 36 +-- .github/workflows/codeql-analysis.yaml | 184 ++++---------- .github/workflows/coverage.yaml | 113 +++------ .github/workflows/format-all.yaml | 180 ++++---------- .github/workflows/header-guards-check.yaml | 89 ++----- .github/workflows/header-guards-fix.yaml | 38 +-- .github/workflows/jsonnet-format-check.yaml | 86 ++----- .github/workflows/jsonnet-format-fix.yaml | 36 +-- .github/workflows/markdown-check.yaml | 89 ++----- .github/workflows/markdown-fix.yaml | 38 +-- .github/workflows/python-check.yaml | 89 ++----- .github/workflows/python-fix.yaml | 38 +-- .github/workflows/yaml-check.yaml | 88 ++----- .github/workflows/yaml-fix.yaml | 36 +-- test/python/all_config.py | 10 +- test/python/reducer.py | 8 +- test/python/sumit.py | 10 +- test/python/test_coverage.py | 15 +- test/python/test_mismatch.py | 8 +- test/python/vectypes.py | 12 +- 34 files changed, 906 insertions(+), 1436 deletions(-) create mode 100644 .github/actions/collect-format-results/action.yaml create mode 100644 .github/actions/post-clang-tidy-results/action.yaml create mode 100644 .github/actions/run-change-detection/action.yaml create mode 100644 .github/actions/workflow-setup/action.yaml diff --git a/.github/actions/collect-format-results/action.yaml b/.github/actions/collect-format-results/action.yaml new file mode 100644 index 00000000..e630cf14 --- /dev/null +++ b/.github/actions/collect-format-results/action.yaml @@ -0,0 +1,53 @@ +name: "Collect Format Results" +description: "Aggregates results from multiple formatting jobs and creates a summary comment." +inputs: + results-json: + description: "JSON object containing job results" + required: true + +outputs: + message: + description: "The formatted summary message" + value: ${{ steps.collect.outputs.message }} + has_failures: + description: "Whether any job failed" + value: ${{ steps.collect.outputs.has_failures }} + +runs: + using: "composite" + steps: + - name: Aggregate results + id: collect + shell: bash + run: | + echo "results<> $GITHUB_ENV + echo '${{ inputs.results-json }}' >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + # In a real script we would parse the JSON, but for a composite action + # we can pass pre-formatted data. To keep it simple and robust, + # let's assume the caller provides a bash-friendly format or we use python. + + python3 -c " + import json, os + data = json.loads(os.environ['results']) + messages = [] + has_failures = False + for name, res in data.items(): + if res['result'] in ['failure', 'cancelled', 'skipped']: + messages.append(f'❌ {name} workflow {res[\"result\"]}') + has_failures = True + elif res.get('changes') == 'true': + if res.get('pushed') == 'true': + messages.append(f'✅ {name} fixes pushed (commit {res.get(\"sha\", \"\")})') + elif res.get('patch_name'): + messages.append(f'⚠️ {name} fixes available as patch {res.get(\"patch_name\")}') + + output_msg = 'No automatic format fixes were necessary.' + if messages: + output_msg = '### Format Fixes Applied\n' + '\n'.join(messages) + '\n\n⚠️ **Note:** Some issues may require manual review.' + + with open(os.environ['GITHUB_OUTPUT'], 'a') as f: + f.write(f'message<> "$GITHUB_OUTPUT" + else + echo "has_fixes=false" >> "$GITHUB_OUTPUT" + fi + + - name: Post inline comments + if: steps.check.outputs.has_fixes == 'true' && inputs.pr-number != '' + uses: platisd/clang-tidy-pr-comments@28cfb84edafa771c044bde7e4a2a3fae57463818 # v1.8.0 + with: + clang_tidy_fixes: ${{ inputs.build-path }}/clang-tidy-fixes.yaml + github_token: ${{ github.token }} + pull_request_id: ${{ inputs.pr-number }} + + - name: Post summary comment + if: steps.check.outputs.has_fixes == 'true' && inputs.post-summary == 'true' && inputs.pr-number != '' + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + with: + script: | + const fs = require('fs'); + const fixesFile = '${{ inputs.build-path }}/clang-tidy-fixes.yaml'; + + let totalIssues = 0; + const checkCounts = {}; + + if (fs.existsSync(fixesFile)) { + try { + const content = fs.readFileSync(fixesFile, 'utf8'); + const matches = content.matchAll(/^\s*DiagnosticName:\s+(\S.+?)$/gm); + for (const match of matches) { + const name = match[1].trim(); + checkCounts[name] = (checkCounts[name] || 0) + 1; + totalIssues++; + } + } catch (e) { console.log(e); } + } + + if (totalIssues > 0) { + const sorted = Object.entries(checkCounts).sort((a, b) => b[1] - a[1]); + let body = `## Clang-Tidy Check Results\n\nFound ${totalIssues} issue(s).\n\n### Issues by check:\n\n`; + sorted.forEach(([check, count]) => { body += `- **${check}**: ${count}\n`; }); + body += '\nSee inline comments for details. Comment `@phlexbot tidy-fix` to auto-fix.'; + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: ${{ inputs.pr-number }}, + body: body + }); + } diff --git a/.github/actions/prepare-check-outputs/action.yaml b/.github/actions/prepare-check-outputs/action.yaml index dbed7690..f1cf3242 100644 --- a/.github/actions/prepare-check-outputs/action.yaml +++ b/.github/actions/prepare-check-outputs/action.yaml @@ -10,6 +10,12 @@ inputs: pr-base-sha: description: "Manual base SHA override" required: false + checkout-path: + description: "Manual checkout path override" + required: false + build-path: + description: "Manual build path override" + required: false outputs: is_act: description: "Whether running in act" @@ -26,6 +32,12 @@ outputs: pr_number: description: "The PR number if available" value: ${{ steps.resolve.outputs.pr_number }} + checkout_path: + description: "The resolved checkout path" + value: ${{ steps.resolve.outputs.checkout_path }} + build_path: + description: "The resolved build path" + value: ${{ steps.resolve.outputs.build_path }} runs: using: "composite" steps: @@ -65,8 +77,21 @@ runs: fi REPO="${REPO:-${{ github.repository }}}" + REPO_NAME="${REPO##*/}" + + CHECKOUT_PATH="${{ inputs.checkout-path }}" + if [ -z "$CHECKOUT_PATH" ]; then + CHECKOUT_PATH="${REPO_NAME}-src" + fi + + BUILD_PATH="${{ inputs.build-path }}" + if [ -z "$BUILD_PATH" ]; then + BUILD_PATH="${REPO_NAME}-build" + fi echo "ref=$REF" >> "$GITHUB_OUTPUT" echo "repo=$REPO" >> "$GITHUB_OUTPUT" echo "base_sha=$BASE_SHA" >> "$GITHUB_OUTPUT" echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT" + echo "checkout_path=$CHECKOUT_PATH" >> "$GITHUB_OUTPUT" + echo "build_path=$BUILD_PATH" >> "$GITHUB_OUTPUT" diff --git a/.github/actions/prepare-fix-outputs/action.yaml b/.github/actions/prepare-fix-outputs/action.yaml index 6967977f..a48fbdd8 100644 --- a/.github/actions/prepare-fix-outputs/action.yaml +++ b/.github/actions/prepare-fix-outputs/action.yaml @@ -7,6 +7,9 @@ inputs: repo: description: "Manual repo override" required: false + checkout-path: + description: "Manual checkout path override" + required: false outputs: ref: description: "The resolved ref" @@ -14,6 +17,9 @@ outputs: repo: description: "The resolved repository" value: ${{ steps.resolve.outputs.repo }} + checkout_path: + description: "The resolved checkout path" + value: ${{ steps.resolve.outputs.checkout_path }} runs: using: "composite" steps: @@ -49,5 +55,12 @@ runs: fi fi + REPO_NAME="${REPO##*/}" + CHECKOUT_PATH="${{ inputs.checkout-path }}" + if [ -z "$CHECKOUT_PATH" ]; then + CHECKOUT_PATH="${REPO_NAME}-src" + fi + echo "ref=$REF" >> "$GITHUB_OUTPUT" echo "repo=$REPO" >> "$GITHUB_OUTPUT" + echo "checkout_path=$CHECKOUT_PATH" >> "$GITHUB_OUTPUT" diff --git a/.github/actions/run-change-detection/action.yaml b/.github/actions/run-change-detection/action.yaml new file mode 100644 index 00000000..ad40d539 --- /dev/null +++ b/.github/actions/run-change-detection/action.yaml @@ -0,0 +1,68 @@ +name: "Run Change Detection" +description: "Encapsulates checkout, detection of relevant changes, and reporting." +inputs: + checkout-path: + description: "Path to check out code to" + required: true + ref: + description: "The branch, ref, or SHA to checkout" + required: true + repo: + description: "The repository to checkout from" + required: true + base-ref: + description: "The base ref for comparison" + required: true + file-type: + description: "Predefined file type (cpp, python, cmake, jsonnet, yaml, md)" + required: false + include-globs: + description: "Custom include globs" + required: false + exclude-globs: + description: "Custom exclude globs" + required: false + head-ref: + description: "Explicit head ref (defaults to inputs.ref)" + required: false + +outputs: + has_changes: + description: "Whether relevant changes were detected" + value: ${{ steps.filter.outputs.matched }} + matched_files: + description: "The list of matched files" + value: ${{ steps.filter.outputs.matched_files }} + +runs: + using: "composite" + steps: + - name: Check out source code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + path: ${{ inputs.checkout-path }} + ref: ${{ inputs.ref }} + repository: ${{ inputs.repo }} + + - name: Detect relevant changes + id: filter + uses: Framework-R-D/phlex/.github/actions/detect-relevant-changes@main + with: + repo-path: ${{ inputs.checkout-path }} + base-ref: ${{ inputs.base-ref }} + head-ref: ${{ inputs.head-ref || inputs.ref }} + file-type: ${{ inputs.file-type }} + include-globs: ${{ inputs.include-globs }} + exclude-globs: ${{ inputs.exclude-globs }} + + - name: Report detection outcome + shell: bash + run: | + if [ "${{ steps.filter.outputs.matched }}" != "true" ]; then + echo "::notice::No relevant changes detected for ${{ inputs.file-type || 'custom globs' }}; job will be skipped." + else + echo "::group::Relevant files detected" + printf '%s\n' "${{ steps.filter.outputs.matched_files }}" + echo "::endgroup::" + fi diff --git a/.github/actions/workflow-setup/action.yaml b/.github/actions/workflow-setup/action.yaml new file mode 100644 index 00000000..619f911f --- /dev/null +++ b/.github/actions/workflow-setup/action.yaml @@ -0,0 +1,121 @@ +name: "Workflow Setup" +description: "Handles ref resolution, environment detection, and change detection in a single step." +inputs: + mode: + description: "Workflow mode ('check' or 'fix')" + required: false + default: "check" + ref: + description: "Manual ref override" + required: false + repo: + description: "Manual repo override" + required: false + pr-base-sha: + description: "Manual base SHA override (check mode only)" + required: false + checkout-path: + description: "Manual checkout path override" + required: false + build-path: + description: "Manual build path override" + required: false + file-type: + description: "File type for change detection (e.g., cpp, python)" + required: false + include-globs: + description: "Include globs for change detection" + required: false + exclude-globs: + description: "Exclude globs for change detection" + required: false + +outputs: + is_act: + description: "Whether running in act" + value: ${{ steps.prepare.outputs.is_act }} + ref: + description: "Resolved ref" + value: ${{ steps.prepare.outputs.ref }} + repo: + description: "Resolved repository" + value: ${{ steps.prepare.outputs.repo }} + base_sha: + description: "Resolved base SHA" + value: ${{ steps.prepare.outputs.base_sha }} + pr_number: + description: "PR number" + value: ${{ steps.prepare.outputs.pr_number }} + checkout_path: + description: "Resolved checkout path" + value: ${{ steps.prepare.outputs.checkout_path }} + build_path: + description: "Resolved build path" + value: ${{ steps.prepare.outputs.build_path }} + has_changes: + description: "Whether relevant changes were detected" + value: ${{ steps.detect.outputs.has_changes }} + +runs: + using: "composite" + steps: + - name: Prepare basic outputs (check mode) + if: inputs.mode == 'check' + id: prepare_check + uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@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 }} + + - name: Prepare basic outputs (fix mode) + if: inputs.mode == 'fix' + id: prepare_fix + uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + with: + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} + checkout-path: ${{ inputs.checkout-path }} + + - name: Standardize outputs + id: prepare + shell: bash + run: | + if [ "${{ inputs.mode }}" == "check" ]; then + echo "is_act=${{ steps.prepare_check.outputs.is_act }}" >> "$GITHUB_OUTPUT" + echo "ref=${{ steps.prepare_check.outputs.ref }}" >> "$GITHUB_OUTPUT" + echo "repo=${{ steps.prepare_check.outputs.repo }}" >> "$GITHUB_OUTPUT" + echo "base_sha=${{ steps.prepare_check.outputs.base_sha }}" >> "$GITHUB_OUTPUT" + echo "pr_number=${{ steps.prepare_check.outputs.pr_number }}" >> "$GITHUB_OUTPUT" + echo "checkout_path=${{ steps.prepare_check.outputs.checkout_path }}" >> "$GITHUB_OUTPUT" + echo "build_path=${{ steps.prepare_check.outputs.build_path }}" >> "$GITHUB_OUTPUT" + else + echo "is_act=false" >> "$GITHUB_OUTPUT" + echo "ref=${{ steps.prepare_fix.outputs.ref }}" >> "$GITHUB_OUTPUT" + echo "repo=${{ steps.prepare_fix.outputs.repo }}" >> "$GITHUB_OUTPUT" + echo "base_sha=" >> "$GITHUB_OUTPUT" + echo "pr_number=${{ github.event.issue.number }}" >> "$GITHUB_OUTPUT" + echo "checkout_path=${{ steps.prepare_fix.outputs.checkout_path }}" >> "$GITHUB_OUTPUT" + CHECKOUT_PATH="${{ steps.prepare_fix.outputs.checkout_path }}" + REPO_NAME="${CHECKOUT_PATH%-src}" + BUILD_PATH="${{ inputs.build-path }}" + if [ -z "$BUILD_PATH" ]; then + BUILD_PATH="${REPO_NAME}-build" + fi + echo "build_path=$BUILD_PATH" >> "$GITHUB_OUTPUT" + fi + + - name: Run change detection + id: detect + if: inputs.file-type != '' || inputs.include-globs != '' + uses: Framework-R-D/phlex/.github/actions/run-change-detection@main + with: + checkout-path: ${{ steps.prepare.outputs.checkout_path }} + ref: ${{ steps.prepare.outputs.ref }} + repo: ${{ steps.prepare.outputs.repo }} + base-ref: ${{ steps.prepare.outputs.base_sha }} + file-type: ${{ inputs.file-type }} + include-globs: ${{ inputs.include-globs }} + exclude-globs: ${{ inputs.exclude-globs }} diff --git a/.github/workflows/actionlint-check.yaml b/.github/workflows/actionlint-check.yaml index 0ad0eae6..fa69671a 100644 --- a/.github/workflows/actionlint-check.yaml +++ b/.github/workflows/actionlint-check.yaml @@ -47,78 +47,31 @@ env: github.event.repository.name) }} jobs: - pre-check: + setup: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.prepare.outputs.is_act }} - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} - base_sha: ${{ steps.prepare.outputs.base_sha }} - pr_number: ${{ steps.prepare.outputs.pr_number }} + 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 }} + has_changes: ${{ steps.setup.outputs.has_changes }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main + - 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 }} - - detect-changes: - needs: pre-check - if: > - github.event_name != 'workflow_dispatch' && ( - github.event_name != 'workflow_call' || - (inputs.skip-relevance-check != 'true' && github.event.inputs == null && github.event.comment == null) - ) && needs.pre-check.outputs.is_act != 'true' - runs-on: ubuntu-latest - permissions: - contents: read - packages: read - outputs: - has_changes: ${{ steps.filter.outputs.matched }} - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - path: ${{ env.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} - - - name: Detect relevant changes - id: filter - uses: Framework-R-D/phlex/.github/actions/detect-relevant-changes@main - with: - repo-path: ${{ env.local_checkout_path }} - base-ref: ${{ needs.pre-check.outputs.base_sha }} - head-ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || needs.pre-check.outputs.ref }} include-globs: | .github/workflows/**/*.yml .github/workflows/**/*.yaml .github/actions/**/*.yml .github/actions/**/*.yaml - - name: Report detection outcome - run: | - if [ "${{ steps.filter.outputs.matched }}" != "true" ]; then - echo "::notice::No actionlint related changes detected; job will be skipped." - else - echo "::group::Actionlint relevant files" - printf '%s\n' "${{ steps.filter.outputs.matched_files }}" - echo "::endgroup::" - fi - actionlint-check: - needs: [pre-check, detect-changes] + needs: setup if: > - always() && ( - needs.detect-changes.result == 'skipped' || - ( - needs.detect-changes.result == 'success' && - needs.detect-changes.outputs.has_changes == 'true' - ) - ) + always() && needs.setup.outputs.has_changes == 'true' runs-on: ubuntu-latest permissions: contents: read @@ -127,9 +80,9 @@ jobs: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - ref: ${{ needs.pre-check.outputs.ref }} + ref: ${{ needs.setup.outputs.ref }} path: ${{ env.local_checkout_path }} - repository: ${{ needs.pre-check.outputs.repo }} + repository: ${{ needs.setup.outputs.repo }} - name: Announce actionlint check run: echo "➡️ Running actionlint check..." @@ -153,19 +106,3 @@ jobs: echo "::error::actionlint check failed. Please review the output above for details." exit 1 fi - - actionlint-check-skipped: - needs: [pre-check, detect-changes] - if: > - needs.pre-check.result == 'success' && github.event_name != 'workflow_dispatch' && ( - github.event_name != 'workflow_call' || - (inputs.skip-relevance-check != 'true' && github.event.inputs == null && github.event.comment == null) - ) && 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 workflow changes detected - run: echo "::notice::No actionlint relevant changes detected; check skipped." diff --git a/.github/workflows/clang-format-check.yaml b/.github/workflows/clang-format-check.yaml index 32c3057d..38478df1 100644 --- a/.github/workflows/clang-format-check.yaml +++ b/.github/workflows/clang-format-check.yaml @@ -15,67 +15,27 @@ permissions: type: string jobs: - pre-check: + setup: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.prepare.outputs.is_act }} - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} - base_sha: ${{ steps.prepare.outputs.base_sha }} - pr_number: ${{ steps.prepare.outputs.pr_number }} + 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 }} + has_changes: ${{ steps.setup.outputs.has_changes }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@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 }} - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - path: phlex-src - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} - - - name: Detect relevant changes - id: filter - uses: Framework-R-D/phlex/.github/actions/detect-relevant-changes@main + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: - repo-path: phlex-src - base-ref: ${{ needs.pre-check.outputs.base_sha }} - head-ref: ${{ needs.pre-check.outputs.ref }} file-type: cpp - - name: Report detection outcome - run: | - if [ "${{ steps.filter.outputs.matched }}" != "true" ]; then - echo "::notice::No clang-format related changes detected; job will be skipped." - else - echo "::group::Clang-format relevant files" - printf '%s\n' "${{ steps.filter.outputs.matched_files }}" - echo "::endgroup::" - fi - clang-format-check: - needs: [pre-check, detect-changes] + needs: setup if: > - always() && ( - needs.detect-changes.result == 'skipped' || - ( - needs.detect-changes.result == 'success' && - needs.detect-changes.outputs.has_changes == 'true' - ) - ) + always() && needs.setup.outputs.has_changes == 'true' runs-on: ubuntu-latest permissions: contents: read @@ -84,9 +44,9 @@ jobs: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - ref: ${{ needs.pre-check.outputs.ref }} - path: phlex-src - repository: ${{ needs.pre-check.outputs.repo }} + ref: ${{ needs.setup.outputs.ref }} + path: ${{ needs.setup.outputs.checkout_path }} + repository: ${{ needs.setup.outputs.repo }} - name: Announce clang-format check run: echo "➡️ Running clang-format check..." @@ -95,7 +55,7 @@ jobs: id: lint uses: DoozyX/clang-format-lint-action@bcb4eb2cb0d707ee4f3e5cc3b456eb075f12cf73 # v0.20 with: - source: "./phlex-src" + source: "./${{ needs.setup.outputs.checkout_path }}" clangFormatVersion: 20 extensions: cpp,hpp,cpp.in,hpp.in continue-on-error: true @@ -110,16 +70,3 @@ jobs: echo "::error::Comment '@${{ github.event.repository.name }}bot format' on the PR to attempt auto-fix." exit 1 fi - - clang-format-check-skipped: - 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 "::notice::No clang-format relevant changes detected; check skipped." diff --git a/.github/workflows/clang-format-fix.yaml b/.github/workflows/clang-format-fix.yaml index 2b3fa1cc..25397798 100644 --- a/.github/workflows/clang-format-fix.yaml +++ b/.github/workflows/clang-format-fix.yaml @@ -57,34 +57,36 @@ env: local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} jobs: - pre-check: + setup: runs-on: ubuntu-latest name: Parse command if: > - github.event_name == 'workflow_dispatch' || inputs.ref != '' || ( + inputs.ref != '' || + github.event_name == 'workflow_dispatch' || ( 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 clang-fix', github.event.repository.name)) ) - # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. - # This covers repo owners, invited collaborators, and all org members. outputs: - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} + ref: ${{ steps.setup.outputs.ref }} + repo: ${{ steps.setup.outputs.repo }} + checkout_path: ${{ steps.setup.outputs.checkout_path }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: + mode: fix ref: ${{ inputs.ref }} repo: ${{ inputs.repo }} + checkout-path: ${{ inputs.checkout-path }} apply_formatting: runs-on: ubuntu-latest name: Apply formatting - needs: pre-check - if: ${{ needs.pre-check.result == 'success' }} + needs: setup + if: ${{ needs.setup.result == 'success' }} outputs: changes: ${{ steps.handle_commit.outputs.changes }} pushed: ${{ steps.handle_commit.outputs.pushed }} @@ -94,9 +96,9 @@ jobs: steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - path: ${{ env.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} + path: ${{ needs.setup.outputs.checkout_path }} + ref: ${{ needs.setup.outputs.ref }} + repository: ${{ needs.setup.outputs.repo }} token: ${{ secrets.WORKFLOW_PAT }} - uses: DoozyX/clang-format-lint-action@bcb4eb2cb0d707ee4f3e5cc3b456eb075f12cf73 # v0.20 @@ -111,10 +113,10 @@ jobs: uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main with: tool: clang-format - working-directory: ${{ env.local_checkout_path }} + working-directory: ${{ needs.setup.outputs.checkout_path }} token: ${{ secrets.WORKFLOW_PAT }} - pr-info-ref: ${{ needs.pre-check.outputs.ref }} - pr-info-repo: ${{ needs.pre-check.outputs.repo }} + pr-info-ref: ${{ needs.setup.outputs.ref }} + pr-info-repo: ${{ needs.setup.outputs.repo }} skip-comment: ${{ inputs.skip-comment || 'false' }} - name: Update PR comment reactions diff --git a/.github/workflows/clang-tidy-check.yaml b/.github/workflows/clang-tidy-check.yaml index e1a8ce52..b3cf3db3 100644 --- a/.github/workflows/clang-tidy-check.yaml +++ b/.github/workflows/clang-tidy-check.yaml @@ -17,7 +17,8 @@ permissions: type: string jobs: - pre-check: + setup: + runs-on: ubuntu-latest if: > github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' || ( github.event_name == 'issue_comment' && @@ -25,71 +26,28 @@ jobs: contains(fromJSON('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association) && startsWith(github.event.comment.body, '@phlexbot tidy-check') ) - runs-on: ubuntu-latest outputs: - is_act: ${{ steps.prepare.outputs.is_act }} - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} - base_sha: ${{ steps.prepare.outputs.base_sha }} - pr_number: ${{ steps.prepare.outputs.pr_number }} + 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: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main - - detect-changes: - needs: pre-check - if: > - needs.pre-check.result == 'success' && 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 }} - - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: - fetch-depth: 0 - path: phlex-src - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} - - - name: Detect relevant changes - id: filter - uses: Framework-R-D/phlex/.github/actions/detect-relevant-changes@main - with: - repo-path: phlex-src - base-ref: ${{ needs.pre-check.outputs.base_sha }} - head-ref: ${{ needs.pre-check.outputs.ref }} file-type: | cpp cmake - - name: Report detection outcome - run: | - if [ "${{ steps.filter.outputs.matched }}" != "true" ]; then - echo "::notice::No clang-tidy relevant changes detected; job will be skipped." - else - echo "::group::Clang-tidy relevant files" - printf '%s\n' "${{ steps.filter.outputs.matched_files }}" - echo "::endgroup::" - fi - clang-tidy-check: - needs: [pre-check, detect-changes] + needs: setup if: > - always() && ( - needs.detect-changes.result == 'skipped' || - ( - needs.detect-changes.result == 'success' && - needs.detect-changes.outputs.has_changes == 'true' - ) - ) + always() && needs.setup.outputs.has_changes == 'true' runs-on: ubuntu-24.04 container: image: ghcr.io/framework-r-d/phlex-ci:latest @@ -98,17 +56,21 @@ jobs: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - ref: ${{ needs.pre-check.outputs.ref }} - path: phlex-src - repository: ${{ needs.pre-check.outputs.repo }} + ref: ${{ needs.setup.outputs.ref }} + path: ${{ needs.setup.outputs.checkout_path }} + repository: ${{ needs.setup.outputs.repo }} - name: Setup build environment uses: Framework-R-D/phlex/.github/actions/setup-build-env@main + with: + build-path: ${{ needs.setup.outputs.build_path }} - name: Configure CMake (Debug) uses: Framework-R-D/phlex/.github/actions/configure-cmake@main with: build-type: Debug + source-path: ${{ needs.setup.outputs.checkout_path }} + build-path: ${{ needs.setup.outputs.build_path }} extra-options: "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_SCAN_FOR_MODULES=OFF -DCMAKE_CXX_CLANG_TIDY='clang-tidy;--export-fixes=clang-tidy-fixes.yaml'" @@ -118,160 +80,43 @@ jobs: shell: bash run: | . /entrypoint.sh - cd "$GITHUB_WORKSPACE/phlex-build" + cd "$GITHUB_WORKSPACE/${{ needs.setup.outputs.build_path }}" echo "➡️ Running clang-tidy checks..." cmake_status=0 cmake --build . -j "$(nproc)" > clang-tidy.log 2>&1 || cmake_status=$? - # Distinguish tooling failures from issue detection by checking log content if [ "$cmake_status" -ne 0 ]; then - if ! grep -qE '^/.+\.(cpp|hpp|c|h):[0-9]+:[0-9]+: (warning|error):' clang-tidy.log; then - echo "::error::clang-tidy failed without producing diagnostic output (exit code $cmake_status)" - echo "::group::clang-tidy log output" - cat clang-tidy.log - echo "::endgroup::" - exit "$cmake_status" - fi - fi - - if grep -qE '^/.+\.(cpp|hpp|c|h):[0-9]+:[0-9]+: (warning|error):' clang-tidy.log; then - echo "has_issues=true" >> "$GITHUB_OUTPUT" + echo "::error::CMake build failed with exit code $cmake_status" + exit 1 + elif grep -qE '^/.+\.(cpp|hpp|c|h):[0-9]+:[0-9]+: (warning|error):' clang-tidy.log; then echo "::warning::Clang-tidy found issues in the code" - echo "Error count by check (full details in clang-tidy-log artifact):" - sed -nEe '\&^/& s&^.*\[([^][:space:]]+)\]$&\1&p' clang-tidy.log | sort | uniq -c | sort -n -k 1 -r - echo "Comment '@${{ github.event.repository.name }}bot tidy-fix [...]' on the PR to attempt auto-fix" else - echo "has_issues=false" >> "$GITHUB_OUTPUT" echo "✅ clang-tidy check passed" fi - - name: Upload clang-tidy report - if: always() - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 - with: - name: clang-tidy-report - path: phlex-build/clang-tidy-fixes.yaml - retention-days: 7 - if-no-files-found: ignore - - - name: Upload clang-tidy log + - name: Upload artifacts if: always() uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 with: - name: clang-tidy-log - path: phlex-build/clang-tidy.log + name: clang-tidy-check + path: | + ${{ needs.setup.outputs.build_path }}/clang-tidy-fixes.yaml + ${{ needs.setup.outputs.build_path }}/clang-tidy.log retention-days: 7 if-no-files-found: ignore - clang-tidy-pr-comments: - needs: [pre-check, clang-tidy-check] - if: - always() && needs.clang-tidy-check.result == 'success' && (github.event_name == 'pull_request' || - github.event_name == 'issue_comment') + report: + needs: [setup, clang-tidy-check] + if: always() && needs.setup.result == 'success' runs-on: ubuntu-latest permissions: pull-requests: write issues: write steps: - - name: Download clang-tidy report - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: clang-tidy-report - path: phlex-build - continue-on-error: true - - - name: Download clang-tidy log - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: clang-tidy-log - path: phlex-build - continue-on-error: true - - - name: Setup Node.js - if: github.event_name == 'issue_comment' - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + - name: Post Clang-Tidy results + uses: Framework-R-D/phlex/.github/actions/post-clang-tidy-results@main with: - node-version: "20.x" - - - name: Install js-yaml - if: github.event_name == 'issue_comment' - run: npm install js-yaml - - - name: Check if artifacts exist - id: check_artifacts - run: | - if [ -f phlex-build/clang-tidy-fixes.yaml ]; then - echo "has_fixes=true" >> "$GITHUB_OUTPUT" - else - echo "has_fixes=false" >> "$GITHUB_OUTPUT" - fi - - - name: Post clang-tidy comments - if: steps.check_artifacts.outputs.has_fixes == 'true' - uses: platisd/clang-tidy-pr-comments@28cfb84edafa771c044bde7e4a2a3fae57463818 # v1.8.0 - with: - clang_tidy_fixes: phlex-build/clang-tidy-fixes.yaml - github_token: ${{ secrets.GITHUB_TOKEN }} - pull_request_id: ${{ github.event.pull_request.number || needs.pre-check.outputs.pr_number }} - - - name: Post summary comment - if: steps.check_artifacts.outputs.has_fixes == 'true' && github.event_name == 'issue_comment' - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - with: - script: | - const fs = require('fs'); - const path = require('path'); - const yaml = require('js-yaml'); - - const fixesFile = 'phlex-build/clang-tidy-fixes.yaml'; - const checkCounts = {}; - let totalIssues = 0; - - if (fs.existsSync(fixesFile)) { - try { - const content = yaml.load(fs.readFileSync(fixesFile, 'utf8')); - if (content?.Diagnostics) { - content.Diagnostics.forEach(diag => { - if (diag.DiagnosticName) { - checkCounts[diag.DiagnosticName] = (checkCounts[diag.DiagnosticName] || 0) + 1; - totalIssues++; - } - }); - } - } catch (e) { - console.log(`Error reading fixes file: ${e.message}`); - } - } - - const sorted = Object.entries(checkCounts).sort((a, b) => b[1] - a[1]); - let body = '## Clang-Tidy Check Results\n\n'; - body += `Found ${totalIssues} issue(s) in the code.\n\n`; - if (sorted.length > 0) { - body += '### Issues by check:\n\n'; - sorted.forEach(([check, count]) => { - body += `- **${check}**: ${count}\n`; - }); - body += '\n'; - } - body += 'See inline comments for details. '; - body += 'Comment `@phlexbot tidy-fix [...]` to attempt auto-fix.'; - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: ${{ needs.pre-check.outputs.pr_number }}, - body: body - }); - - clang-tidy-check-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 clang-tidy changes detected - run: echo "::notice::No clang-tidy relevant changes detected; check skipped." + build-path: ${{ needs.setup.outputs.build_path }} + pr-number: ${{ needs.setup.outputs.pr_number }} + post-summary: "true" diff --git a/.github/workflows/clang-tidy-fix.yaml b/.github/workflows/clang-tidy-fix.yaml index 56aa7c20..97936885 100644 --- a/.github/workflows/clang-tidy-fix.yaml +++ b/.github/workflows/clang-tidy-fix.yaml @@ -23,7 +23,7 @@ permissions: contents: write jobs: - pre-check: + setup: runs-on: ubuntu-latest name: Parse command if: > @@ -36,8 +36,10 @@ jobs: # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. # This covers repo owners, invited collaborators, and all org members. outputs: - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} + ref: ${{ steps.setup.outputs.ref }} + repo: ${{ steps.setup.outputs.repo }} + checkout_path: ${{ steps.setup.outputs.checkout_path }} + build_path: ${{ steps.setup.outputs.build_path }} tidy_checks: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tidy-checks || steps.parse_comment.outputs.tidy_checks }} @@ -55,15 +57,17 @@ jobs: tidy_checks="$(echo "$checks_line" | tr ',' ' ' | xargs -n1 | paste -sd, -)" echo "tidy_checks=$tidy_checks" >> "$GITHUB_OUTPUT" fi - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main + with: + mode: fix apply_tidy_fixes: runs-on: ubuntu-24.04 name: Apply clang-tidy fixes - needs: pre-check - if: ${{ needs.pre-check.result == 'success' }} + needs: setup + if: ${{ needs.setup.result == 'success' }} container: image: ghcr.io/framework-r-d/phlex-ci:latest @@ -72,43 +76,43 @@ jobs: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - path: phlex-src - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} + path: ${{ needs.setup.outputs.checkout_path }} + ref: ${{ needs.setup.outputs.ref }} + repository: ${{ needs.setup.outputs.repo }} token: ${{ secrets.WORKFLOW_PAT }} - name: Try to download existing fixes from check workflow id: download_fixes_check - if: needs.pre-check.outputs.tidy_checks == '' - uses: dawidd6/action-download-artifact@09b07ec687d10771279a426c79925ee415c12906 # v17 + if: needs.setup.outputs.tidy_checks == '' + uses: dawidd6/action-download-artifact@2536c51d3d126276eb39f74d6bc9c72ac6ef30d3 # v16 with: workflow: clang-tidy-check.yaml - name: clang-tidy-report + name: clang-tidy-check path: fixes - branch: ${{ needs.pre-check.outputs.ref }} + branch: ${{ needs.setup.outputs.ref }} continue-on-error: true - name: Try to download existing fixes from previous fix workflow id: download_fixes_fix - if: steps.download_fixes_check.outcome != 'success' && needs.pre-check.outputs.tidy_checks == '' - uses: dawidd6/action-download-artifact@09b07ec687d10771279a426c79925ee415c12906 # v17 + if: steps.download_fixes_check.outcome != 'success' && needs.setup.outputs.tidy_checks == '' + uses: dawidd6/action-download-artifact@2536c51d3d126276eb39f74d6bc9c72ac6ef30d3 # v16 with: workflow: clang-tidy-fix.yaml - name: clang-tidy-report + name: clang-tidy-fix path: fixes - branch: ${{ needs.pre-check.outputs.ref }} + branch: ${{ needs.setup.outputs.ref }} continue-on-error: true - name: Apply fixes from artifact if available id: apply_from_artifact if: - needs.pre-check.outputs.tidy_checks == '' && (steps.download_fixes_check.outcome == 'success' || + needs.setup.outputs.tidy_checks == '' && (steps.download_fixes_check.outcome == 'success' || steps.download_fixes_fix.outcome == 'success') run: | if [ -f fixes/clang-tidy-fixes.yaml ]; then echo "Applying fixes from existing artifact..." . /entrypoint.sh - cd phlex-src + cd "${{ needs.setup.outputs.checkout_path }}" clang-apply-replacements ../fixes || true echo "applied=true" >> "$GITHUB_OUTPUT" else @@ -118,12 +122,14 @@ jobs: - name: Setup build environment if: steps.apply_from_artifact.outputs.applied != 'true' uses: Framework-R-D/phlex/.github/actions/setup-build-env@main + with: + build-path: ${{ needs.setup.outputs.build_path }} - name: Prepare CMake configuration options if: steps.apply_from_artifact.outputs.applied != 'true' id: prep_tidy_opts env: - TIDY_CHECKS: ${{ needs.pre-check.outputs.tidy_checks }} + TIDY_CHECKS: ${{ needs.setup.outputs.tidy_checks }} run: | . /entrypoint.sh cd "$GITHUB_WORKSPACE" @@ -140,6 +146,8 @@ jobs: uses: Framework-R-D/phlex/.github/actions/configure-cmake@main with: build-type: Debug + source-path: ${{ needs.setup.outputs.checkout_path }} + build-path: ${{ needs.setup.outputs.build_path }} extra-options: "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_SCAN_FOR_MODULES=OFF -DCMAKE_CXX_CLANG_TIDY='${{ steps.prep_tidy_opts.outputs.clang_tidy_opts }}'" @@ -148,24 +156,25 @@ jobs: if: steps.apply_from_artifact.outputs.applied != 'true' run: | . /entrypoint.sh - cd "$GITHUB_WORKSPACE/phlex-build" + cd "$GITHUB_WORKSPACE/${{ needs.setup.outputs.build_path }}" cmake --build . -j "$(nproc)" || true - name: Apply clang-tidy fixes if: steps.apply_from_artifact.outputs.applied != 'true' run: | . /entrypoint.sh - cd "$GITHUB_WORKSPACE/phlex-build" + cd "$GITHUB_WORKSPACE/${{ needs.setup.outputs.build_path }}" if [ -f clang-tidy-fixes.yaml ]; then clang-apply-replacements . || true fi - - name: Upload clang-tidy report + - name: Upload artifacts if: always() uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 with: - name: clang-tidy-report - path: phlex-build/clang-tidy-fixes.yaml + name: clang-tidy-fix + path: | + ${{ needs.setup.outputs.build_path }}/clang-tidy-fixes.yaml retention-days: 7 if-no-files-found: ignore @@ -173,48 +182,25 @@ jobs: uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main with: tool: clang-tidy - working-directory: phlex-src + working-directory: ${{ needs.setup.outputs.checkout_path }} token: ${{ secrets.WORKFLOW_PAT }} - pr-info-ref: ${{ needs.pre-check.outputs.ref }} - pr-info-repo: ${{ needs.pre-check.outputs.repo }} + pr-info-ref: ${{ needs.setup.outputs.ref }} + pr-info-repo: ${{ needs.setup.outputs.repo }} - clang-tidy-pr-comments: - needs: apply_tidy_fixes + report: + needs: [setup, apply_tidy_fixes] + if: always() && needs.setup.result == 'success' && needs.setup.outputs.pr_number != '' runs-on: ubuntu-latest permissions: pull-requests: write steps: - - name: Download clang-tidy report - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + - name: Post Clang-Tidy results + uses: Framework-R-D/phlex/.github/actions/post-clang-tidy-results@main with: - name: clang-tidy-report - path: phlex-build - continue-on-error: true + build-path: ${{ needs.setup.outputs.build_path }} + pr-number: ${{ needs.setup.outputs.pr_number }} - - name: Check if artifacts exist - id: check_artifacts - run: | - if [ -f phlex-build/clang-tidy-fixes.yaml ]; then - echo "has_fixes=true" >> "$GITHUB_OUTPUT" - else - echo "has_fixes=false" >> "$GITHUB_OUTPUT" - fi - - - name: Post clang-tidy comments - if: steps.check_artifacts.outputs.has_fixes == 'true' - uses: platisd/clang-tidy-pr-comments@28cfb84edafa771c044bde7e4a2a3fae57463818 # v1.8.0 - with: - clang_tidy_fixes: phlex-build/clang-tidy-fixes.yaml - github_token: ${{ secrets.GITHUB_TOKEN }} - - complete-comment: - needs: [pre-check, apply_tidy_fixes, clang-tidy-pr-comments] - if: always() && needs.pre-check.result == 'success' - runs-on: ubuntu-latest - steps: - name: Update PR comment reactions uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main with: - status: - ${{ (needs.apply_tidy_fixes.result == 'success' && needs.clang-tidy-pr-comments.result == 'success') && - 'success' || 'failure' }} + status: ${{ needs.apply_tidy_fixes.result }} diff --git a/.github/workflows/cmake-build.yaml b/.github/workflows/cmake-build.yaml index c42dfbbb..a74c5c06 100644 --- a/.github/workflows/cmake-build.yaml +++ b/.github/workflows/cmake-build.yaml @@ -75,7 +75,7 @@ env: }} jobs: - pre-check: + setup: if: > github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'workflow_call' || ( @@ -84,80 +84,37 @@ jobs: contains(fromJSON('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association) && startsWith(github.event.comment.body, format('@{0}bot build', github.event.repository.name)) ) - # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. - # This covers repo owners, invited collaborators, and all org members. runs-on: ubuntu-latest permissions: contents: read packages: read outputs: - is_act: ${{ steps.prepare.outputs.is_act }} - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} - base_sha: ${{ steps.prepare.outputs.base_sha }} - pr_number: ${{ steps.prepare.outputs.pr_number }} + 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: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main + - 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 }} - - detect-changes: - needs: pre-check - if: > - needs.pre-check.result == 'success' && ( - github.event_name == 'pull_request' || - github.event_name == 'push' || - ( - github.event_name == 'workflow_call' && - inputs.skip-relevance-check != 'true' && - github.event.inputs == null && - github.event.comment == null - ) - ) && 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - path: ${{ env.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} - - - name: Detect relevant changes - id: filter - uses: Framework-R-D/phlex/.github/actions/detect-relevant-changes@main - with: - repo-path: ${{ env.local_checkout_path }} - base-ref: ${{ needs.pre-check.outputs.base_sha }} - head-ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || needs.pre-check.outputs.ref }} + checkout-path: ${{ inputs.checkout-path }} + build-path: ${{ inputs.build-path }} 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' + needs: setup + if: needs.setup.result == 'success' runs-on: ubuntu-latest outputs: matrix: ${{ steps.generate.outputs.matrix }} @@ -171,15 +128,9 @@ jobs: comment-body: ${{ github.event.comment.body }} build: - needs: [pre-check, detect-changes, generate-matrix] + needs: [setup, generate-matrix] if: > - always() && needs.pre-check.result == 'success' && ( - needs.detect-changes.result == 'skipped' || - ( - needs.detect-changes.result == 'success' && - needs.detect-changes.outputs.has_changes == 'true' - ) - ) + always() && needs.setup.result == 'success' && needs.setup.outputs.has_changes == 'true' runs-on: ubuntu-24.04 strategy: fail-fast: false @@ -192,14 +143,14 @@ jobs: - name: Check out code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - path: ${{ env.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} + path: ${{ needs.setup.outputs.checkout_path }} + ref: ${{ needs.setup.outputs.ref }} + repository: ${{ needs.setup.outputs.repo }} - name: Setup build environment uses: Framework-R-D/phlex/.github/actions/setup-build-env@main with: - build-path: ${{ env.local_build_path }} + build-path: ${{ needs.setup.outputs.build_path }} - name: Announce CMake configuration run: echo "➡️ Configuring CMake..." @@ -207,15 +158,15 @@ jobs: - name: Extract repository name id: repo_name env: - REPO_FULL_NAME: ${{ needs.pre-check.outputs.repo }} + 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: ${{ env.local_checkout_path }} - build-path: ${{ env.local_build_path }} + 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: | @@ -226,13 +177,13 @@ jobs: id: build uses: Framework-R-D/phlex/.github/actions/build-cmake@main with: - build-path: ${{ env.local_build_path }} + build-path: ${{ needs.setup.outputs.build_path }} - name: Run tests if: matrix.sanitizer != 'valgrind' run: | . /entrypoint.sh - cd "$GITHUB_WORKSPACE/${{ env.local_build_path }}" + cd "$GITHUB_WORKSPACE/${{ needs.setup.outputs.build_path }}" echo "➡️ Running tests..." echo "::group::Running ctest" @@ -249,7 +200,7 @@ jobs: if: matrix.sanitizer == 'valgrind' run: | . /entrypoint.sh - cd "$GITHUB_WORKSPACE/${{ env.local_build_path }}" + cd "$GITHUB_WORKSPACE/${{ needs.setup.outputs.build_path }}" echo "➡️ Running Valgrind tests..." echo "::group::Running ctest -T memcheck" @@ -261,33 +212,17 @@ jobs: 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' && ( - github.event_name != 'workflow_call' || - (inputs.skip-relevance-check != 'true' && github.event.inputs == null && github.event.comment == null) - ) && 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." - build-complete: - needs: [pre-check, build] + needs: [setup, build] if: > - always() && github.event_name == 'issue_comment' && needs.pre-check.result == 'success' + 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: Framework-R-D/phlex/.github/actions/pr-comment@main + uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1 with: # yamllint disable rule:line-length message: | diff --git a/.github/workflows/cmake-format-check.yaml b/.github/workflows/cmake-format-check.yaml index fa692c0e..6dc44e84 100644 --- a/.github/workflows/cmake-format-check.yaml +++ b/.github/workflows/cmake-format-check.yaml @@ -47,82 +47,35 @@ env: github.event.repository.name) }} jobs: - pre-check: + setup: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.prepare.outputs.is_act }} - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} - base_sha: ${{ steps.prepare.outputs.base_sha }} - pr_number: ${{ steps.prepare.outputs.pr_number }} + 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 }} + has_changes: ${{ steps.setup.outputs.has_changes }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main + - 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 }} - - detect-changes: - needs: pre-check - if: > - github.event_name != 'workflow_dispatch' && ( - github.event_name != 'workflow_call' || - (inputs.skip-relevance-check != 'true' && github.event.inputs == null && github.event.comment == null) - ) && needs.pre-check.outputs.is_act != 'true' - runs-on: ubuntu-latest - permissions: - contents: read - packages: read - outputs: - has_changes: ${{ steps.filter.outputs.matched }} - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - path: ${{ env.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} - - - name: Detect relevant changes - id: filter - uses: Framework-R-D/phlex/.github/actions/detect-relevant-changes@main - with: - repo-path: ${{ env.local_checkout_path }} - base-ref: ${{ needs.pre-check.outputs.base_sha }} - head-ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || needs.pre-check.outputs.ref }} file-type: cmake - - name: Report detection outcome - run: | - if [ "${{ steps.filter.outputs.matched }}" != "true" ]; then - echo "::notice::No CMake-related changes detected; formatting check will be skipped." - else - echo "::group::CMake-related files" - printf '%s\n' "${{ steps.filter.outputs.matched_files }}" - echo "::endgroup::" - fi - cmake-format-check: - needs: [pre-check, detect-changes] + needs: setup if: > - always() && ( - needs.detect-changes.result == 'skipped' || - ( - needs.detect-changes.result == 'success' && - needs.detect-changes.outputs.has_changes == 'true' - ) - ) + always() && needs.setup.outputs.has_changes == 'true' runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - ref: ${{ needs.pre-check.outputs.ref }} + ref: ${{ needs.setup.outputs.ref }} path: ${{ env.local_checkout_path }} - repository: ${{ needs.pre-check.outputs.repo }} + repository: ${{ needs.setup.outputs.repo }} - name: Set up Python uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 @@ -151,16 +104,3 @@ jobs: exit 1 fi # yamllint enable - - cmake-format-check-skipped: - needs: [pre-check, detect-changes] - if: > - needs.pre-check.result == 'success' && github.event_name != 'workflow_dispatch' && ( - github.event_name != 'workflow_call' || - (inputs.skip-relevance-check != 'true' && github.event.inputs == null && github.event.comment == null) - ) && needs.pre-check.outputs.is_act != 'true' && (needs.detect-changes.result == 'success' && - needs.detect-changes.outputs.has_changes != 'true') - runs-on: ubuntu-latest - steps: - - name: No relevant CMake changes detected - run: echo "::notice::No CMake-related changes detected; cmake-format check skipped." diff --git a/.github/workflows/cmake-format-fix.yaml b/.github/workflows/cmake-format-fix.yaml index 402bd84d..6ec6be80 100644 --- a/.github/workflows/cmake-format-fix.yaml +++ b/.github/workflows/cmake-format-fix.yaml @@ -57,34 +57,36 @@ env: local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} jobs: - pre-check: + setup: runs-on: ubuntu-latest name: Parse command if: > - github.event_name == 'workflow_dispatch' || inputs.ref != '' || ( + inputs.ref != '' || + github.event_name == 'workflow_dispatch' || ( 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 cmake-fix', github.event.repository.name)) ) - # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. - # This covers repo owners, invited collaborators, and all org members. outputs: - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} + ref: ${{ steps.setup.outputs.ref }} + repo: ${{ steps.setup.outputs.repo }} + checkout_path: ${{ steps.setup.outputs.checkout_path }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: + mode: fix ref: ${{ inputs.ref }} repo: ${{ inputs.repo }} + checkout-path: ${{ inputs.checkout-path }} apply_cmake_formatting: runs-on: ubuntu-latest name: Apply CMake formatting - needs: pre-check - if: needs.pre-check.result == 'success' + needs: setup + if: needs.setup.result == 'success' outputs: changes: ${{ steps.handle_commit.outputs.changes }} pushed: ${{ steps.handle_commit.outputs.pushed }} @@ -95,9 +97,9 @@ jobs: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - path: ${{ env.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} + path: ${{ needs.setup.outputs.checkout_path }} + ref: ${{ needs.setup.outputs.ref }} + repository: ${{ needs.setup.outputs.repo }} token: ${{ secrets.WORKFLOW_PAT }} - name: Set up Python @@ -118,10 +120,10 @@ jobs: uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main with: tool: cmake-format - working-directory: ${{ env.local_checkout_path }} + working-directory: ${{ needs.setup.outputs.checkout_path }} token: ${{ secrets.WORKFLOW_PAT }} - pr-info-ref: ${{ needs.pre-check.outputs.ref }} - pr-info-repo: ${{ needs.pre-check.outputs.repo }} + pr-info-ref: ${{ needs.setup.outputs.ref }} + pr-info-repo: ${{ needs.setup.outputs.repo }} skip-comment: ${{ inputs.skip-comment || 'false' }} - name: Update PR comment reactions diff --git a/.github/workflows/codeql-analysis.yaml b/.github/workflows/codeql-analysis.yaml index 6160dbc8..82e3b48c 100644 --- a/.github/workflows/codeql-analysis.yaml +++ b/.github/workflows/codeql-analysis.yaml @@ -66,166 +66,87 @@ env: CPP_COMPILER: g++ jobs: - pre-check: + setup: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.prepare.outputs.is_act }} - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} - base_sha: ${{ steps.prepare.outputs.base_sha }} - pr_number: ${{ steps.prepare.outputs.pr_number }} + 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 }} skip_detection: ${{ steps.should_skip.outputs.skip }} - local_checkout_path: ${{ steps.path.outputs.path }} + has_changes_cpp: ${{ steps.detect_cpp.outputs.has_changes }} + has_changes_python: ${{ steps.detect_python.outputs.has_changes }} + has_changes_actions: ${{ steps.detect_actions.outputs.has_changes }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main + - 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 }} - - - name: Resolve checkout path - id: path - shell: bash - run: | - CHECKOUT_PATH="${{ (github.event_name == 'workflow_call' && inputs.checkout-path) || format('{0}-src', github.event.repository.name) }}" - echo "path=$CHECKOUT_PATH" >> "$GITHUB_OUTPUT" + checkout-path: ${{ inputs.checkout-path }} - name: Determine if detection should be skipped id: should_skip run: | - # Skip detection for scheduled runs, workflow_dispatch, or workflow_call with language-matrix override if [ "${{ github.event_name }}" = "schedule" ] || \ [ "${{ github.event_name }}" = "workflow_dispatch" ] || \ [ "${{ github.event_name }}" = "push" ] || \ { [ "${{ github.event_name }}" = "workflow_call" ] && [ -n "${{ inputs.language-matrix }}" ]; } || \ - [ "${{ steps.prepare.outputs.is_act }}" = "true" ]; then + [ "${{ steps.setup.outputs.is_act }}" = "true" ]; then echo "skip=true" >> "$GITHUB_OUTPUT" else echo "skip=false" >> "$GITHUB_OUTPUT" fi - detect-changes-cpp: - needs: pre-check - if: > - needs.pre-check.result == 'success' && needs.pre-check.outputs.skip_detection != 'true' - runs-on: ubuntu-latest - permissions: - contents: read - outputs: - has_changes: ${{ steps.filter.outputs.matched }} - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - path: ${{ needs.pre-check.outputs.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} - - - name: Detect C++ relevant changes - id: filter - uses: Framework-R-D/phlex/.github/actions/detect-relevant-changes@main + - name: Detect C++ changes + id: detect_cpp + if: steps.should_skip.outputs.skip != 'true' + uses: Framework-R-D/phlex/.github/actions/run-change-detection@main with: - repo-path: ${{ needs.pre-check.outputs.local_checkout_path }} - base-ref: ${{ needs.pre-check.outputs.base_sha }} - head-ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || needs.pre-check.outputs.ref }} + checkout-path: ${{ steps.setup.outputs.checkout_path }} + ref: ${{ steps.setup.outputs.ref }} + repo: ${{ steps.setup.outputs.repo }} + base-ref: ${{ steps.setup.outputs.base_sha }} + head-ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || steps.setup.outputs.ref }} file-type: | cpp cmake - - name: Report detection outcome - run: | - if [ "${{ steps.filter.outputs.matched }}" != "true" ]; then - echo "::notice::No C++ relevant changes detected; C++ CodeQL scan will be skipped." - else - echo "::group::C++ CodeQL relevant files" - printf '%s\n' "${{ steps.filter.outputs.matched_files }}" - echo "::endgroup::" - fi - - detect-changes-python: - needs: pre-check - if: > - needs.pre-check.result == 'success' && needs.pre-check.outputs.skip_detection != 'true' - runs-on: ubuntu-latest - permissions: - contents: read - outputs: - has_changes: ${{ steps.filter.outputs.matched }} - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - path: ${{ needs.pre-check.outputs.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} - - - name: Detect Python relevant changes - id: filter - uses: Framework-R-D/phlex/.github/actions/detect-relevant-changes@main + - name: Detect Python changes + id: detect_python + if: steps.should_skip.outputs.skip != 'true' + uses: Framework-R-D/phlex/.github/actions/run-change-detection@main with: - repo-path: ${{ needs.pre-check.outputs.local_checkout_path }} - base-ref: ${{ needs.pre-check.outputs.base_sha }} - head-ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || needs.pre-check.outputs.ref }} + checkout-path: ${{ steps.setup.outputs.checkout_path }} + ref: ${{ steps.setup.outputs.ref }} + repo: ${{ steps.setup.outputs.repo }} + base-ref: ${{ steps.setup.outputs.base_sha }} + head-ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || steps.setup.outputs.ref }} file-type: python - - name: Report detection outcome - run: | - if [ "${{ steps.filter.outputs.matched }}" != "true" ]; then - echo "::notice::No Python relevant changes detected; Python CodeQL scan will be skipped." - else - echo "::group::Python CodeQL relevant files" - printf '%s\n' "${{ steps.filter.outputs.matched_files }}" - echo "::endgroup::" - fi - - detect-changes-actions: - needs: pre-check - if: > - needs.pre-check.result == 'success' && needs.pre-check.outputs.skip_detection != 'true' - runs-on: ubuntu-latest - permissions: - contents: read - outputs: - has_changes: ${{ steps.filter.outputs.matched }} - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - path: ${{ needs.pre-check.outputs.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} - - - name: Detect Actions/workflow relevant changes - id: filter - uses: Framework-R-D/phlex/.github/actions/detect-relevant-changes@main + - name: Detect Actions changes + id: detect_actions + if: steps.should_skip.outputs.skip != 'true' + uses: Framework-R-D/phlex/.github/actions/run-change-detection@main with: - repo-path: ${{ needs.pre-check.outputs.local_checkout_path }} - base-ref: ${{ needs.pre-check.outputs.base_sha }} - head-ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || needs.pre-check.outputs.ref }} + checkout-path: ${{ steps.setup.outputs.checkout_path }} + ref: ${{ steps.setup.outputs.ref }} + repo: ${{ steps.setup.outputs.repo }} + base-ref: ${{ steps.setup.outputs.base_sha }} + head-ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || steps.setup.outputs.ref }} include-globs: | .github/workflows/*.yaml .github/workflows/*.yml .github/actions/**/action.yaml .github/actions/**/action.yml - - name: Report detection outcome - run: | - if [ "${{ steps.filter.outputs.matched }}" != "true" ]; then - echo "::notice::No Actions/workflow relevant changes detected; Actions CodeQL scan will be skipped." - else - echo "::group::Actions CodeQL relevant files" - printf '%s\n' "${{ steps.filter.outputs.matched_files }}" - echo "::endgroup::" - fi - determine-languages: - needs: [pre-check, detect-changes-cpp, detect-changes-python, detect-changes-actions] - if: always() && needs.pre-check.result == 'success' + needs: setup + if: always() && needs.setup.result == 'success' runs-on: ubuntu-latest outputs: languages: ${{ steps.build_matrix.outputs.languages }} @@ -236,7 +157,7 @@ jobs: LANGUAGE_MATRIX: ${{ inputs.language-matrix }} run: | # If detection was skipped, use all languages or the provided language-matrix - if [ "${{ needs.pre-check.outputs.skip_detection }}" = "true" ]; then + if [ "${{ needs.setup.outputs.skip_detection }}" = "true" ]; then if [ "${{ github.event_name }}" = "workflow_call" ] && [ -n "$LANGUAGE_MATRIX" ]; then # Validate that language-matrix is valid JSON if ! echo "$LANGUAGE_MATRIX" | python3 -c "import sys, json; json.load(sys.stdin)" 2>/dev/null; then @@ -252,16 +173,13 @@ jobs: # Build array based on detection results langs=() - if [ "${{ needs.detect-changes-cpp.result }}" = "success" ] && - [ "${{ needs.detect-changes-cpp.outputs.has_changes }}" = "true" ]; then + if [ "${{ needs.setup.outputs.has_changes_cpp }}" = "true" ]; then langs+=("cpp") fi - if [ "${{ needs.detect-changes-python.result }}" = "success" ] && - [ "${{ needs.detect-changes-python.outputs.has_changes }}" = "true" ]; then + if [ "${{ needs.setup.outputs.has_changes_python }}" = "true" ]; then langs+=("python") fi - if [ "${{ needs.detect-changes-actions.result }}" = "success" ] && - [ "${{ needs.detect-changes-actions.outputs.has_changes }}" = "true" ]; then + if [ "${{ needs.setup.outputs.has_changes_actions }}" = "true" ]; then langs+=("actions") fi @@ -281,7 +199,7 @@ jobs: fi codeql: - needs: [pre-check, determine-languages] + needs: [setup, determine-languages] if: > needs.determine-languages.result == 'success' && needs.determine-languages.outputs.languages != '[]' name: Analyze ${{ matrix.language }} with CodeQL @@ -289,7 +207,7 @@ jobs: container: image: ghcr.io/framework-r-d/phlex-ci:latest env: - local_checkout_path: ${{ needs.pre-check.outputs.local_checkout_path }} + local_checkout_path: ${{ needs.setup.outputs.checkout_path }} local_build_path: ${{ (github.event_name == 'workflow_call' && inputs.build-path) || format('{0}-build', github.event.repository.name) }} @@ -305,7 +223,7 @@ jobs: - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - ref: ${{ needs.pre-check.outputs.ref }} + ref: ${{ needs.setup.outputs.ref }} path: ${{ env.local_checkout_path }} fetch-depth: 0 diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index ccbb4ba1..2ec4b508 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -28,7 +28,7 @@ permissions: pull-requests: read jobs: - pre-check: + setup: if: > github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' || github.event_name == 'push' || ( @@ -37,71 +37,33 @@ jobs: contains(fromJSON('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association) && startsWith(github.event.comment.body, format('@{0}bot coverage', github.event.repository.name)) ) - # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. - # This covers repo owners, invited collaborators, and all org members. runs-on: ubuntu-latest outputs: - is_act: ${{ steps.prepare.outputs.is_act }} - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} - base_sha: ${{ steps.prepare.outputs.base_sha }} - pr_number: ${{ steps.prepare.outputs.pr_number }} + 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: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main - detect-changes: - needs: pre-check - if: > - needs.pre-check.result == 'success' && github.event_name != 'workflow_dispatch' && github.event_name != - 'issue_comment' && needs.pre-check.outputs.is_act != 'true' - runs-on: ubuntu-latest - permissions: - contents: read - packages: read - outputs: - has_changes: ${{ steps.filter.outputs.matched }} - steps: - - name: Check out source code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: - fetch-depth: 0 - path: phlex-src - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} - - - name: Detect relevant changes - id: filter - uses: Framework-R-D/phlex/.github/actions/detect-relevant-changes@main - with: - repo-path: phlex-src - base-ref: ${{ needs.pre-check.outputs.base_sha }} - head-ref: ${{ needs.pre-check.outputs.ref }} + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} + pr-base-sha: ${{ inputs.pr-base-sha }} file-type: | cpp cmake python - - name: Report detection outcome - run: | - if [ "${{ steps.filter.outputs.matched }}" != "true" ]; then - echo "::notice::No coverage relevant changes detected; workflow will be skipped." - else - echo "::group::Coverage relevant files" - printf '%s\n' "${{ steps.filter.outputs.matched_files }}" - echo "::endgroup::" - fi - coverage: - needs: [pre-check, detect-changes] + needs: setup if: > - always() && ( - needs.detect-changes.result == 'skipped' || - ( - needs.detect-changes.result == 'success' && - needs.detect-changes.outputs.has_changes == 'true' - ) - ) + always() && needs.setup.outputs.has_changes == 'true' runs-on: ubuntu-24.04 container: image: ghcr.io/framework-r-d/phlex-ci:latest @@ -135,12 +97,14 @@ jobs: - name: Check out source code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - ref: ${{ needs.pre-check.outputs.ref }} - path: phlex-src - repository: ${{ needs.pre-check.outputs.repo }} + ref: ${{ needs.setup.outputs.ref }} + path: ${{ needs.setup.outputs.checkout_path }} + repository: ${{ needs.setup.outputs.repo }} - 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 for coverage..." @@ -152,6 +116,8 @@ jobs: with: cpp-compiler: g++ preset: coverage-gcc + source-path: ${{ needs.setup.outputs.checkout_path }} + build-path: ${{ needs.setup.outputs.build_path }} enable-form: ${{ steps.coverage_options.outputs.enable_form }} form-root-storage: ${{ steps.coverage_options.outputs.enable_form }} @@ -162,6 +128,8 @@ jobs: with: cpp-compiler: clang++ preset: coverage-clang + source-path: ${{ needs.setup.outputs.checkout_path }} + build-path: ${{ needs.setup.outputs.build_path }} enable-form: ${{ steps.coverage_options.outputs.enable_form }} form-root-storage: ${{ steps.coverage_options.outputs.enable_form }} @@ -178,14 +146,16 @@ jobs: - name: Build with coverage instrumentation id: build uses: Framework-R-D/phlex/.github/actions/build-cmake@main + with: + build-path: ${{ needs.setup.outputs.build_path }} - name: Run tests with coverage run: | . /entrypoint.sh - cd "$GITHUB_WORKSPACE/phlex-build" + cd "$GITHUB_WORKSPACE/${{ needs.setup.outputs.build_path }}" echo "➡️ Running tests with coverage..." - PROFILE_ROOT="$GITHUB_WORKSPACE/phlex-build/test/profraw" + PROFILE_ROOT="$GITHUB_WORKSPACE/${{ needs.setup.outputs.build_path }}/test/profraw" echo "Cleaning LLVM profile directory: $PROFILE_ROOT" rm -rf "$PROFILE_ROOT" mkdir -p "$PROFILE_ROOT" @@ -207,7 +177,7 @@ jobs: shell: bash run: | . /entrypoint.sh - cd "$GITHUB_WORKSPACE/phlex-build" + cd "$GITHUB_WORKSPACE/${{ needs.setup.outputs.build_path }}" echo "➡️ Generating coverage reports for GCC..." echo "::group::Running coverage-gcov target" @@ -226,7 +196,7 @@ jobs: shell: bash run: | . /entrypoint.sh - cd "$GITHUB_WORKSPACE/phlex-build" + cd "$GITHUB_WORKSPACE/${{ needs.setup.outputs.build_path }}" echo "➡️ Generating coverage reports for Clang..." echo "::group::Running coverage-llvm target" @@ -245,7 +215,7 @@ jobs: shell: bash run: | . /entrypoint.sh - cd "$GITHUB_WORKSPACE/phlex-build" + cd "$GITHUB_WORKSPACE/${{ needs.setup.outputs.build_path }}" echo "➡️ Generating Python coverage report..." echo "::group::Running coverage-python target" @@ -269,7 +239,7 @@ jobs: if: ${{ steps.report_gcc.outcome != 'skipped' || steps.report_clang.outcome != 'skipped' }} shell: bash run: | - cd "$GITHUB_WORKSPACE/phlex-build" + cd "$GITHUB_WORKSPACE/${{ needs.setup.outputs.build_path }}" if [ -f coverage.xml ]; then echo "has_coverage_xml=true" >> "$GITHUB_OUTPUT" else @@ -305,7 +275,7 @@ jobs: ARTIFACT_DIR="$GITHUB_WORKSPACE/coverage-artifacts" rm -rf "$ARTIFACT_DIR" mkdir -p "$ARTIFACT_DIR" - cd "$GITHUB_WORKSPACE/phlex-build" + cd "$GITHUB_WORKSPACE/${{ needs.setup.outputs.build_path }}" for file in \ coverage-llvm.txt \ coverage-llvm.info \ @@ -426,16 +396,3 @@ jobs: path: coverage-artifacts/coverage-html/ if-no-files-found: warn retention-days: 30 - - coverage-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 coverage changes detected - run: echo "::notice::No relevant C++ changes detected; coverage workflow skipped." diff --git a/.github/workflows/format-all.yaml b/.github/workflows/format-all.yaml index 6f2702bd..8126aebc 100644 --- a/.github/workflows/format-all.yaml +++ b/.github/workflows/format-all.yaml @@ -11,191 +11,111 @@ permissions: contents: write jobs: - pre-check: + setup: runs-on: ubuntu-latest - name: Parse command if: > 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 format', github.event.repository.name)) outputs: - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} + ref: ${{ steps.setup.outputs.ref }} + repo: ${{ steps.setup.outputs.repo }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main + with: + mode: fix clang-format: - needs: pre-check - uses: Framework-R-D/phlex/.github/workflows/clang-format-fix.yaml@main + needs: setup + uses: ./.github/workflows/clang-format-fix.yaml with: - checkout-path: phlex-src - ref: ${{ needs.pre-check.outputs.ref }} - repo: ${{ needs.pre-check.outputs.repo }} + ref: ${{ needs.setup.outputs.ref }} + repo: ${{ needs.setup.outputs.repo }} skip-comment: "true" secrets: inherit cmake-format: - needs: pre-check - uses: Framework-R-D/phlex/.github/workflows/cmake-format-fix.yaml@main + needs: setup + uses: ./.github/workflows/cmake-format-fix.yaml with: - checkout-path: phlex-src - ref: ${{ needs.pre-check.outputs.ref }} - repo: ${{ needs.pre-check.outputs.repo }} + ref: ${{ needs.setup.outputs.ref }} + repo: ${{ needs.setup.outputs.repo }} skip-comment: "true" secrets: inherit header-guards: - needs: pre-check - uses: Framework-R-D/phlex/.github/workflows/header-guards-fix.yaml@main + needs: setup + uses: ./.github/workflows/header-guards-fix.yaml with: - checkout-path: phlex-src - ref: ${{ needs.pre-check.outputs.ref }} - repo: ${{ needs.pre-check.outputs.repo }} + ref: ${{ needs.setup.outputs.ref }} + repo: ${{ needs.setup.outputs.repo }} skip-comment: "true" secrets: inherit jsonnet-format: - needs: pre-check - uses: Framework-R-D/phlex/.github/workflows/jsonnet-format-fix.yaml@main + needs: setup + uses: ./.github/workflows/jsonnet-format-fix.yaml with: - checkout-path: phlex-src - ref: ${{ needs.pre-check.outputs.ref }} - repo: ${{ needs.pre-check.outputs.repo }} + ref: ${{ needs.setup.outputs.ref }} + repo: ${{ needs.setup.outputs.repo }} skip-comment: "true" secrets: inherit markdown: - needs: pre-check - uses: Framework-R-D/phlex/.github/workflows/markdown-fix.yaml@main + needs: setup + uses: ./.github/workflows/markdown-fix.yaml with: - checkout-path: phlex-src - ref: ${{ needs.pre-check.outputs.ref }} - repo: ${{ needs.pre-check.outputs.repo }} + ref: ${{ needs.setup.outputs.ref }} + repo: ${{ needs.setup.outputs.repo }} skip-comment: "true" secrets: inherit python: - needs: pre-check - uses: Framework-R-D/phlex/.github/workflows/python-fix.yaml@main + needs: setup + uses: ./.github/workflows/python-fix.yaml with: - checkout-path: phlex-src - ref: ${{ needs.pre-check.outputs.ref }} - repo: ${{ needs.pre-check.outputs.repo }} + ref: ${{ needs.setup.outputs.ref }} + repo: ${{ needs.setup.outputs.repo }} skip-comment: "true" secrets: inherit yaml: - needs: pre-check - uses: Framework-R-D/phlex/.github/workflows/yaml-fix.yaml@main + needs: setup + uses: ./.github/workflows/yaml-fix.yaml with: - checkout-path: phlex-src - ref: ${{ needs.pre-check.outputs.ref }} - repo: ${{ needs.pre-check.outputs.repo }} + ref: ${{ needs.setup.outputs.ref }} + repo: ${{ needs.setup.outputs.repo }} skip-comment: "true" secrets: inherit combine-results: - needs: [pre-check, clang-format, cmake-format, header-guards, jsonnet-format, markdown, python, yaml] - if: ${{ always() && needs.pre-check.result == 'success' }} + needs: [setup, clang-format, cmake-format, header-guards, jsonnet-format, markdown, python, yaml] + if: always() && needs.setup.result == 'success' runs-on: ubuntu-latest steps: - name: Collect results id: collect - shell: bash - run: | - messages=() - has_failures=false - - check_job() { - local name="$1" result="$2" changes="$3" pushed="$4" patch_name="$5" sha_short="$6" - if [ "$result" == "failure" ] || [ "$result" == "cancelled" ] || [ "$result" == "skipped" ]; then - messages+=("❌ $name workflow $result") - has_failures=true - elif [ "$changes" == "true" ]; then - if [ "$pushed" == "true" ]; then - messages+=("✅ $name fixes pushed (commit $sha_short)") - elif [ -n "$patch_name" ]; then - messages+=("⚠️ $name fixes available as a patch file (\`$patch_name\`) in the \"fix-patch\" artifact. Download the artifact from this workflow run, then run: \`git apply $patch_name\` from the repository root.") - fi - fi - } - - check_job "clang-format" \ - "${{ needs.clang-format.result }}" \ - "${{ needs.clang-format.outputs.changes }}" \ - "${{ needs.clang-format.outputs.pushed }}" \ - "${{ needs.clang-format.outputs.patch_name }}" \ - "${{ needs.clang-format.outputs.commit_sha_short }}" - - check_job "cmake-format" \ - "${{ needs.cmake-format.result }}" \ - "${{ needs.cmake-format.outputs.changes }}" \ - "${{ needs.cmake-format.outputs.pushed }}" \ - "${{ needs.cmake-format.outputs.patch_name }}" \ - "${{ needs.cmake-format.outputs.commit_sha_short }}" - - check_job "header-guards" \ - "${{ needs.header-guards.result }}" \ - "${{ needs.header-guards.outputs.changes }}" \ - "${{ needs.header-guards.outputs.pushed }}" \ - "${{ needs.header-guards.outputs.patch_name }}" \ - "${{ needs.header-guards.outputs.commit_sha_short }}" - - check_job "jsonnetfmt" \ - "${{ needs.jsonnet-format.result }}" \ - "${{ needs.jsonnet-format.outputs.changes }}" \ - "${{ needs.jsonnet-format.outputs.pushed }}" \ - "${{ needs.jsonnet-format.outputs.patch_name }}" \ - "${{ needs.jsonnet-format.outputs.commit_sha_short }}" - - check_job "markdownlint" \ - "${{ needs.markdown.result }}" \ - "${{ needs.markdown.outputs.changes }}" \ - "${{ needs.markdown.outputs.pushed }}" \ - "${{ needs.markdown.outputs.patch_name }}" \ - "${{ needs.markdown.outputs.commit_sha_short }}" - - check_job "ruff" \ - "${{ needs.python.result }}" \ - "${{ needs.python.outputs.changes }}" \ - "${{ needs.python.outputs.pushed }}" \ - "${{ needs.python.outputs.patch_name }}" \ - "${{ needs.python.outputs.commit_sha_short }}" - - check_job "YAML formatter" \ - "${{ needs.yaml.result }}" \ - "${{ needs.yaml.outputs.changes }}" \ - "${{ needs.yaml.outputs.pushed }}" \ - "${{ needs.yaml.outputs.patch_name }}" \ - "${{ needs.yaml.outputs.commit_sha_short }}" - - if [ ${#messages[@]} -eq 0 ]; then - echo "message=No automatic format fixes were necessary." >> "$GITHUB_OUTPUT" - else + uses: Framework-R-D/phlex/.github/actions/collect-format-results@main + with: + results-json: | { - echo "message<> "$GITHUB_OUTPUT" - fi - - if [ "$has_failures" == "true" ]; then - exit 1 - fi + "clang-format": { "result": "${{ needs.clang-format.result }}", "changes": "${{ needs.clang-format.outputs.changes }}", "pushed": "${{ needs.clang-format.outputs.pushed }}", "sha": "${{ needs.clang-format.outputs.commit_sha_short }}", "patch_name": "${{ needs.clang-format.outputs.patch_name }}" }, + "cmake-format": { "result": "${{ needs.cmake-format.result }}", "changes": "${{ needs.cmake-format.outputs.changes }}", "pushed": "${{ needs.cmake-format.outputs.pushed }}", "sha": "${{ needs.cmake-format.outputs.commit_sha_short }}", "patch_name": "${{ needs.cmake-format.outputs.patch_name }}" }, + "header-guards": { "result": "${{ needs.header-guards.result }}", "changes": "${{ needs.header-guards.outputs.changes }}", "pushed": "${{ needs.header-guards.outputs.pushed }}", "sha": "${{ needs.header-guards.outputs.commit_sha_short }}", "patch_name": "${{ needs.header-guards.outputs.patch_name }}" }, + "jsonnetfmt": { "result": "${{ needs.jsonnet-format.result }}", "changes": "${{ needs.jsonnet-format.outputs.changes }}", "pushed": "${{ needs.jsonnet-format.outputs.pushed }}", "sha": "${{ needs.jsonnet-format.outputs.commit_sha_short }}", "patch_name": "${{ needs.jsonnet-format.outputs.patch_name }}" }, + "markdownlint": { "result": "${{ needs.markdown.result }}", "changes": "${{ needs.markdown.outputs.changes }}", "pushed": "${{ needs.markdown.outputs.pushed }}", "sha": "${{ needs.markdown.outputs.commit_sha_short }}", "patch_name": "${{ needs.markdown.outputs.patch_name }}" }, + "ruff": { "result": "${{ needs.python.result }}", "changes": "${{ needs.python.outputs.changes }}", "pushed": "${{ needs.python.outputs.pushed }}", "sha": "${{ needs.python.outputs.commit_sha_short }}", "patch_name": "${{ needs.python.outputs.patch_name }}" }, + "YAML formatter": { "result": "${{ needs.yaml.result }}", "changes": "${{ needs.yaml.outputs.changes }}", "pushed": "${{ needs.yaml.outputs.pushed }}", "sha": "${{ needs.yaml.outputs.commit_sha_short }}", "patch_name": "${{ needs.yaml.outputs.patch_name }}" } + } - name: Post combined comment - if: always() uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1 with: message: ${{ steps.collect.outputs.message }} - name: Update PR comment reactions - if: always() uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main with: - status: ${{ job.status }} + status: ${{ steps.collect.outputs.has_failures == 'true' && 'failure' || 'success' }} diff --git a/.github/workflows/header-guards-check.yaml b/.github/workflows/header-guards-check.yaml index 6a07ace1..b784b991 100644 --- a/.github/workflows/header-guards-check.yaml +++ b/.github/workflows/header-guards-check.yaml @@ -47,70 +47,27 @@ env: github.event.repository.name) }} jobs: - pre-check: + setup: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.prepare.outputs.is_act }} - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} - base_sha: ${{ steps.prepare.outputs.base_sha }} - pr_number: ${{ steps.prepare.outputs.pr_number }} + 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 }} + has_changes: ${{ steps.setup.outputs.has_changes }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main - - detect-changes: - needs: pre-check - if: > - needs.pre-check.result == 'success' && github.event_name != 'workflow_dispatch' && ( - github.event_name != 'workflow_call' || - (inputs.skip-relevance-check != 'true' && github.event.inputs == null && github.event.comment == null) - ) && needs.pre-check.outputs.is_act != 'true' - runs-on: ubuntu-latest - permissions: - contents: read - packages: read - outputs: - has_changes: ${{ steps.filter.outputs.matched }} - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: - fetch-depth: 0 - path: ${{ env.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} - - - name: Detect relevant changes - id: filter - uses: Framework-R-D/phlex/.github/actions/detect-relevant-changes@main - with: - repo-path: ${{ env.local_checkout_path }} - base-ref: ${{ needs.pre-check.outputs.base_sha }} - head-ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || needs.pre-check.outputs.ref }} file-type: cpp - - name: Report detection outcome - run: | - if [ "${{ steps.filter.outputs.matched }}" != "true" ]; then - echo "::notice::No header file changes detected; check will be skipped." - else - echo "::group::Header files" - printf '%s\n' "${{ steps.filter.outputs.matched_files }}" - echo "::endgroup::" - fi - header-guards-check: - needs: [pre-check, detect-changes] + needs: setup if: > - always() && ( - needs.detect-changes.result == 'skipped' || - ( - needs.detect-changes.result == 'success' && - needs.detect-changes.outputs.has_changes == 'true' - ) - ) + always() && needs.setup.outputs.has_changes == 'true' runs-on: ubuntu-latest permissions: contents: read @@ -119,9 +76,9 @@ jobs: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - ref: ${{ needs.pre-check.outputs.ref }} + ref: ${{ needs.setup.outputs.ref }} path: ${{ env.local_checkout_path }} - repository: ${{ needs.pre-check.outputs.repo }} + repository: ${{ needs.setup.outputs.repo }} - name: Set up Python uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 @@ -141,19 +98,3 @@ jobs: echo "::error::Header guard check failed." echo "::error::Comment '@${{ github.event.repository.name }}bot header-guards-fix' on the PR to auto-fix." exit 1 - - header-guards-check-skipped: - needs: [pre-check, detect-changes] - if: > - needs.pre-check.result == 'success' && github.event_name != 'workflow_dispatch' && ( - github.event_name != 'workflow_call' || - (inputs.skip-relevance-check != 'true' && github.event.inputs == null && github.event.comment == null) - ) && 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 header changes detected - run: echo "::notice::No header file changes detected; header-guards-check skipped." diff --git a/.github/workflows/header-guards-fix.yaml b/.github/workflows/header-guards-fix.yaml index ae09c2ce..95356ab6 100644 --- a/.github/workflows/header-guards-fix.yaml +++ b/.github/workflows/header-guards-fix.yaml @@ -57,34 +57,36 @@ env: local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} jobs: - pre-check: + setup: runs-on: ubuntu-latest name: Parse command if: > - github.event_name == 'workflow_dispatch' || inputs.ref != '' || ( + inputs.ref != '' || + github.event_name == 'workflow_dispatch' || ( 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 header-guards-fix', github.event.repository.name)) ) - # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. - # This covers repo owners, invited collaborators, and all org members. outputs: - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} + ref: ${{ steps.setup.outputs.ref }} + repo: ${{ steps.setup.outputs.repo }} + checkout_path: ${{ steps.setup.outputs.checkout_path }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: + mode: fix ref: ${{ inputs.ref }} repo: ${{ inputs.repo }} + checkout-path: ${{ inputs.checkout-path }} apply_fixes: runs-on: ubuntu-latest name: Apply fixes - needs: pre-check - if: needs.pre-check.result == 'success' + needs: setup + if: needs.setup.result == 'success' outputs: changes: ${{ steps.handle_commit.outputs.changes }} pushed: ${{ steps.handle_commit.outputs.pushed }} @@ -95,9 +97,9 @@ jobs: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - path: ${{ env.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} + path: ${{ needs.setup.outputs.checkout_path }} + ref: ${{ needs.setup.outputs.ref }} + repository: ${{ needs.setup.outputs.repo }} token: ${{ secrets.WORKFLOW_PAT }} - name: Set up Python @@ -106,7 +108,7 @@ jobs: python-version: "3.12" - name: Fix header guards - working-directory: ${{ env.local_checkout_path }} + working-directory: ${{ needs.setup.outputs.checkout_path }} run: | echo "Fixing header guards..." python3 scripts/fix_header_guards.py --root . phlex plugins form || true @@ -116,10 +118,10 @@ jobs: uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main with: tool: header-guards - working-directory: ${{ env.local_checkout_path }} + working-directory: ${{ needs.setup.outputs.checkout_path }} token: ${{ secrets.WORKFLOW_PAT }} - pr-info-ref: ${{ needs.pre-check.outputs.ref }} - pr-info-repo: ${{ needs.pre-check.outputs.repo }} + pr-info-ref: ${{ needs.setup.outputs.ref }} + pr-info-repo: ${{ needs.setup.outputs.repo }} skip-comment: ${{ inputs.skip-comment || 'false' }} - name: Update PR comment reactions diff --git a/.github/workflows/jsonnet-format-check.yaml b/.github/workflows/jsonnet-format-check.yaml index a76b9900..df3f3ebd 100644 --- a/.github/workflows/jsonnet-format-check.yaml +++ b/.github/workflows/jsonnet-format-check.yaml @@ -47,70 +47,27 @@ env: github.event.repository.name) }} jobs: - pre-check: + setup: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.prepare.outputs.is_act }} - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} - base_sha: ${{ steps.prepare.outputs.base_sha }} - pr_number: ${{ steps.prepare.outputs.pr_number }} + 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 }} + has_changes: ${{ steps.setup.outputs.has_changes }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main - - detect-changes: - needs: pre-check - if: > - needs.pre-check.result == 'success' && github.event_name != 'workflow_dispatch' && ( - github.event_name != 'workflow_call' || - (inputs.skip-relevance-check != 'true' && github.event.inputs == null && github.event.comment == null) - ) && needs.pre-check.outputs.is_act != 'true' - runs-on: ubuntu-latest - permissions: - contents: read - packages: read - outputs: - has_changes: ${{ steps.filter.outputs.matched }} - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - path: ${{ env.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} - - - name: Detect relevant changes - id: filter - uses: Framework-R-D/phlex/.github/actions/detect-relevant-changes@main + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: - repo-path: ${{ env.local_checkout_path }} - base-ref: ${{ needs.pre-check.outputs.base_sha }} - head-ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || needs.pre-check.outputs.ref }} file-type: jsonnet - - name: Report detection outcome - run: | - if [ "${{ steps.filter.outputs.matched }}" != "true" ]; then - echo "::notice::No Jsonnet-related changes detected; formatting check will be skipped." - else - echo "::group::Jsonnet-related files" - printf '%s\n' "${{ steps.filter.outputs.matched_files }}" - echo "::endgroup::" - fi - jsonnet-format-check: - needs: [pre-check, detect-changes] + needs: setup if: > - always() && ( - needs.detect-changes.result == 'skipped' || - ( - needs.detect-changes.result == 'success' && - needs.detect-changes.outputs.has_changes == 'true' - ) - ) + always() && needs.setup.outputs.has_changes == 'true' runs-on: ubuntu-latest container: image: public.ecr.aws/bitnami/jsonnet:latest @@ -119,8 +76,8 @@ jobs: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} + ref: ${{ needs.setup.outputs.ref }} + repository: ${{ needs.setup.outputs.repo }} path: ${{ env.local_checkout_path }} - name: Check Jsonnet formatting @@ -143,16 +100,3 @@ jobs: exit 1 fi # yamllint enable - - jsonnet-format-check-skipped: - needs: [pre-check, detect-changes] - if: > - needs.pre-check.result == 'success' && github.event_name != 'workflow_dispatch' && ( - github.event_name != 'workflow_call' || - (inputs.skip-relevance-check != 'true' && github.event.inputs == null && github.event.comment == null) - ) && needs.pre-check.outputs.is_act != 'true' && (needs.detect-changes.result == 'success' && - needs.detect-changes.outputs.has_changes != 'true') - runs-on: ubuntu-latest - steps: - - name: No relevant Jsonnet changes detected - run: echo "::notice::No Jsonnet-related changes detected; jsonnet-format check skipped." diff --git a/.github/workflows/jsonnet-format-fix.yaml b/.github/workflows/jsonnet-format-fix.yaml index 8360f114..fa66ca5c 100644 --- a/.github/workflows/jsonnet-format-fix.yaml +++ b/.github/workflows/jsonnet-format-fix.yaml @@ -57,34 +57,36 @@ env: local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} jobs: - pre-check: + setup: runs-on: ubuntu-latest name: Parse command if: > - github.event_name == 'workflow_dispatch' || inputs.ref != '' || ( + inputs.ref != '' || + github.event_name == 'workflow_dispatch' || ( 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 jsonnet-fix', github.event.repository.name)) ) - # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. - # This covers repo owners, invited collaborators, and all org members. outputs: - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} + ref: ${{ steps.setup.outputs.ref }} + repo: ${{ steps.setup.outputs.repo }} + checkout_path: ${{ steps.setup.outputs.checkout_path }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: + mode: fix ref: ${{ inputs.ref }} repo: ${{ inputs.repo }} + checkout-path: ${{ inputs.checkout-path }} apply_jsonnet_formatting: runs-on: ubuntu-latest name: Apply Jsonnet formatting - needs: pre-check - if: needs.pre-check.result == 'success' + needs: setup + if: needs.setup.result == 'success' outputs: changes: ${{ steps.handle_commit.outputs.changes }} pushed: ${{ steps.handle_commit.outputs.pushed }} @@ -96,9 +98,9 @@ jobs: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - path: ${{ env.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} + path: ${{ needs.setup.outputs.checkout_path }} + ref: ${{ needs.setup.outputs.ref }} + repository: ${{ needs.setup.outputs.repo }} token: ${{ secrets.WORKFLOW_PAT }} - name: Apply Jsonnet formatting @@ -117,10 +119,10 @@ jobs: uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main with: tool: jsonnetfmt - working-directory: ${{ env.local_checkout_path }} + working-directory: ${{ needs.setup.outputs.checkout_path }} token: ${{ secrets.WORKFLOW_PAT }} - pr-info-ref: ${{ needs.pre-check.outputs.ref }} - pr-info-repo: ${{ needs.pre-check.outputs.repo }} + pr-info-ref: ${{ needs.setup.outputs.ref }} + pr-info-repo: ${{ needs.setup.outputs.repo }} skip-comment: ${{ inputs.skip-comment || 'false' }} - name: Update PR comment reactions diff --git a/.github/workflows/markdown-check.yaml b/.github/workflows/markdown-check.yaml index 35802c08..d39fdd5e 100644 --- a/.github/workflows/markdown-check.yaml +++ b/.github/workflows/markdown-check.yaml @@ -47,70 +47,27 @@ env: github.event.repository.name) }} jobs: - pre-check: + setup: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.prepare.outputs.is_act }} - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} - base_sha: ${{ steps.prepare.outputs.base_sha }} - pr_number: ${{ steps.prepare.outputs.pr_number }} + 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 }} + has_changes: ${{ steps.setup.outputs.has_changes }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main - - detect-changes: - needs: pre-check - if: > - needs.pre-check.result == 'success' && github.event_name != 'workflow_dispatch' && ( - github.event_name != 'workflow_call' || - (inputs.skip-relevance-check != 'true' && github.event.inputs == null && github.event.comment == null) - ) && needs.pre-check.outputs.is_act != 'true' - runs-on: ubuntu-latest - permissions: - contents: read - packages: read - outputs: - has_changes: ${{ steps.filter.outputs.matched }} - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - path: ${{ env.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} - - - name: Detect relevant changes - id: filter - uses: Framework-R-D/phlex/.github/actions/detect-relevant-changes@main + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: - repo-path: ${{ env.local_checkout_path }} - base-ref: ${{ needs.pre-check.outputs.base_sha }} - head-ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || needs.pre-check.outputs.ref }} file-type: md - - name: Report detection outcome - run: | - if [ "${{ steps.filter.outputs.matched }}" != "true" ]; then - echo "::notice::No Markdown-related changes detected; formatting check will be skipped." - else - echo "::group::Markdown-related files" - printf '%s\n' "${{ steps.filter.outputs.matched_files }}" - echo "::endgroup::" - fi - markdown-check: - needs: [pre-check, detect-changes] + needs: setup if: > - always() && ( - needs.detect-changes.result == 'skipped' || - ( - needs.detect-changes.result == 'success' && - needs.detect-changes.outputs.has_changes == 'true' - ) - ) + always() && needs.setup.outputs.has_changes == 'true' runs-on: ubuntu-latest permissions: contents: read @@ -119,9 +76,9 @@ jobs: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - ref: ${{ needs.pre-check.outputs.ref }} + ref: ${{ needs.setup.outputs.ref }} path: ${{ env.local_checkout_path }} - repository: ${{ needs.pre-check.outputs.repo }} + repository: ${{ needs.setup.outputs.repo }} - name: Add problem matcher uses: xt0rted/markdownlint-problem-matcher@1a5fabfb577370cfdf5af944d418e4be3ea06f27 # v3.0.0 @@ -147,19 +104,3 @@ jobs: exit 1 fi # yamllint enable - - markdown-check-skipped: - needs: [pre-check, detect-changes] - if: > - needs.pre-check.result == 'success' && github.event_name != 'workflow_dispatch' && ( - github.event_name != 'workflow_call' || - (inputs.skip-relevance-check != 'true' && github.event.inputs == null && github.event.comment == null) - ) && 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 Markdown changes detected - run: echo "::notice::No Markdown-related changes detected; markdown-check skipped." diff --git a/.github/workflows/markdown-fix.yaml b/.github/workflows/markdown-fix.yaml index f6a9c6ac..cb082462 100644 --- a/.github/workflows/markdown-fix.yaml +++ b/.github/workflows/markdown-fix.yaml @@ -57,34 +57,36 @@ env: local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} jobs: - pre-check: + setup: runs-on: ubuntu-latest name: Parse command if: > - github.event_name == 'workflow_dispatch' || inputs.ref != '' || ( + inputs.ref != '' || + github.event_name == 'workflow_dispatch' || ( 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 markdown-fix', github.event.repository.name)) ) - # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. - # This covers repo owners, invited collaborators, and all org members. outputs: - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} + ref: ${{ steps.setup.outputs.ref }} + repo: ${{ steps.setup.outputs.repo }} + checkout_path: ${{ steps.setup.outputs.checkout_path }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: + mode: fix ref: ${{ inputs.ref }} repo: ${{ inputs.repo }} + checkout-path: ${{ inputs.checkout-path }} apply_fixes: runs-on: ubuntu-latest name: Apply fixes - needs: pre-check - if: needs.pre-check.result == 'success' + needs: setup + if: needs.setup.result == 'success' outputs: changes: ${{ steps.handle_commit.outputs.changes }} pushed: ${{ steps.handle_commit.outputs.pushed }} @@ -95,9 +97,9 @@ jobs: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - path: ${{ env.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} + path: ${{ needs.setup.outputs.checkout_path }} + ref: ${{ needs.setup.outputs.ref }} + repository: ${{ needs.setup.outputs.repo }} token: ${{ secrets.WORKFLOW_PAT }} - name: Set up Node.js @@ -109,7 +111,7 @@ jobs: run: npm install -g markdownlint-cli2 - name: Run markdownlint-cli2 fix - working-directory: ${{ env.local_checkout_path }} + working-directory: ${{ needs.setup.outputs.checkout_path }} run: | echo "Fixing Markdown format with markdownlint-cli2..." markdownlint-cli2 --fix "**/*.md" "!**/CHANGELOG.md" || true @@ -119,10 +121,10 @@ jobs: uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main with: tool: markdownlint - working-directory: ${{ env.local_checkout_path }} + working-directory: ${{ needs.setup.outputs.checkout_path }} token: ${{ secrets.WORKFLOW_PAT }} - pr-info-ref: ${{ needs.pre-check.outputs.ref }} - pr-info-repo: ${{ needs.pre-check.outputs.repo }} + pr-info-ref: ${{ needs.setup.outputs.ref }} + pr-info-repo: ${{ needs.setup.outputs.repo }} skip-comment: ${{ inputs.skip-comment || 'false' }} - name: Update PR comment reactions diff --git a/.github/workflows/python-check.yaml b/.github/workflows/python-check.yaml index fb76fe08..503bf880 100644 --- a/.github/workflows/python-check.yaml +++ b/.github/workflows/python-check.yaml @@ -47,70 +47,27 @@ env: github.event.repository.name) }} jobs: - pre-check: + setup: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.prepare.outputs.is_act }} - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} - base_sha: ${{ steps.prepare.outputs.base_sha }} - pr_number: ${{ steps.prepare.outputs.pr_number }} + 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 }} + has_changes: ${{ steps.setup.outputs.has_changes }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main - - detect-changes: - needs: pre-check - if: > - needs.pre-check.result == 'success' && github.event_name != 'workflow_dispatch' && ( - github.event_name != 'workflow_call' || - (inputs.skip-relevance-check != 'true' && github.event.inputs == null && github.event.comment == null) - ) && needs.pre-check.outputs.is_act != 'true' - runs-on: ubuntu-latest - permissions: - contents: read - packages: read - outputs: - has_changes: ${{ steps.filter.outputs.matched }} - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - path: ${{ env.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} - - - name: Detect relevant changes - id: filter - uses: Framework-R-D/phlex/.github/actions/detect-relevant-changes@main + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: - repo-path: ${{ env.local_checkout_path }} - base-ref: ${{ needs.pre-check.outputs.base_sha }} - head-ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || needs.pre-check.outputs.ref }} file-type: python - - name: Report detection outcome - run: | - if [ "${{ steps.filter.outputs.matched }}" != "true" ]; then - echo "::notice::No python check relevant changes detected; job will be skipped." - else - echo "::group::Python check relevant files" - printf '%s\n' "${{ steps.filter.outputs.matched_files }}" - echo "::endgroup::" - fi - python-check: - needs: [pre-check, detect-changes] + needs: setup if: > - always() && ( - needs.detect-changes.result == 'skipped' || - ( - needs.detect-changes.result == 'success' && - needs.detect-changes.outputs.has_changes == 'true' - ) - ) + always() && needs.setup.outputs.has_changes == 'true' runs-on: ubuntu-latest permissions: contents: read @@ -119,9 +76,9 @@ jobs: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - ref: ${{ needs.pre-check.outputs.ref }} + ref: ${{ needs.setup.outputs.ref }} path: ${{ env.local_checkout_path }} - repository: ${{ needs.pre-check.outputs.repo }} + repository: ${{ needs.setup.outputs.repo }} - name: Set up Python uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 @@ -161,19 +118,3 @@ jobs: exit 1 fi # yamllint enable - - python-check-skipped: - needs: [pre-check, detect-changes] - if: > - needs.pre-check.result == 'success' && github.event_name != 'workflow_dispatch' && ( - github.event_name != 'workflow_call' || - (inputs.skip-relevance-check != 'true' && github.event.inputs == null && github.event.comment == null) - ) && 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 Python changes detected - run: echo "No Python relevant changes detected; check skipped." diff --git a/.github/workflows/python-fix.yaml b/.github/workflows/python-fix.yaml index b63efa2d..f3ca535c 100644 --- a/.github/workflows/python-fix.yaml +++ b/.github/workflows/python-fix.yaml @@ -57,34 +57,36 @@ env: local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} jobs: - pre-check: + setup: runs-on: ubuntu-latest name: Parse command if: > - github.event_name == 'workflow_dispatch' || inputs.ref != '' || ( + inputs.ref != '' || + github.event_name == 'workflow_dispatch' || ( 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 python-fix', github.event.repository.name)) ) - # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. - # This covers repo owners, invited collaborators, and all org members. outputs: - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} + ref: ${{ steps.setup.outputs.ref }} + repo: ${{ steps.setup.outputs.repo }} + checkout_path: ${{ steps.setup.outputs.checkout_path }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: + mode: fix ref: ${{ inputs.ref }} repo: ${{ inputs.repo }} + checkout-path: ${{ inputs.checkout-path }} apply_fixes: runs-on: ubuntu-latest name: Apply fixes - needs: pre-check - if: needs.pre-check.result == 'success' + needs: setup + if: needs.setup.result == 'success' outputs: changes: ${{ steps.handle_commit.outputs.changes }} pushed: ${{ steps.handle_commit.outputs.pushed }} @@ -94,9 +96,9 @@ jobs: steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - path: ${{ env.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} + path: ${{ needs.setup.outputs.checkout_path }} + ref: ${{ needs.setup.outputs.ref }} + repository: ${{ needs.setup.outputs.repo }} token: ${{ secrets.WORKFLOW_PAT }} - name: Set up Python @@ -109,7 +111,7 @@ jobs: pip install ruff - name: Run ruff format and fix - working-directory: ${{ env.local_checkout_path }} + working-directory: ${{ needs.setup.outputs.checkout_path }} env: FORCE_COLOR: 1 run: | @@ -123,10 +125,10 @@ jobs: uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main with: tool: ruff - working-directory: ${{ env.local_checkout_path }} + working-directory: ${{ needs.setup.outputs.checkout_path }} token: ${{ secrets.WORKFLOW_PAT }} - pr-info-ref: ${{ needs.pre-check.outputs.ref }} - pr-info-repo: ${{ needs.pre-check.outputs.repo }} + pr-info-ref: ${{ needs.setup.outputs.ref }} + pr-info-repo: ${{ needs.setup.outputs.repo }} skip-comment: ${{ inputs.skip-comment || 'false' }} - name: Update PR comment reactions diff --git a/.github/workflows/yaml-check.yaml b/.github/workflows/yaml-check.yaml index 7c0d4855..be9cad9d 100644 --- a/.github/workflows/yaml-check.yaml +++ b/.github/workflows/yaml-check.yaml @@ -14,76 +14,35 @@ permissions: type: string jobs: - pre-check: + setup: runs-on: ubuntu-latest outputs: - is_act: ${{ steps.prepare.outputs.is_act }} - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} - base_sha: ${{ steps.prepare.outputs.base_sha }} - pr_number: ${{ steps.prepare.outputs.pr_number }} + 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 }} + has_changes: ${{ steps.setup.outputs.has_changes }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-check-outputs@main - - detect-changes: - needs: pre-check - if: > - needs.pre-check.result == 'success' && 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 }} - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - path: phlex-src - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} - - - name: Detect relevant changes - id: filter - uses: Framework-R-D/phlex/.github/actions/detect-relevant-changes@main + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: - repo-path: phlex-src - base-ref: ${{ needs.pre-check.outputs.base_sha }} - head-ref: ${{ needs.pre-check.outputs.ref }} file-type: yaml - - name: Report detection outcome - run: | - if [ "${{ steps.filter.outputs.matched }}" != "true" ]; then - echo "::notice::No YAML-related changes detected; check will be skipped." - else - echo "::group::YAML-related files" - printf '%s\n' "${{ steps.filter.outputs.matched_files }}" - echo "::endgroup::" - fi - yaml-check: - needs: [pre-check, detect-changes] + needs: setup if: > - always() && ( - needs.detect-changes.result == 'skipped' || - ( - needs.detect-changes.result == 'success' && - needs.detect-changes.outputs.has_changes == 'true' - ) - ) + always() && needs.setup.outputs.has_changes == 'true' runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - ref: ${{ needs.pre-check.outputs.ref }} - path: phlex-src - repository: ${{ needs.pre-check.outputs.repo }} + ref: ${{ needs.setup.outputs.ref }} + path: ${{ needs.setup.outputs.checkout_path }} + repository: ${{ needs.setup.outputs.repo }} - name: Setup Python uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 @@ -95,7 +54,7 @@ jobs: - name: Run yamllint id: lint - working-directory: phlex-src + working-directory: ${{ needs.setup.outputs.checkout_path }} run: yamllint . continue-on-error: true @@ -109,16 +68,3 @@ jobs: echo "::error::Comment '@${{ github.event.repository.name }}bot yaml-fix' on the PR to auto-fix." exit 1 fi - - yaml-check-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 YAML changes detected - run: echo "::notice::No YAML-related changes detected; yaml-check skipped." diff --git a/.github/workflows/yaml-fix.yaml b/.github/workflows/yaml-fix.yaml index a9ae09d0..f3438e7a 100644 --- a/.github/workflows/yaml-fix.yaml +++ b/.github/workflows/yaml-fix.yaml @@ -57,34 +57,36 @@ env: local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} jobs: - pre-check: + setup: runs-on: ubuntu-latest name: Parse command if: > - github.event_name == 'workflow_dispatch' || inputs.ref != '' || ( + inputs.ref != '' || + github.event_name == 'workflow_dispatch' || ( 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 yaml-fix', github.event.repository.name)) ) - # Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments. - # This covers repo owners, invited collaborators, and all org members. outputs: - ref: ${{ steps.prepare.outputs.ref }} - repo: ${{ steps.prepare.outputs.repo }} + ref: ${{ steps.setup.outputs.ref }} + repo: ${{ steps.setup.outputs.repo }} + checkout_path: ${{ steps.setup.outputs.checkout_path }} steps: - - name: Prepare outputs - id: prepare - uses: Framework-R-D/phlex/.github/actions/prepare-fix-outputs@main + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: + mode: fix ref: ${{ inputs.ref }} repo: ${{ inputs.repo }} + checkout-path: ${{ inputs.checkout-path }} apply_yaml_fixes: runs-on: ubuntu-latest name: Apply YAML fixes - needs: pre-check - if: ${{ needs.pre-check.result == 'success' }} + needs: setup + if: ${{ needs.setup.result == 'success' }} outputs: changes: ${{ steps.handle_commit.outputs.changes }} pushed: ${{ steps.handle_commit.outputs.pushed }} @@ -96,9 +98,9 @@ jobs: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: - path: ${{ env.local_checkout_path }} - ref: ${{ needs.pre-check.outputs.ref }} - repository: ${{ needs.pre-check.outputs.repo }} + path: ${{ needs.setup.outputs.checkout_path }} + ref: ${{ needs.setup.outputs.ref }} + repository: ${{ needs.setup.outputs.repo }} token: ${{ secrets.WORKFLOW_PAT }} - name: Setup Node.js @@ -119,10 +121,10 @@ jobs: uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main with: tool: YAML formatter - working-directory: ${{ env.local_checkout_path }} + working-directory: ${{ needs.setup.outputs.checkout_path }} token: ${{ secrets.WORKFLOW_PAT }} - pr-info-ref: ${{ needs.pre-check.outputs.ref }} - pr-info-repo: ${{ needs.pre-check.outputs.repo }} + pr-info-ref: ${{ needs.setup.outputs.ref }} + pr-info-repo: ${{ needs.setup.outputs.repo }} skip-comment: ${{ inputs.skip-comment || 'false' }} - name: Update PR comment reactions diff --git a/test/python/all_config.py b/test/python/all_config.py index 0a4c1631..aeee3b37 100644 --- a/test/python/all_config.py +++ b/test/python/all_config.py @@ -49,9 +49,9 @@ def __init__(self, config): assert len(config["some_objects"]) == 3 expected = [ - {"a": "b", "c": "d", "e": "f"}, - {"g": "h", "i": "j", "k": "l"}, - {"m": "n", "o": "p", "q": "r"}, + {'a': 'b', 'c': 'd', 'e': 'f'}, + {'g': 'h', 'i': 'j', 'k': 'l'}, + {'m': 'n', 'o': 'p', 'q': 'r'}, ] for i in range(3): assert config["some_objects"][i] == expected[i] @@ -60,10 +60,10 @@ def __init__(self, config): assert config["empty"] == () try: - config[42] # should raise + config[42] # should raise assert not "did not raise TypeError" except TypeError: - pass # all good as exception was raised + pass # all good as exception was raised def __call__(self, i: int, j: int) -> None: """Dummy routine to do something. diff --git a/test/python/reducer.py b/test/python/reducer.py index 75b283e6..b32fe039 100644 --- a/test/python/reducer.py +++ b/test/python/reducer.py @@ -74,13 +74,17 @@ def PHLEX_REGISTER_ALGORITHMS(m, config): {"creator": "reduce0", "layer": "event", "suffix": "sum0"}, {"creator": "reduce1", "layer": "event", "suffix": "sum1"}, ] - m.transform(add_sum01, name="reduce01", input_family=input_family01, output_products=["sum01"]) + m.transform( + add_sum01, name="reduce01", input_family=input_family01, output_products=["sum01"] + ) input_family01 = [ {"creator": "reduce2", "layer": "event", "suffix": "sum2"}, {"creator": "reduce3", "layer": "event", "suffix": "sum3"}, ] - m.transform(add_sum23, name="reduce23", input_family=input_family01, output_products=["sum23"]) + m.transform( + add_sum23, name="reduce23", input_family=input_family01, output_products=["sum23"] + ) # once more (and the configuration will add a verifier) input_family_final = [ diff --git a/test/python/sumit.py b/test/python/sumit.py index ae43e5ff..17eaef93 100644 --- a/test/python/sumit.py +++ b/test/python/sumit.py @@ -63,8 +63,8 @@ def PHLEX_REGISTER_ALGORITHMS(m, config): None """ m.transform(collectify, input_family=config["input"], output_products=["my_pyarray"]) - m.transform( - sum_array, - input_family=[{"creator": "collectify", "layer": "event", "suffix": "my_pyarray"}], - output_products=config["output"], - ) + m.transform(sum_array, + input_family=[ + {"creator" : "collectify", "layer" : "event", "suffix" : "my_pyarray"} + ], + output_products=config["output"]) diff --git a/test/python/test_coverage.py b/test/python/test_coverage.py index 52c844d8..33f82d33 100644 --- a/test/python/test_coverage.py +++ b/test/python/test_coverage.py @@ -42,14 +42,13 @@ def PHLEX_REGISTER_ALGORITHMS(m, config): """Register algorithms.""" # We need to transform scalar inputs to lists first # i, f1, d1 come from cppsource4py - tfs = ( - (collect_int, "input", "i", "l_int"), - (collect_float, "input", "f1", "l_float"), - (collect_double, "input", "d1", "l_double"), - (list_int_func, collect_int.__name__, "l_int", "sum_int"), - (list_float_func, collect_float.__name__, "l_float", "sum_float"), - (list_double_func, collect_double.__name__, "l_double", "sum_double"), - ) + tfs = ((collect_int, "input", "i", "l_int"), + (collect_float, "input", "f1", "l_float"), + (collect_double, "input", "d1", "l_double"), + (list_int_func, collect_int.__name__, "l_int", "sum_int"), + (list_float_func, collect_float.__name__, "l_float", "sum_float"), + (list_double_func, collect_double.__name__, "l_double", "sum_double") + ) for func, creator, suffix, output in tfs: input_family = [{"creator": creator, "layer": "event", "suffix": suffix}] diff --git a/test/python/test_mismatch.py b/test/python/test_mismatch.py index 55eca0e7..2d188496 100644 --- a/test/python/test_mismatch.py +++ b/test/python/test_mismatch.py @@ -10,8 +10,6 @@ def PHLEX_REGISTER_ALGORITHMS(m, config): """Register algorithms.""" # input_family has 1 element, but function takes 2 arguments # This should trigger the error in modulewrap.cpp - m.transform( - mismatch_func, - input_family=[{"creator": "input", "layer": "event", "suffix": "a"}], - output_products=["sum"], - ) + m.transform(mismatch_func, + input_family=[{"creator": "input", "layer": "event", "suffix": "a"}], + output_products=["sum"]) diff --git a/test/python/vectypes.py b/test/python/vectypes.py index 5cd46492..de182aab 100644 --- a/test/python/vectypes.py +++ b/test/python/vectypes.py @@ -259,13 +259,11 @@ def PHLEX_REGISTER_ALGORITHMS(m, config): ) sum_kwargs = { - "input_family": [ - { - "creator": list_collect.__name__ if use_lists else arr_collect.__name__, - "layer": "event", - "suffix": arr_name, - } - ], + "input_family": [{ + "creator": list_collect.__name__ if use_lists else arr_collect.__name__, + "layer": "event", + "suffix": arr_name + }], "output_products": config[out_key], } if sum_name: From c2f2dc531091fb74ed5b1035f4254d28e2f9864d Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 13:47:38 -0500 Subject: [PATCH 04/10] [WIP] [18132869807280577001] Fix comment reactions for tidy-fix workflow (#417) * Initial plan * fix: use needs.setup.outputs.checkout_path consistently in fix workflows Replace env.local_checkout_path (which uses github.event.repository.name and can diverge from the actual checkout path when inputs.repo names a different repository) with needs.setup.outputs.checkout_path in the actual fix steps of all affected workflows. Also remove the now-unused local_checkout_path top-level env block from all fix workflows. Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> --- .github/workflows/clang-format-fix.yaml | 5 +---- .github/workflows/cmake-format-fix.yaml | 5 +---- .github/workflows/header-guards-fix.yaml | 3 --- .github/workflows/jsonnet-format-fix.yaml | 5 +---- .github/workflows/markdown-fix.yaml | 3 --- .github/workflows/python-fix.yaml | 3 --- .github/workflows/yaml-fix.yaml | 5 +---- 7 files changed, 4 insertions(+), 25 deletions(-) diff --git a/.github/workflows/clang-format-fix.yaml b/.github/workflows/clang-format-fix.yaml index 25397798..aec93000 100644 --- a/.github/workflows/clang-format-fix.yaml +++ b/.github/workflows/clang-format-fix.yaml @@ -53,9 +53,6 @@ permissions: pull-requests: write contents: write -env: - local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} - jobs: setup: runs-on: ubuntu-latest @@ -103,7 +100,7 @@ jobs: - uses: DoozyX/clang-format-lint-action@bcb4eb2cb0d707ee4f3e5cc3b456eb075f12cf73 # v0.20 with: - source: "./${{ env.local_checkout_path }}" + source: "./${{ needs.setup.outputs.checkout_path }}" clangFormatVersion: 20 inplace: "True" extensions: cpp,hpp,cpp.in,hpp.in diff --git a/.github/workflows/cmake-format-fix.yaml b/.github/workflows/cmake-format-fix.yaml index 6ec6be80..a0d2ed18 100644 --- a/.github/workflows/cmake-format-fix.yaml +++ b/.github/workflows/cmake-format-fix.yaml @@ -53,9 +53,6 @@ permissions: pull-requests: write contents: write -env: - local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} - jobs: setup: runs-on: ubuntu-latest @@ -113,7 +110,7 @@ jobs: - name: Apply CMake formatting run: | echo "Applying CMake formatting..." - gersemi -i ${{ env.local_checkout_path }} + gersemi -i ${{ needs.setup.outputs.checkout_path }} - name: Handle fix commit id: handle_commit diff --git a/.github/workflows/header-guards-fix.yaml b/.github/workflows/header-guards-fix.yaml index 95356ab6..8584bc77 100644 --- a/.github/workflows/header-guards-fix.yaml +++ b/.github/workflows/header-guards-fix.yaml @@ -53,9 +53,6 @@ permissions: pull-requests: write contents: write -env: - local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} - jobs: setup: runs-on: ubuntu-latest diff --git a/.github/workflows/jsonnet-format-fix.yaml b/.github/workflows/jsonnet-format-fix.yaml index fa66ca5c..82822c1e 100644 --- a/.github/workflows/jsonnet-format-fix.yaml +++ b/.github/workflows/jsonnet-format-fix.yaml @@ -53,9 +53,6 @@ permissions: pull-requests: write contents: write -env: - local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} - jobs: setup: runs-on: ubuntu-latest @@ -106,7 +103,7 @@ jobs: - name: Apply Jsonnet formatting id: lint env: - CHECKOUT_PATH: ${{ env.local_checkout_path }} + CHECKOUT_PATH: ${{ needs.setup.outputs.checkout_path }} # yamllint disable rule:line-length run: | docker run --rm -v "${{ github.workspace }}:/work" -w /work --user root public.ecr.aws/bitnami/jsonnet:latest \ diff --git a/.github/workflows/markdown-fix.yaml b/.github/workflows/markdown-fix.yaml index cb082462..3e9c6c99 100644 --- a/.github/workflows/markdown-fix.yaml +++ b/.github/workflows/markdown-fix.yaml @@ -53,9 +53,6 @@ permissions: pull-requests: write contents: write -env: - local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} - jobs: setup: runs-on: ubuntu-latest diff --git a/.github/workflows/python-fix.yaml b/.github/workflows/python-fix.yaml index f3ca535c..43c13153 100644 --- a/.github/workflows/python-fix.yaml +++ b/.github/workflows/python-fix.yaml @@ -53,9 +53,6 @@ permissions: pull-requests: write contents: write -env: - local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} - jobs: setup: runs-on: ubuntu-latest diff --git a/.github/workflows/yaml-fix.yaml b/.github/workflows/yaml-fix.yaml index f3438e7a..6916cdc4 100644 --- a/.github/workflows/yaml-fix.yaml +++ b/.github/workflows/yaml-fix.yaml @@ -53,9 +53,6 @@ permissions: pull-requests: write contents: write -env: - local_checkout_path: ${{ inputs.checkout-path || format('{0}-src', github.event.repository.name) }} - jobs: setup: runs-on: ubuntu-latest @@ -113,7 +110,7 @@ jobs: - name: Apply YAML formatting run: | - cd ${{ env.local_checkout_path }} + cd ${{ needs.setup.outputs.checkout_path }} prettier --write '**/*.{yaml,yml}' - name: Handle fix commit From 244389083fe0b0a8ff585b800ddfb578bc2de2ad Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 14:06:00 -0500 Subject: [PATCH 05/10] maintenance: eliminate remaining pre-consolidation path/input paradigms from workflows (#418) * Initial plan * fix: remove remaining pre-consolidation path/input patterns from workflows Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> --- .github/workflows/actionlint-check.yaml | 9 ++------- .github/workflows/cmake-build.yaml | 9 +-------- .github/workflows/cmake-format-check.yaml | 9 ++------- .github/workflows/codeql-analysis.yaml | 15 +++++++-------- .github/workflows/header-guards-check.yaml | 9 ++------- .github/workflows/jsonnet-format-check.yaml | 9 ++------- .github/workflows/markdown-check.yaml | 11 +++-------- .github/workflows/python-check.yaml | 11 +++-------- 8 files changed, 22 insertions(+), 60 deletions(-) diff --git a/.github/workflows/actionlint-check.yaml b/.github/workflows/actionlint-check.yaml index fa69671a..418ff03e 100644 --- a/.github/workflows/actionlint-check.yaml +++ b/.github/workflows/actionlint-check.yaml @@ -41,11 +41,6 @@ permissions: required: false type: string -env: - local_checkout_path: - ${{ (github.event_name == 'workflow_call' && inputs.checkout-path) || format('{0}-src', - github.event.repository.name) }} - jobs: setup: runs-on: ubuntu-latest @@ -81,7 +76,7 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ needs.setup.outputs.ref }} - path: ${{ env.local_checkout_path }} + path: ${{ needs.setup.outputs.checkout_path }} repository: ${{ needs.setup.outputs.repo }} - name: Announce actionlint check @@ -91,7 +86,7 @@ jobs: id: lint run: | docker run --rm \ - -v "${{ github.workspace }}/${{ env.local_checkout_path }}:/work" \ + -v "${{ github.workspace }}/${{ needs.setup.outputs.checkout_path }}:/work" \ -w /work \ rhysd/actionlint:latest \ -config-file .github/actionlint.yaml diff --git a/.github/workflows/cmake-build.yaml b/.github/workflows/cmake-build.yaml index a74c5c06..a9da769e 100644 --- a/.github/workflows/cmake-build.yaml +++ b/.github/workflows/cmake-build.yaml @@ -67,12 +67,6 @@ permissions: env: BUILD_TYPE: Release CICOLOR_FORCE: 1 - local_checkout_path: - ${{ (github.event_name == 'workflow_call' && inputs.checkout-path) || format('{0}-src', - github.event.repository.name) }} - local_build_path: - ${{ (github.event_name == 'workflow_call' && inputs.build-path) || format('{0}-build', github.event.repository.name) - }} jobs: setup: @@ -123,8 +117,7 @@ jobs: uses: Framework-R-D/phlex/.github/actions/generate-build-matrix@main with: user-input: - ${{ (github.event_name == 'workflow_call' && inputs.build-combinations) || - github.event.inputs.build-combinations }} + ${{ inputs.build-combinations || github.event.inputs.build-combinations }} comment-body: ${{ github.event.comment.body }} build: diff --git a/.github/workflows/cmake-format-check.yaml b/.github/workflows/cmake-format-check.yaml index 6dc44e84..2ddc0a96 100644 --- a/.github/workflows/cmake-format-check.yaml +++ b/.github/workflows/cmake-format-check.yaml @@ -41,11 +41,6 @@ permissions: required: false type: string -env: - local_checkout_path: - ${{ (github.event_name == 'workflow_call' && inputs.checkout-path) || format('{0}-src', - github.event.repository.name) }} - jobs: setup: runs-on: ubuntu-latest @@ -74,7 +69,7 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ needs.setup.outputs.ref }} - path: ${{ env.local_checkout_path }} + path: ${{ needs.setup.outputs.checkout_path }} repository: ${{ needs.setup.outputs.repo }} - name: Set up Python @@ -89,7 +84,7 @@ jobs: id: lint run: | echo "➡️ Checking CMake file formatting..." - gersemi --check ${{ env.local_checkout_path }} + gersemi --check ${{ needs.setup.outputs.checkout_path }} continue-on-error: true - name: Evaluate CMake formatting result diff --git a/.github/workflows/codeql-analysis.yaml b/.github/workflows/codeql-analysis.yaml index 82e3b48c..6f612f0e 100644 --- a/.github/workflows/codeql-analysis.yaml +++ b/.github/workflows/codeql-analysis.yaml @@ -75,6 +75,7 @@ jobs: 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 }} skip_detection: ${{ steps.should_skip.outputs.skip }} has_changes_cpp: ${{ steps.detect_cpp.outputs.has_changes }} has_changes_python: ${{ steps.detect_python.outputs.has_changes }} @@ -88,6 +89,7 @@ jobs: repo: ${{ inputs.repo }} pr-base-sha: ${{ inputs.pr-base-sha }} checkout-path: ${{ inputs.checkout-path }} + build-path: ${{ inputs.build-path }} - name: Determine if detection should be skipped id: should_skip @@ -111,7 +113,7 @@ jobs: ref: ${{ steps.setup.outputs.ref }} repo: ${{ steps.setup.outputs.repo }} base-ref: ${{ steps.setup.outputs.base_sha }} - head-ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || steps.setup.outputs.ref }} + head-ref: ${{ inputs.pr-head-sha || steps.setup.outputs.ref }} file-type: | cpp cmake @@ -125,7 +127,7 @@ jobs: ref: ${{ steps.setup.outputs.ref }} repo: ${{ steps.setup.outputs.repo }} base-ref: ${{ steps.setup.outputs.base_sha }} - head-ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || steps.setup.outputs.ref }} + head-ref: ${{ inputs.pr-head-sha || steps.setup.outputs.ref }} file-type: python - name: Detect Actions changes @@ -137,7 +139,7 @@ jobs: ref: ${{ steps.setup.outputs.ref }} repo: ${{ steps.setup.outputs.repo }} base-ref: ${{ steps.setup.outputs.base_sha }} - head-ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || steps.setup.outputs.ref }} + head-ref: ${{ inputs.pr-head-sha || steps.setup.outputs.ref }} include-globs: | .github/workflows/*.yaml .github/workflows/*.yml @@ -208,12 +210,9 @@ jobs: image: ghcr.io/framework-r-d/phlex-ci:latest env: local_checkout_path: ${{ needs.setup.outputs.checkout_path }} - local_build_path: - ${{ (github.event_name == 'workflow_call' && inputs.build-path) || format('{0}-build', - github.event.repository.name) }} + local_build_path: ${{ needs.setup.outputs.build_path }} CODEQL_EXTRACTOR_CPP_COMPILATION_DATABASE: - ${{ github.workspace }}/${{ (github.event_name == 'workflow_call' && inputs.build-path) || format('{0}-build', - github.event.repository.name) }}/compile_commands.json + ${{ github.workspace }}/${{ needs.setup.outputs.build_path }}/compile_commands.json strategy: fail-fast: false matrix: diff --git a/.github/workflows/header-guards-check.yaml b/.github/workflows/header-guards-check.yaml index b784b991..1ce24729 100644 --- a/.github/workflows/header-guards-check.yaml +++ b/.github/workflows/header-guards-check.yaml @@ -41,11 +41,6 @@ permissions: required: false type: string -env: - local_checkout_path: - ${{ (github.event_name == 'workflow_call' && inputs.checkout-path) || format('{0}-src', - github.event.repository.name) }} - jobs: setup: runs-on: ubuntu-latest @@ -77,7 +72,7 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ needs.setup.outputs.ref }} - path: ${{ env.local_checkout_path }} + path: ${{ needs.setup.outputs.checkout_path }} repository: ${{ needs.setup.outputs.repo }} - name: Set up Python @@ -87,7 +82,7 @@ jobs: - name: Check header guards id: check - working-directory: ${{ env.local_checkout_path }} + working-directory: ${{ needs.setup.outputs.checkout_path }} run: | python3 scripts/fix_header_guards.py --check --root . phlex plugins form > check_output.txt 2>&1 || echo "has_issues=true" >> "$GITHUB_OUTPUT" cat check_output.txt diff --git a/.github/workflows/jsonnet-format-check.yaml b/.github/workflows/jsonnet-format-check.yaml index df3f3ebd..0695f6df 100644 --- a/.github/workflows/jsonnet-format-check.yaml +++ b/.github/workflows/jsonnet-format-check.yaml @@ -41,11 +41,6 @@ permissions: required: false type: string -env: - local_checkout_path: - ${{ (github.event_name == 'workflow_call' && inputs.checkout-path) || format('{0}-src', - github.event.repository.name) }} - jobs: setup: runs-on: ubuntu-latest @@ -78,11 +73,11 @@ jobs: with: ref: ${{ needs.setup.outputs.ref }} repository: ${{ needs.setup.outputs.repo }} - path: ${{ env.local_checkout_path }} + path: ${{ needs.setup.outputs.checkout_path }} - name: Check Jsonnet formatting id: lint - working-directory: ${{ env.local_checkout_path }} + working-directory: ${{ needs.setup.outputs.checkout_path }} run: | find . \( -name "*.jsonnet" -o -name "*.libsonnet" \) -print0 | xargs -0 -r -I {} \ bash -c 'jsonnetfmt --test "{}" || (echo "FAILED: {}" && diff -u <(jsonnetfmt "{}") "{}" && exit 1)' diff --git a/.github/workflows/markdown-check.yaml b/.github/workflows/markdown-check.yaml index d39fdd5e..2c0a94e6 100644 --- a/.github/workflows/markdown-check.yaml +++ b/.github/workflows/markdown-check.yaml @@ -41,11 +41,6 @@ permissions: required: false type: string -env: - local_checkout_path: - ${{ (github.event_name == 'workflow_call' && inputs.checkout-path) || format('{0}-src', - github.event.repository.name) }} - jobs: setup: runs-on: ubuntu-latest @@ -77,7 +72,7 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ needs.setup.outputs.ref }} - path: ${{ env.local_checkout_path }} + path: ${{ needs.setup.outputs.checkout_path }} repository: ${{ needs.setup.outputs.repo }} - name: Add problem matcher @@ -88,8 +83,8 @@ jobs: uses: DavidAnson/markdownlint-cli2-action@07035fd053f7be764496c0f8d8f9f41f98305101 # v22.0.0 with: globs: | - ${{ env.local_checkout_path }}/**/*.md - !${{ env.local_checkout_path }}/**/CHANGELOG.md + ${{ needs.setup.outputs.checkout_path }}/**/*.md + !${{ needs.setup.outputs.checkout_path }}/**/CHANGELOG.md continue-on-error: true - name: Evaluate markdownlint result diff --git a/.github/workflows/python-check.yaml b/.github/workflows/python-check.yaml index 503bf880..aae6d5a4 100644 --- a/.github/workflows/python-check.yaml +++ b/.github/workflows/python-check.yaml @@ -41,11 +41,6 @@ permissions: required: false type: string -env: - local_checkout_path: - ${{ (github.event_name == 'workflow_call' && inputs.checkout-path) || format('{0}-src', - github.event.repository.name) }} - jobs: setup: runs-on: ubuntu-latest @@ -77,7 +72,7 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: ref: ${{ needs.setup.outputs.ref }} - path: ${{ env.local_checkout_path }} + path: ${{ needs.setup.outputs.checkout_path }} repository: ${{ needs.setup.outputs.repo }} - name: Set up Python @@ -91,7 +86,7 @@ jobs: - name: Run ruff check id: ruff - working-directory: ${{ env.local_checkout_path }} + working-directory: ${{ needs.setup.outputs.checkout_path }} env: FORCE_COLOR: 1 run: | @@ -101,7 +96,7 @@ jobs: - name: Run MyPy check id: mypy - working-directory: ${{ env.local_checkout_path }} + working-directory: ${{ needs.setup.outputs.checkout_path }} run: | echo "➡️ Checking Python code with MyPy..." mypy --color-output . From fdbc63b307729217c0f33652febc12088744d13a Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 14:24:21 -0500 Subject: [PATCH 06/10] fix: artifact download nested path and missing `issues: write` permission (#419) * Initial plan * Fix artifact nested path and add issues:write permission for reactions Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> --- .github/actions/post-clang-tidy-results/action.yaml | 1 - .github/workflows/format-all.yaml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/post-clang-tidy-results/action.yaml b/.github/actions/post-clang-tidy-results/action.yaml index 8d3f8ad5..8221e81c 100644 --- a/.github/actions/post-clang-tidy-results/action.yaml +++ b/.github/actions/post-clang-tidy-results/action.yaml @@ -19,7 +19,6 @@ runs: uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0 with: pattern: clang-tidy-* - path: ${{ inputs.build-path }} merge-multiple: true continue-on-error: true diff --git a/.github/workflows/format-all.yaml b/.github/workflows/format-all.yaml index 8126aebc..71445f18 100644 --- a/.github/workflows/format-all.yaml +++ b/.github/workflows/format-all.yaml @@ -9,6 +9,7 @@ on: permissions: pull-requests: write contents: write + issues: write jobs: setup: From 4ad02758a372f82057777521051f9bdc08e1154e Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 14:51:46 -0500 Subject: [PATCH 07/10] fix: workflow permissions and relevance-check bypass regressions (#420) * Initial plan * fix: address unresolved review comments - permissions, workflow_dispatch, pr-head-sha wiring Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> --- .github/actions/complete-pr-comment/action.yaml | 7 ++++--- .github/actions/workflow-setup/action.yaml | 4 ++++ .github/workflows/actionlint-check.yaml | 7 ++++++- .github/workflows/clang-format-check.yaml | 2 +- .github/workflows/clang-format-fix.yaml | 1 + .github/workflows/clang-tidy-check.yaml | 2 +- .github/workflows/cmake-build.yaml | 7 ++++++- .github/workflows/cmake-format-check.yaml | 7 ++++++- .github/workflows/cmake-format-fix.yaml | 1 + .github/workflows/coverage.yaml | 2 +- .github/workflows/header-guards-check.yaml | 7 ++++++- .github/workflows/header-guards-fix.yaml | 1 + .github/workflows/jsonnet-format-check.yaml | 7 ++++++- .github/workflows/jsonnet-format-fix.yaml | 1 + .github/workflows/markdown-check.yaml | 7 ++++++- .github/workflows/markdown-fix.yaml | 1 + .github/workflows/python-check.yaml | 7 ++++++- .github/workflows/python-fix.yaml | 1 + .github/workflows/yaml-check.yaml | 2 +- .github/workflows/yaml-fix.yaml | 1 + 20 files changed, 61 insertions(+), 14 deletions(-) diff --git a/.github/actions/complete-pr-comment/action.yaml b/.github/actions/complete-pr-comment/action.yaml index 1ecabd30..0e8488b2 100644 --- a/.github/actions/complete-pr-comment/action.yaml +++ b/.github/actions/complete-pr-comment/action.yaml @@ -1,7 +1,8 @@ name: "Complete PR Comment" -description: - "Removes the 'eyes' reaction and adds a completion reaction ('rocket' for success, 'confused' for 'failure', 'cancelled', or 'skipped') to the - triggering comment." +description: >- + Removes the 'eyes' reaction and adds a completion reaction ('rocket' for success, 'confused' for 'failure', + 'cancelled', or 'skipped') to the triggering comment. Requires `issues: write` permission in the calling + workflow to update comment reactions via the GitHub Reactions API. inputs: status: description: diff --git a/.github/actions/workflow-setup/action.yaml b/.github/actions/workflow-setup/action.yaml index 619f911f..89a27321 100644 --- a/.github/actions/workflow-setup/action.yaml +++ b/.github/actions/workflow-setup/action.yaml @@ -29,6 +29,9 @@ inputs: exclude-globs: description: "Exclude globs for change detection" required: false + head-ref: + description: "Explicit head ref for change detection (overrides the resolved ref)" + required: false outputs: is_act: @@ -119,3 +122,4 @@ runs: file-type: ${{ inputs.file-type }} include-globs: ${{ inputs.include-globs }} exclude-globs: ${{ inputs.exclude-globs }} + head-ref: ${{ inputs.head-ref }} diff --git a/.github/workflows/actionlint-check.yaml b/.github/workflows/actionlint-check.yaml index 418ff03e..52742693 100644 --- a/.github/workflows/actionlint-check.yaml +++ b/.github/workflows/actionlint-check.yaml @@ -62,11 +62,16 @@ jobs: .github/workflows/**/*.yaml .github/actions/**/*.yml .github/actions/**/*.yaml + head-ref: ${{ inputs.pr-head-sha }} actionlint-check: needs: setup if: > - always() && needs.setup.outputs.has_changes == 'true' + always() && ( + github.event_name == 'workflow_dispatch' || + inputs.skip-relevance-check || + needs.setup.outputs.has_changes == 'true' + ) runs-on: ubuntu-latest permissions: contents: read diff --git a/.github/workflows/clang-format-check.yaml b/.github/workflows/clang-format-check.yaml index 38478df1..f385f740 100644 --- a/.github/workflows/clang-format-check.yaml +++ b/.github/workflows/clang-format-check.yaml @@ -35,7 +35,7 @@ jobs: clang-format-check: needs: setup if: > - always() && needs.setup.outputs.has_changes == 'true' + always() && (github.event_name == 'workflow_dispatch' || needs.setup.outputs.has_changes == 'true') runs-on: ubuntu-latest permissions: contents: read diff --git a/.github/workflows/clang-format-fix.yaml b/.github/workflows/clang-format-fix.yaml index aec93000..c47bd782 100644 --- a/.github/workflows/clang-format-fix.yaml +++ b/.github/workflows/clang-format-fix.yaml @@ -52,6 +52,7 @@ run-name: "${{ github.actor }} fixing C++ code format" permissions: pull-requests: write contents: write + issues: write jobs: setup: diff --git a/.github/workflows/clang-tidy-check.yaml b/.github/workflows/clang-tidy-check.yaml index b3cf3db3..74eeb4ea 100644 --- a/.github/workflows/clang-tidy-check.yaml +++ b/.github/workflows/clang-tidy-check.yaml @@ -47,7 +47,7 @@ jobs: clang-tidy-check: needs: setup if: > - always() && needs.setup.outputs.has_changes == 'true' + always() && (github.event_name == 'workflow_dispatch' || needs.setup.outputs.has_changes == 'true') runs-on: ubuntu-24.04 container: image: ghcr.io/framework-r-d/phlex-ci:latest diff --git a/.github/workflows/cmake-build.yaml b/.github/workflows/cmake-build.yaml index a9da769e..87299cfb 100644 --- a/.github/workflows/cmake-build.yaml +++ b/.github/workflows/cmake-build.yaml @@ -102,6 +102,7 @@ jobs: 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 @@ -123,7 +124,11 @@ jobs: build: needs: [setup, generate-matrix] if: > - always() && needs.setup.result == 'success' && needs.setup.outputs.has_changes == 'true' + 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 diff --git a/.github/workflows/cmake-format-check.yaml b/.github/workflows/cmake-format-check.yaml index 2ddc0a96..190e803d 100644 --- a/.github/workflows/cmake-format-check.yaml +++ b/.github/workflows/cmake-format-check.yaml @@ -58,11 +58,16 @@ jobs: uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: file-type: cmake + head-ref: ${{ inputs.pr-head-sha }} cmake-format-check: needs: setup if: > - always() && needs.setup.outputs.has_changes == 'true' + always() && ( + github.event_name == 'workflow_dispatch' || + inputs.skip-relevance-check || + needs.setup.outputs.has_changes == 'true' + ) runs-on: ubuntu-latest steps: - name: Checkout code diff --git a/.github/workflows/cmake-format-fix.yaml b/.github/workflows/cmake-format-fix.yaml index a0d2ed18..0894b150 100644 --- a/.github/workflows/cmake-format-fix.yaml +++ b/.github/workflows/cmake-format-fix.yaml @@ -52,6 +52,7 @@ run-name: "${{ github.actor }} fixing CMake format" permissions: pull-requests: write contents: write + issues: write jobs: setup: diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index 2ec4b508..60d7a6d3 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -63,7 +63,7 @@ jobs: coverage: needs: setup if: > - always() && needs.setup.outputs.has_changes == 'true' + always() && (github.event_name == 'workflow_dispatch' || needs.setup.outputs.has_changes == 'true') runs-on: ubuntu-24.04 container: image: ghcr.io/framework-r-d/phlex-ci:latest diff --git a/.github/workflows/header-guards-check.yaml b/.github/workflows/header-guards-check.yaml index 1ce24729..24f695df 100644 --- a/.github/workflows/header-guards-check.yaml +++ b/.github/workflows/header-guards-check.yaml @@ -58,11 +58,16 @@ jobs: uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: file-type: cpp + head-ref: ${{ inputs.pr-head-sha }} header-guards-check: needs: setup if: > - always() && needs.setup.outputs.has_changes == 'true' + always() && ( + github.event_name == 'workflow_dispatch' || + inputs.skip-relevance-check || + needs.setup.outputs.has_changes == 'true' + ) runs-on: ubuntu-latest permissions: contents: read diff --git a/.github/workflows/header-guards-fix.yaml b/.github/workflows/header-guards-fix.yaml index 8584bc77..05935630 100644 --- a/.github/workflows/header-guards-fix.yaml +++ b/.github/workflows/header-guards-fix.yaml @@ -52,6 +52,7 @@ run-name: "${{ github.actor }} fixing header guards" permissions: pull-requests: write contents: write + issues: write jobs: setup: diff --git a/.github/workflows/jsonnet-format-check.yaml b/.github/workflows/jsonnet-format-check.yaml index 0695f6df..ffed5e07 100644 --- a/.github/workflows/jsonnet-format-check.yaml +++ b/.github/workflows/jsonnet-format-check.yaml @@ -58,11 +58,16 @@ jobs: uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: file-type: jsonnet + head-ref: ${{ inputs.pr-head-sha }} jsonnet-format-check: needs: setup if: > - always() && needs.setup.outputs.has_changes == 'true' + always() && ( + github.event_name == 'workflow_dispatch' || + inputs.skip-relevance-check || + needs.setup.outputs.has_changes == 'true' + ) runs-on: ubuntu-latest container: image: public.ecr.aws/bitnami/jsonnet:latest diff --git a/.github/workflows/jsonnet-format-fix.yaml b/.github/workflows/jsonnet-format-fix.yaml index 82822c1e..88c1df42 100644 --- a/.github/workflows/jsonnet-format-fix.yaml +++ b/.github/workflows/jsonnet-format-fix.yaml @@ -52,6 +52,7 @@ run-name: "${{ github.actor }} fixing Jsonnet format" permissions: pull-requests: write contents: write + issues: write jobs: setup: diff --git a/.github/workflows/markdown-check.yaml b/.github/workflows/markdown-check.yaml index 2c0a94e6..1102fd5f 100644 --- a/.github/workflows/markdown-check.yaml +++ b/.github/workflows/markdown-check.yaml @@ -58,11 +58,16 @@ jobs: uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: file-type: md + head-ref: ${{ inputs.pr-head-sha }} markdown-check: needs: setup if: > - always() && needs.setup.outputs.has_changes == 'true' + always() && ( + github.event_name == 'workflow_dispatch' || + inputs.skip-relevance-check || + needs.setup.outputs.has_changes == 'true' + ) runs-on: ubuntu-latest permissions: contents: read diff --git a/.github/workflows/markdown-fix.yaml b/.github/workflows/markdown-fix.yaml index 3e9c6c99..424a8138 100644 --- a/.github/workflows/markdown-fix.yaml +++ b/.github/workflows/markdown-fix.yaml @@ -52,6 +52,7 @@ run-name: "${{ github.actor }} fixing Markdown format" permissions: pull-requests: write contents: write + issues: write jobs: setup: diff --git a/.github/workflows/python-check.yaml b/.github/workflows/python-check.yaml index aae6d5a4..e5bb900f 100644 --- a/.github/workflows/python-check.yaml +++ b/.github/workflows/python-check.yaml @@ -58,11 +58,16 @@ jobs: uses: Framework-R-D/phlex/.github/actions/workflow-setup@main with: file-type: python + head-ref: ${{ inputs.pr-head-sha }} python-check: needs: setup if: > - always() && needs.setup.outputs.has_changes == 'true' + always() && ( + github.event_name == 'workflow_dispatch' || + inputs.skip-relevance-check || + needs.setup.outputs.has_changes == 'true' + ) runs-on: ubuntu-latest permissions: contents: read diff --git a/.github/workflows/python-fix.yaml b/.github/workflows/python-fix.yaml index 43c13153..5c676556 100644 --- a/.github/workflows/python-fix.yaml +++ b/.github/workflows/python-fix.yaml @@ -52,6 +52,7 @@ run-name: "${{ github.actor }} fixing Python code" permissions: pull-requests: write contents: write + issues: write jobs: setup: diff --git a/.github/workflows/yaml-check.yaml b/.github/workflows/yaml-check.yaml index be9cad9d..05c41ed2 100644 --- a/.github/workflows/yaml-check.yaml +++ b/.github/workflows/yaml-check.yaml @@ -34,7 +34,7 @@ jobs: yaml-check: needs: setup if: > - always() && needs.setup.outputs.has_changes == 'true' + always() && (github.event_name == 'workflow_dispatch' || needs.setup.outputs.has_changes == 'true') runs-on: ubuntu-latest steps: - name: Checkout code diff --git a/.github/workflows/yaml-fix.yaml b/.github/workflows/yaml-fix.yaml index 6916cdc4..b20e2257 100644 --- a/.github/workflows/yaml-fix.yaml +++ b/.github/workflows/yaml-fix.yaml @@ -52,6 +52,7 @@ name: YAML Fix permissions: pull-requests: write contents: write + issues: write jobs: setup: From c659d10e28378cc44b58268ecf9d1d27e0984401 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 15:24:07 -0500 Subject: [PATCH 08/10] fix: wire workflow_call inputs, act fallback for change detection, and correct clang-tidy/format-all failure behavior (#421) * Initial plan * fix: wire workflow_call inputs, act fallback for change detection, and clang-tidy/format-all failures Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com> --- .github/actions/workflow-setup/action.yaml | 15 +++++++++++++-- .github/workflows/actionlint-check.yaml | 4 ++++ .github/workflows/clang-tidy-check.yaml | 1 + .github/workflows/cmake-format-check.yaml | 4 ++++ .github/workflows/format-all.yaml | 6 ++++++ .github/workflows/header-guards-check.yaml | 4 ++++ .github/workflows/jsonnet-format-check.yaml | 4 ++++ .github/workflows/markdown-check.yaml | 4 ++++ .github/workflows/python-check.yaml | 4 ++++ 9 files changed, 44 insertions(+), 2 deletions(-) diff --git a/.github/actions/workflow-setup/action.yaml b/.github/actions/workflow-setup/action.yaml index 89a27321..a72de8d0 100644 --- a/.github/actions/workflow-setup/action.yaml +++ b/.github/actions/workflow-setup/action.yaml @@ -57,7 +57,7 @@ outputs: value: ${{ steps.prepare.outputs.build_path }} has_changes: description: "Whether relevant changes were detected" - value: ${{ steps.detect.outputs.has_changes }} + value: ${{ steps.changes.outputs.has_changes }} runs: using: "composite" @@ -112,7 +112,7 @@ runs: - name: Run change detection id: detect - if: inputs.file-type != '' || inputs.include-globs != '' + if: (inputs.file-type != '' || inputs.include-globs != '') && steps.prepare.outputs.is_act != 'true' uses: Framework-R-D/phlex/.github/actions/run-change-detection@main with: checkout-path: ${{ steps.prepare.outputs.checkout_path }} @@ -123,3 +123,14 @@ runs: include-globs: ${{ inputs.include-globs }} exclude-globs: ${{ inputs.exclude-globs }} head-ref: ${{ inputs.head-ref }} + + - name: Set has_changes output + id: changes + shell: bash + run: | + if [ "${{ steps.prepare.outputs.is_act }}" = "true" ] && \ + ([ "${{ inputs.file-type }}" != "" ] || [ "${{ inputs.include-globs }}" != "" ]); then + echo "has_changes=true" >> "$GITHUB_OUTPUT" + else + echo "has_changes=${{ steps.detect.outputs.has_changes }}" >> "$GITHUB_OUTPUT" + fi diff --git a/.github/workflows/actionlint-check.yaml b/.github/workflows/actionlint-check.yaml index 52742693..4236c799 100644 --- a/.github/workflows/actionlint-check.yaml +++ b/.github/workflows/actionlint-check.yaml @@ -63,6 +63,10 @@ jobs: .github/actions/**/*.yml .github/actions/**/*.yaml head-ref: ${{ inputs.pr-head-sha }} + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} + pr-base-sha: ${{ inputs.pr-base-sha }} + checkout-path: ${{ inputs.checkout-path }} actionlint-check: needs: setup diff --git a/.github/workflows/clang-tidy-check.yaml b/.github/workflows/clang-tidy-check.yaml index 74eeb4ea..921a5c01 100644 --- a/.github/workflows/clang-tidy-check.yaml +++ b/.github/workflows/clang-tidy-check.yaml @@ -91,6 +91,7 @@ jobs: exit 1 elif grep -qE '^/.+\.(cpp|hpp|c|h):[0-9]+:[0-9]+: (warning|error):' clang-tidy.log; then echo "::warning::Clang-tidy found issues in the code" + exit 1 else echo "✅ clang-tidy check passed" fi diff --git a/.github/workflows/cmake-format-check.yaml b/.github/workflows/cmake-format-check.yaml index 190e803d..8a7eb5ed 100644 --- a/.github/workflows/cmake-format-check.yaml +++ b/.github/workflows/cmake-format-check.yaml @@ -59,6 +59,10 @@ jobs: with: file-type: cmake head-ref: ${{ inputs.pr-head-sha }} + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} + pr-base-sha: ${{ inputs.pr-base-sha }} + checkout-path: ${{ inputs.checkout-path }} cmake-format-check: needs: setup diff --git a/.github/workflows/format-all.yaml b/.github/workflows/format-all.yaml index 71445f18..c166d5e0 100644 --- a/.github/workflows/format-all.yaml +++ b/.github/workflows/format-all.yaml @@ -120,3 +120,9 @@ jobs: uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main with: status: ${{ steps.collect.outputs.has_failures == 'true' && 'failure' || 'success' }} + + - name: Fail on formatter failures + if: steps.collect.outputs.has_failures == 'true' + run: | + echo "One or more formatters failed, were canceled, or were skipped." + exit 1 diff --git a/.github/workflows/header-guards-check.yaml b/.github/workflows/header-guards-check.yaml index 24f695df..42bd4762 100644 --- a/.github/workflows/header-guards-check.yaml +++ b/.github/workflows/header-guards-check.yaml @@ -59,6 +59,10 @@ jobs: with: file-type: cpp head-ref: ${{ inputs.pr-head-sha }} + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} + pr-base-sha: ${{ inputs.pr-base-sha }} + checkout-path: ${{ inputs.checkout-path }} header-guards-check: needs: setup diff --git a/.github/workflows/jsonnet-format-check.yaml b/.github/workflows/jsonnet-format-check.yaml index ffed5e07..476c5350 100644 --- a/.github/workflows/jsonnet-format-check.yaml +++ b/.github/workflows/jsonnet-format-check.yaml @@ -59,6 +59,10 @@ jobs: with: file-type: jsonnet head-ref: ${{ inputs.pr-head-sha }} + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} + pr-base-sha: ${{ inputs.pr-base-sha }} + checkout-path: ${{ inputs.checkout-path }} jsonnet-format-check: needs: setup diff --git a/.github/workflows/markdown-check.yaml b/.github/workflows/markdown-check.yaml index 1102fd5f..1968e927 100644 --- a/.github/workflows/markdown-check.yaml +++ b/.github/workflows/markdown-check.yaml @@ -59,6 +59,10 @@ jobs: with: file-type: md head-ref: ${{ inputs.pr-head-sha }} + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} + pr-base-sha: ${{ inputs.pr-base-sha }} + checkout-path: ${{ inputs.checkout-path }} markdown-check: needs: setup diff --git a/.github/workflows/python-check.yaml b/.github/workflows/python-check.yaml index e5bb900f..d4eda96b 100644 --- a/.github/workflows/python-check.yaml +++ b/.github/workflows/python-check.yaml @@ -59,6 +59,10 @@ jobs: with: file-type: python head-ref: ${{ inputs.pr-head-sha }} + ref: ${{ inputs.ref }} + repo: ${{ inputs.repo }} + pr-base-sha: ${{ inputs.pr-base-sha }} + checkout-path: ${{ inputs.checkout-path }} python-check: needs: setup From 333f6d39c24925e5c446d39be210a17274c669e8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 Mar 2026 20:26:42 +0000 Subject: [PATCH 09/10] Apply YAML formatter fixes --- .github/actions/complete-pr-comment/action.yaml | 4 ++-- .github/workflows/clang-format-fix.yaml | 3 +-- .github/workflows/cmake-build.yaml | 3 +-- .github/workflows/cmake-format-fix.yaml | 3 +-- .github/workflows/header-guards-fix.yaml | 3 +-- .github/workflows/jsonnet-format-fix.yaml | 3 +-- .github/workflows/markdown-fix.yaml | 3 +-- .github/workflows/python-fix.yaml | 3 +-- .github/workflows/yaml-fix.yaml | 3 +-- 9 files changed, 10 insertions(+), 18 deletions(-) diff --git a/.github/actions/complete-pr-comment/action.yaml b/.github/actions/complete-pr-comment/action.yaml index 0e8488b2..95a4d598 100644 --- a/.github/actions/complete-pr-comment/action.yaml +++ b/.github/actions/complete-pr-comment/action.yaml @@ -1,8 +1,8 @@ name: "Complete PR Comment" description: >- Removes the 'eyes' reaction and adds a completion reaction ('rocket' for success, 'confused' for 'failure', - 'cancelled', or 'skipped') to the triggering comment. Requires `issues: write` permission in the calling - workflow to update comment reactions via the GitHub Reactions API. + 'cancelled', or 'skipped') to the triggering comment. Requires `issues: write` permission in the calling workflow to + update comment reactions via the GitHub Reactions API. inputs: status: description: diff --git a/.github/workflows/clang-format-fix.yaml b/.github/workflows/clang-format-fix.yaml index c47bd782..14fab5e0 100644 --- a/.github/workflows/clang-format-fix.yaml +++ b/.github/workflows/clang-format-fix.yaml @@ -59,8 +59,7 @@ jobs: runs-on: ubuntu-latest name: Parse command if: > - inputs.ref != '' || - github.event_name == 'workflow_dispatch' || ( + inputs.ref != '' || github.event_name == 'workflow_dispatch' || ( github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(fromJSON('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association) && diff --git a/.github/workflows/cmake-build.yaml b/.github/workflows/cmake-build.yaml index 87299cfb..8530ffff 100644 --- a/.github/workflows/cmake-build.yaml +++ b/.github/workflows/cmake-build.yaml @@ -117,8 +117,7 @@ jobs: - id: generate uses: Framework-R-D/phlex/.github/actions/generate-build-matrix@main with: - user-input: - ${{ inputs.build-combinations || github.event.inputs.build-combinations }} + user-input: ${{ inputs.build-combinations || github.event.inputs.build-combinations }} comment-body: ${{ github.event.comment.body }} build: diff --git a/.github/workflows/cmake-format-fix.yaml b/.github/workflows/cmake-format-fix.yaml index 0894b150..cd8894ce 100644 --- a/.github/workflows/cmake-format-fix.yaml +++ b/.github/workflows/cmake-format-fix.yaml @@ -59,8 +59,7 @@ jobs: runs-on: ubuntu-latest name: Parse command if: > - inputs.ref != '' || - github.event_name == 'workflow_dispatch' || ( + inputs.ref != '' || github.event_name == 'workflow_dispatch' || ( github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(fromJSON('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association) && diff --git a/.github/workflows/header-guards-fix.yaml b/.github/workflows/header-guards-fix.yaml index 05935630..e0bbb7e3 100644 --- a/.github/workflows/header-guards-fix.yaml +++ b/.github/workflows/header-guards-fix.yaml @@ -59,8 +59,7 @@ jobs: runs-on: ubuntu-latest name: Parse command if: > - inputs.ref != '' || - github.event_name == 'workflow_dispatch' || ( + inputs.ref != '' || github.event_name == 'workflow_dispatch' || ( github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(fromJSON('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association) && diff --git a/.github/workflows/jsonnet-format-fix.yaml b/.github/workflows/jsonnet-format-fix.yaml index 88c1df42..aff39b7e 100644 --- a/.github/workflows/jsonnet-format-fix.yaml +++ b/.github/workflows/jsonnet-format-fix.yaml @@ -59,8 +59,7 @@ jobs: runs-on: ubuntu-latest name: Parse command if: > - inputs.ref != '' || - github.event_name == 'workflow_dispatch' || ( + inputs.ref != '' || github.event_name == 'workflow_dispatch' || ( github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(fromJSON('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association) && diff --git a/.github/workflows/markdown-fix.yaml b/.github/workflows/markdown-fix.yaml index 424a8138..c75c0d78 100644 --- a/.github/workflows/markdown-fix.yaml +++ b/.github/workflows/markdown-fix.yaml @@ -59,8 +59,7 @@ jobs: runs-on: ubuntu-latest name: Parse command if: > - inputs.ref != '' || - github.event_name == 'workflow_dispatch' || ( + inputs.ref != '' || github.event_name == 'workflow_dispatch' || ( github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(fromJSON('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association) && diff --git a/.github/workflows/python-fix.yaml b/.github/workflows/python-fix.yaml index 5c676556..a4ed9b83 100644 --- a/.github/workflows/python-fix.yaml +++ b/.github/workflows/python-fix.yaml @@ -59,8 +59,7 @@ jobs: runs-on: ubuntu-latest name: Parse command if: > - inputs.ref != '' || - github.event_name == 'workflow_dispatch' || ( + inputs.ref != '' || github.event_name == 'workflow_dispatch' || ( github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(fromJSON('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association) && diff --git a/.github/workflows/yaml-fix.yaml b/.github/workflows/yaml-fix.yaml index b20e2257..842c65d7 100644 --- a/.github/workflows/yaml-fix.yaml +++ b/.github/workflows/yaml-fix.yaml @@ -59,8 +59,7 @@ jobs: runs-on: ubuntu-latest name: Parse command if: > - inputs.ref != '' || - github.event_name == 'workflow_dispatch' || ( + inputs.ref != '' || github.event_name == 'workflow_dispatch' || ( github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(fromJSON('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association) && From 749ae5b5483b49422c77bae5bc8b92afc1df21dc Mon Sep 17 00:00:00 2001 From: Chris Green Date: Thu, 12 Mar 2026 15:45:51 -0500 Subject: [PATCH 10/10] Adding missing permissions for issue comments Per https://github.com/Framework-R-D/phlex/pull/411#discussion_r2927240877 --- .github/workflows/clang-tidy-fix.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/clang-tidy-fix.yaml b/.github/workflows/clang-tidy-fix.yaml index 97936885..e6edcaca 100644 --- a/.github/workflows/clang-tidy-fix.yaml +++ b/.github/workflows/clang-tidy-fix.yaml @@ -21,6 +21,7 @@ name: Clang-Tidy Fix permissions: pull-requests: write contents: write + issues: write jobs: setup: