From 1d4cad93e44d4093c0fc0b15e6f6d060379447d7 Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Fri, 20 Mar 2026 14:23:28 -0500 Subject: [PATCH 1/3] Add C++ header-guard checks/fixes to pre-commit --- .pre-commit-config.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e3d6073f..39e25e91 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,6 +22,13 @@ repos: hooks: - id: clang-format types_or: [c++, c, cuda] + - repo: local + hooks: + - id: fix-header-guards + name: fix C++ header guards + entry: python3 scripts/fix_header_guards.py + language: system + files: \.(h|hpp)$ - repo: https://github.com/BlankSpruce/gersemi rev: 0.26.0 hooks: From 3a7ceaff4ad088054ffd35ac2042246f951646b2 Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Fri, 20 Mar 2026 14:28:31 -0500 Subject: [PATCH 2/3] Update pre-commit versions and apply changes --- .github/workflows/cmake-build.yaml | 5 +- .pre-commit-config.yaml | 6 +- .../extra_member/track_start.hpp | 6 +- test/form/data_products/track_start.hpp | 6 +- test/form/test_helpers.hpp | 6 +- test/form/test_utils.hpp | 6 +- test/form/toy_tracker.hpp | 6 +- test/python/suffix.py | 146 ++++++++++++------ 8 files changed, 115 insertions(+), 72 deletions(-) diff --git a/.github/workflows/cmake-build.yaml b/.github/workflows/cmake-build.yaml index d68ea35e..5741ad3a 100644 --- a/.github/workflows/cmake-build.yaml +++ b/.github/workflows/cmake-build.yaml @@ -218,9 +218,8 @@ jobs: cmake-build-skipped: needs: [setup] if: > - needs.setup.result == 'success' && github.event_name != 'workflow_dispatch' && - !inputs.skip-relevance-check && needs.setup.outputs.is_act != 'true' && - needs.setup.outputs.has_changes != 'true' + needs.setup.result == 'success' && github.event_name != 'workflow_dispatch' && !inputs.skip-relevance-check && + needs.setup.outputs.is_act != 'true' && needs.setup.outputs.has_changes != 'true' runs-on: ubuntu-latest permissions: contents: read diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 39e25e91..17d55f89 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - id: check-executables-have-shebangs - id: mixed-line-ending - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.6 + rev: v0.15.7 hooks: - id: ruff-format types_or: [python, pyi] @@ -30,11 +30,11 @@ repos: language: system files: \.(h|hpp)$ - repo: https://github.com/BlankSpruce/gersemi - rev: 0.26.0 + rev: 0.26.1 hooks: - id: gersemi - repo: https://github.com/google/go-jsonnet - rev: v0.21.0 + rev: v0.22.0-rc1 hooks: - id: jsonnet-format - id: jsonnet-lint diff --git a/test/form/data_products/extra_member/track_start.hpp b/test/form/data_products/extra_member/track_start.hpp index b93e744a..5e425b0d 100644 --- a/test/form/data_products/extra_member/track_start.hpp +++ b/test/form/data_products/extra_member/track_start.hpp @@ -3,8 +3,8 @@ #include -#ifndef TRACKSTART_HPP -#define TRACKSTART_HPP +#ifndef TEST_FORM_DATA_PRODUCTS_EXTRA_MEMBER_TRACK_START_HPP +#define TEST_FORM_DATA_PRODUCTS_EXTRA_MEMBER_TRACK_START_HPP class TrackStart { public: @@ -36,4 +36,4 @@ class TrackStart { std::ostream& operator<<(std::ostream& os, TrackStart const& track); -#endif //TRACKSTART_HPP +#endif // TEST_FORM_DATA_PRODUCTS_EXTRA_MEMBER_TRACK_START_HPP diff --git a/test/form/data_products/track_start.hpp b/test/form/data_products/track_start.hpp index bafbe92a..ceb08e4f 100644 --- a/test/form/data_products/track_start.hpp +++ b/test/form/data_products/track_start.hpp @@ -3,8 +3,8 @@ #include -#ifndef __TRACK_START_H__ -#define __TRACK_START_H__ +#ifndef TEST_FORM_DATA_PRODUCTS_TRACK_START_HPP +#define TEST_FORM_DATA_PRODUCTS_TRACK_START_HPP class TrackStart { public: @@ -28,4 +28,4 @@ class TrackStart { std::ostream& operator<<(std::ostream& os, TrackStart const& track); -#endif //__TRACK_START_H__ +#endif // TEST_FORM_DATA_PRODUCTS_TRACK_START_HPP diff --git a/test/form/test_helpers.hpp b/test/form/test_helpers.hpp index 7a831766..57292251 100644 --- a/test/form/test_helpers.hpp +++ b/test/form/test_helpers.hpp @@ -1,7 +1,7 @@ -#ifndef TEST_HELPERS_HPP -#define TEST_HELPERS_HPP +#ifndef TEST_FORM_TEST_HELPERS_HPP +#define TEST_FORM_TEST_HELPERS_HPP #include "data_products/track_start.hpp" #include "form/form.hpp" -#endif +#endif // TEST_FORM_TEST_HELPERS_HPP diff --git a/test/form/test_utils.hpp b/test/form/test_utils.hpp index f1c10d36..88ace4b8 100644 --- a/test/form/test_utils.hpp +++ b/test/form/test_utils.hpp @@ -1,7 +1,7 @@ //Utilities to make FORM unit tests easier to write and maintain -#ifndef FORM_TEST_UTILS_HPP -#define FORM_TEST_UTILS_HPP +#ifndef TEST_FORM_TEST_UTILS_HPP +#define TEST_FORM_TEST_UTILS_HPP #include "storage/istorage.hpp" #include "storage/storage_associative_container.hpp" @@ -124,4 +124,4 @@ namespace form::test { } // namespace form::test -#endif // FORM_TEST_UTILS_HPP +#endif // TEST_FORM_TEST_UTILS_HPP diff --git a/test/form/toy_tracker.hpp b/test/form/toy_tracker.hpp index 6d069baf..d978171e 100644 --- a/test/form/toy_tracker.hpp +++ b/test/form/toy_tracker.hpp @@ -1,6 +1,6 @@ //A toy PHLEX algorithm that takes a maximum number of TrackStarts to generate and generates random points for them. -#ifndef __TOY_TRACKER_H__ -#define __TOY_TRACKER_H__ +#ifndef TEST_FORM_TOY_TRACKER_HPP +#define TEST_FORM_TOY_TRACKER_HPP #include #include @@ -19,4 +19,4 @@ class ToyTracker { int32_t random_max = 32768 * 32768; }; -#endif +#endif // TEST_FORM_TOY_TRACKER_HPP diff --git a/test/python/suffix.py b/test/python/suffix.py index 4eefc264..0cae6a31 100644 --- a/test/python/suffix.py +++ b/test/python/suffix.py @@ -5,38 +5,44 @@ """ - def constant_one(i: int) -> int: """Constant 1.""" return 1 + def constant_two(i: int) -> int: """Constant 2.""" return 2 + def constant_three(i: int) -> int: """Constant 3.""" return 3 + def constant_four(i: int) -> int: """Constant 4.""" return 4 + def observe_one(i: int) -> None: """Observe i; expect 1.""" assert i == 1 + def observe_two(i: int, j: int) -> None: """Observe (i, j); expect (1, 2).""" assert i == 1 assert j == 2 + def observe_three(i: int, j: int, k: int) -> None: """Observe (i, j, k); expect (1, 2, 3).""" assert i == 1 assert j == 2 assert k == 3 + def observe_four(i: int, j: int, k: int, ll: int) -> None: """Observe (i, j, k, l); expect (1, 2, 3, 4).""" assert i == 1 @@ -59,10 +65,12 @@ def PHLEX_REGISTER_ALGORITHMS(m, config): None """ # tests for error handling of input specifications - for input_query in ({"creator": 42, "layer": "event", "suffix": "i"}, - {"creator": "input", "layer": 42, "suffix": "i"}, - {"layer": "event", "suffix": "i"}, - {"creator": "input", "suffix": "i"}): + for input_query in ( + {"creator": 42, "layer": "event", "suffix": "i"}, + {"creator": "input", "layer": 42, "suffix": "i"}, + {"layer": "event", "suffix": "i"}, + {"creator": "input", "suffix": "i"}, + ): try: m.transform(constant_one, input_family=[input_query], output_products=["output_one"]) assert not "supposed to be here" @@ -71,67 +79,103 @@ def PHLEX_REGISTER_ALGORITHMS(m, config): assert "or not a string" in str(e) # transforms with suffix to be used without suffix - m.transform(constant_one, input_family=[ - {"creator": "input", "layer": "event", "suffix": "i"}, - ], - output_products=["output_one"]) - m.transform(constant_two, input_family=[ - {"creator": "input", "layer": "event", "suffix": "i"}, - ], - output_products=["output_two"]) - m.transform(constant_three, input_family=[ - {"creator": "input", "layer": "event", "suffix": "i"}, - ], - output_products=["output_three"]) + m.transform( + constant_one, + input_family=[ + {"creator": "input", "layer": "event", "suffix": "i"}, + ], + output_products=["output_one"], + ) + m.transform( + constant_two, + input_family=[ + {"creator": "input", "layer": "event", "suffix": "i"}, + ], + output_products=["output_two"], + ) + m.transform( + constant_three, + input_family=[ + {"creator": "input", "layer": "event", "suffix": "i"}, + ], + output_products=["output_three"], + ) # observers without suffix # test for failing suffix (incorrect type: not a string) try: - m.observe(observe_one, input_family=[ - {"creator": "constant_one", "layer": "event", "suffix": 42}, - ]) + m.observe( + observe_one, + input_family=[ + {"creator": "constant_one", "layer": "event", "suffix": 42}, + ], + ) assert not "supposed to be here" except TypeError as e: assert "is not a string" in str(e) - m.observe(observe_one, input_family=[ - {"creator": "constant_one", "layer": "event"}, - ]) + m.observe( + observe_one, + input_family=[ + {"creator": "constant_one", "layer": "event"}, + ], + ) # regular - m.observe(observe_two, input_family=[ - {"creator": "constant_one", "layer": "event"}, - {"creator": "constant_two", "layer": "event"}, - ]) - m.observe(observe_three, input_family=[ - {"creator": "constant_one", "layer": "event"}, - {"creator": "constant_two", "layer": "event"}, - {"creator": "constant_three", "layer": "event"}, - ]) + m.observe( + observe_two, + input_family=[ + {"creator": "constant_one", "layer": "event"}, + {"creator": "constant_two", "layer": "event"}, + ], + ) + m.observe( + observe_three, + input_family=[ + {"creator": "constant_one", "layer": "event"}, + {"creator": "constant_two", "layer": "event"}, + {"creator": "constant_three", "layer": "event"}, + ], + ) # test for unsupported number of arguments (remove test once support # to arbitrary number of arguments becomes available try: - m.observe(observe_three, input_family=[ - {"creator": "constant_one", "layer": "event"}, - {"creator": "constant_two", "layer": "event"}, - {"creator": "constant_three", "layer": "event"}, - {"creator": "constant_four", "layer": "event"}, - ]) + m.observe( + observe_three, + input_family=[ + {"creator": "constant_one", "layer": "event"}, + {"creator": "constant_two", "layer": "event"}, + {"creator": "constant_three", "layer": "event"}, + {"creator": "constant_four", "layer": "event"}, + ], + ) assert not "supposed to be here" except TypeError: - pass # noqa + pass # noqa # observers with suffix - m.observe(observe_one, name="observe_one_ws", input_family=[ - {"creator": "constant_one", "layer": "event", "suffix": "output_one"}, - ]) - m.observe(observe_two, name="observe_two_ws", input_family=[ - {"creator": "constant_one", "layer": "event", "suffix": "output_one"}, - {"creator": "constant_two", "layer": "event", "suffix": "output_two"}, - ]) - m.observe(observe_three, name="observe_three_ws", input_family=[ - {"creator": "constant_one", "layer": "event", "suffix": "output_one"}, - {"creator": "constant_two", "layer": "event", "suffix": "output_two"}, - {"creator": "constant_three", "layer": "event", "suffix": "output_three"}, - ]) + m.observe( + observe_one, + name="observe_one_ws", + input_family=[ + {"creator": "constant_one", "layer": "event", "suffix": "output_one"}, + ], + ) + m.observe( + observe_two, + name="observe_two_ws", + input_family=[ + {"creator": "constant_one", "layer": "event", "suffix": "output_one"}, + {"creator": "constant_two", "layer": "event", "suffix": "output_two"}, + ], + ) + m.observe( + observe_three, + name="observe_three_ws", + input_family=[ + {"creator": "constant_one", "layer": "event", "suffix": "output_one"}, + {"creator": "constant_two", "layer": "event", "suffix": "output_two"}, + {"creator": "constant_three", "layer": "event", "suffix": "output_three"}, + ], + ) From b26aae3bd4aa84ade5a6d8217226b4d8900666a1 Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Fri, 20 Mar 2026 15:09:05 -0500 Subject: [PATCH 3/3] Use pre-commit to check/apply all formatting --- .github/workflows/clang-format-check.yaml | 76 ----------- .github/workflows/clang-format-fix.yaml | 123 ------------------ .github/workflows/cmake-format-check.yaml | 116 ----------------- .github/workflows/cmake-format-fix.yaml | 131 ------------------- .github/workflows/format-all.yaml | 128 ------------------- .github/workflows/header-guards-check.yaml | 108 ---------------- .github/workflows/header-guards-fix.yaml | 128 ------------------- .github/workflows/jsonnet-format-check.yaml | 110 ---------------- .github/workflows/jsonnet-format-fix.yaml | 129 ------------------- .github/workflows/markdown-check.yaml | 114 ----------------- .github/workflows/markdown-fix.yaml | 131 ------------------- .github/workflows/pre-commit-check.yaml | 41 ++++++ .github/workflows/pre-commit-fix.yaml | 77 +++++++++++ .github/workflows/python-check.yaml | 128 ------------------- .github/workflows/python-fix.yaml | 135 -------------------- .github/workflows/yaml-check.yaml | 74 ----------- .github/workflows/yaml-fix.yaml | 131 ------------------- 17 files changed, 118 insertions(+), 1762 deletions(-) delete mode 100644 .github/workflows/clang-format-check.yaml delete mode 100644 .github/workflows/clang-format-fix.yaml delete mode 100644 .github/workflows/cmake-format-check.yaml delete mode 100644 .github/workflows/cmake-format-fix.yaml delete mode 100644 .github/workflows/format-all.yaml delete mode 100644 .github/workflows/header-guards-check.yaml delete mode 100644 .github/workflows/header-guards-fix.yaml delete mode 100644 .github/workflows/jsonnet-format-check.yaml delete mode 100644 .github/workflows/jsonnet-format-fix.yaml delete mode 100644 .github/workflows/markdown-check.yaml delete mode 100644 .github/workflows/markdown-fix.yaml create mode 100644 .github/workflows/pre-commit-check.yaml create mode 100644 .github/workflows/pre-commit-fix.yaml delete mode 100644 .github/workflows/python-check.yaml delete mode 100644 .github/workflows/python-fix.yaml delete mode 100644 .github/workflows/yaml-check.yaml delete mode 100644 .github/workflows/yaml-fix.yaml diff --git a/.github/workflows/clang-format-check.yaml b/.github/workflows/clang-format-check.yaml deleted file mode 100644 index ae73a006..00000000 --- a/.github/workflows/clang-format-check.yaml +++ /dev/null @@ -1,76 +0,0 @@ -name: Clang-Format Check -run-name: "${{ github.actor }} checking C++ code format" - -permissions: - contents: read - pull-requests: read - -"on": - pull_request: - workflow_dispatch: - inputs: - ref: - description: "The branch, ref, or SHA to checkout. Defaults to the repository's default branch." - required: false - type: string - -jobs: - setup: - runs-on: ubuntu-latest - outputs: - is_act: ${{ steps.setup.outputs.is_act }} - ref: ${{ steps.setup.outputs.ref }} - repo: ${{ steps.setup.outputs.repo }} - base_sha: ${{ steps.setup.outputs.base_sha }} - pr_number: ${{ steps.setup.outputs.pr_number }} - checkout_path: ${{ steps.setup.outputs.checkout_path }} - has_changes: ${{ steps.setup.outputs.has_changes }} - steps: - - name: Workflow setup - id: setup - uses: Framework-R-D/phlex/.github/actions/workflow-setup@main - with: - file-type: cpp - - clang-format-check: - needs: setup - if: > - always() && (github.event_name == 'workflow_dispatch' || needs.setup.outputs.has_changes == 'true') - runs-on: ubuntu-latest - permissions: - contents: read - - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - ref: ${{ needs.setup.outputs.ref }} - path: ${{ needs.setup.outputs.checkout_path }} - repository: ${{ needs.setup.outputs.repo }} - persist-credentials: false - - - name: Announce clang-format check - run: echo "➡️ Running clang-format check..." - - - name: Run clang-format lint - id: lint - uses: DoozyX/clang-format-lint-action@bcb4eb2cb0d707ee4f3e5cc3b456eb075f12cf73 # v0.20 - with: - source: "./${{ needs.setup.outputs.checkout_path }}" - clangFormatVersion: 20 - extensions: cpp,hpp,cpp.in,hpp.in - continue-on-error: true - - - name: Evaluate clang-format result - if: always() && steps.lint.outcome != 'skipped' - env: - REPO: ${{ needs.setup.outputs.repo }} - run: | - REPO_NAME="${REPO##*/}" - if [ "${{ steps.lint.outcome }}" = 'success' ]; then - echo "✅ clang-format check passed." - else - echo "::error::clang-format check failed. Please review the output above for details." - echo "::error::Comment '@${REPO_NAME}bot format' on the PR to attempt auto-fix." - exit 1 - fi diff --git a/.github/workflows/clang-format-fix.yaml b/.github/workflows/clang-format-fix.yaml deleted file mode 100644 index 644c725a..00000000 --- a/.github/workflows/clang-format-fix.yaml +++ /dev/null @@ -1,123 +0,0 @@ -name: Clang-Format Fix -run-name: "${{ github.actor }} fixing C++ code format" - -"on": - issue_comment: - types: - - created - 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." - required: false - type: string - workflow_call: - inputs: - checkout-path: - description: "Path to check out code to" - required: false - type: string - ref: - description: "The branch name to checkout and push fixes to (must be a branch, not a commit SHA)" - required: true - type: string - repo: - description: "The repository to checkout from" - required: true - type: string - skip-comment: - description: "Skip posting PR comments" - required: false - type: boolean - default: false - outputs: - changes: - description: "Whether any fixes were applied" - value: ${{ jobs.apply_formatting.outputs.changes }} - pushed: - description: "Whether the fixes were pushed to the remote branch" - value: ${{ jobs.apply_formatting.outputs.pushed }} - commit_sha: - description: "The full commit SHA of the applied fixes" - value: ${{ jobs.apply_formatting.outputs.commit_sha }} - commit_sha_short: - description: "The short commit SHA of the applied fixes" - value: ${{ jobs.apply_formatting.outputs.commit_sha_short }} - patch_name: - description: "Name of the patch file if fixes could not be pushed" - value: ${{ jobs.apply_formatting.outputs.patch_name }} - -permissions: - pull-requests: write - contents: write - issues: write - -jobs: - setup: - runs-on: ubuntu-latest - name: Parse command - if: > - 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)) - ) - outputs: - ref: ${{ steps.setup.outputs.ref }} - repo: ${{ steps.setup.outputs.repo }} - checkout_path: ${{ steps.setup.outputs.checkout_path }} - steps: - - 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: setup - if: ${{ needs.setup.result == 'success' }} - outputs: - changes: ${{ steps.handle_commit.outputs.changes }} - pushed: ${{ steps.handle_commit.outputs.pushed }} - commit_sha: ${{ steps.handle_commit.outputs.commit_sha }} - commit_sha_short: ${{ steps.handle_commit.outputs.commit_sha_short }} - patch_name: ${{ steps.handle_commit.outputs.patch_name }} - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - 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 - with: - source: "./${{ needs.setup.outputs.checkout_path }}" - clangFormatVersion: 20 - inplace: "True" - extensions: cpp,hpp,cpp.in,hpp.in - - - name: Handle fix commit - id: handle_commit - uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main - with: - tool: clang-format - working-directory: ${{ needs.setup.outputs.checkout_path }} - token: ${{ secrets.WORKFLOW_PAT }} - pr-info-ref: ${{ needs.setup.outputs.ref }} - pr-info-repo: ${{ needs.setup.outputs.repo }} - skip-comment: ${{ inputs.skip-comment }} - - - name: Update PR comment reactions - if: always() && github.event_name == 'issue_comment' && !inputs.skip-comment - uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main - with: - status: ${{ job.status }} diff --git a/.github/workflows/cmake-format-check.yaml b/.github/workflows/cmake-format-check.yaml deleted file mode 100644 index fe6ae076..00000000 --- a/.github/workflows/cmake-format-check.yaml +++ /dev/null @@ -1,116 +0,0 @@ -name: CMake Format Check -run-name: "${{ github.actor }} checking CMake format" - -permissions: - contents: read - pull-requests: read - -"on": - pull_request: - workflow_dispatch: - inputs: - ref: - description: "The branch, ref, or SHA to checkout. Defaults to the repository's default branch." - required: false - type: string - workflow_call: - inputs: - checkout-path: - description: "Path to check out code to" - required: false - type: string - skip-relevance-check: - description: "Bypass relevance check" - required: false - type: boolean - default: false - pr-base-sha: - description: "Base SHA of the PR for relevance check" - required: false - type: string - pr-head-sha: - description: "Head SHA of the PR for relevance check" - required: false - type: string - ref: - description: "The branch, ref, or SHA to checkout" - required: false - type: string - repo: - description: "The repository to checkout from" - required: false - type: string - -jobs: - setup: - runs-on: ubuntu-latest - outputs: - is_act: ${{ steps.setup.outputs.is_act }} - ref: ${{ steps.setup.outputs.ref }} - repo: ${{ steps.setup.outputs.repo }} - base_sha: ${{ steps.setup.outputs.base_sha }} - pr_number: ${{ steps.setup.outputs.pr_number }} - checkout_path: ${{ steps.setup.outputs.checkout_path }} - has_changes: ${{ steps.setup.outputs.has_changes }} - steps: - - name: Workflow setup - id: setup - uses: Framework-R-D/phlex/.github/actions/workflow-setup@main - 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 - if: > - always() && ( - github.event_name == 'workflow_dispatch' || - inputs.skip-relevance-check || - needs.setup.outputs.has_changes == 'true' - ) - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - ref: ${{ needs.setup.outputs.ref }} - path: ${{ needs.setup.outputs.checkout_path }} - repository: ${{ needs.setup.outputs.repo }} - persist-credentials: false - - - name: Set up Python - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 - with: - python-version: "3.x" - - - name: Install gersemi - run: pip install gersemi - - - name: Check CMake formatting - id: lint - env: - CHECKOUT_PATH: ${{ needs.setup.outputs.checkout_path }} - run: | - echo "➡️ Checking CMake file formatting..." - gersemi --check "${CHECKOUT_PATH}" - continue-on-error: true - - - name: Evaluate CMake formatting result - if: always() && steps.lint.outcome != 'skipped' - env: - REPO: ${{ needs.setup.outputs.repo }} - # yamllint disable rule:line-length - run: | - REPO_NAME="${REPO##*/}" - if [ "${{ steps.lint.outcome }}" = 'success' ]; then - echo "✅ All CMake files are properly formatted." - else - echo "::error::Found files with formatting issues." - echo "::error::Run 'gersemi -i ' locally or comment '@${REPO_NAME}bot format' on the PR to auto-fix." - exit 1 - fi - # yamllint enable diff --git a/.github/workflows/cmake-format-fix.yaml b/.github/workflows/cmake-format-fix.yaml deleted file mode 100644 index 2bafb972..00000000 --- a/.github/workflows/cmake-format-fix.yaml +++ /dev/null @@ -1,131 +0,0 @@ -name: CMake Format Fix -run-name: "${{ github.actor }} fixing CMake format" - -"on": - issue_comment: - types: - - created - 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." - required: false - type: string - workflow_call: - inputs: - checkout-path: - description: "Path to check out code to" - required: false - type: string - ref: - description: "The branch name to checkout and push fixes to (must be a branch, not a commit SHA)" - required: true - type: string - repo: - description: "The repository to checkout from" - required: true - type: string - skip-comment: - description: "Skip posting PR comments" - required: false - type: boolean - default: false - outputs: - changes: - description: "Whether any fixes were applied" - value: ${{ jobs.apply_cmake_formatting.outputs.changes }} - pushed: - description: "Whether the fixes were pushed to the remote branch" - value: ${{ jobs.apply_cmake_formatting.outputs.pushed }} - commit_sha: - description: "The full commit SHA of the applied fixes" - value: ${{ jobs.apply_cmake_formatting.outputs.commit_sha }} - commit_sha_short: - description: "The short commit SHA of the applied fixes" - value: ${{ jobs.apply_cmake_formatting.outputs.commit_sha_short }} - patch_name: - description: "Name of the patch file if fixes could not be pushed" - value: ${{ jobs.apply_cmake_formatting.outputs.patch_name }} - -permissions: - pull-requests: write - contents: write - issues: write - -jobs: - setup: - runs-on: ubuntu-latest - name: Parse command - if: > - 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)) - ) - outputs: - ref: ${{ steps.setup.outputs.ref }} - repo: ${{ steps.setup.outputs.repo }} - checkout_path: ${{ steps.setup.outputs.checkout_path }} - steps: - - 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: setup - if: needs.setup.result == 'success' - outputs: - changes: ${{ steps.handle_commit.outputs.changes }} - pushed: ${{ steps.handle_commit.outputs.pushed }} - commit_sha: ${{ steps.handle_commit.outputs.commit_sha }} - commit_sha_short: ${{ steps.handle_commit.outputs.commit_sha_short }} - patch_name: ${{ steps.handle_commit.outputs.patch_name }} - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - path: ${{ needs.setup.outputs.checkout_path }} - ref: ${{ needs.setup.outputs.ref }} - repository: ${{ needs.setup.outputs.repo }} - token: ${{ secrets.WORKFLOW_PAT }} - - - name: Set up Python - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 - with: - python-version: "3.x" - - - name: Install gersemi - run: pip install gersemi - - - name: Apply CMake formatting - working-directory: ${{ needs.setup.outputs.checkout_path }} - run: | - echo "Applying CMake formatting..." - gersemi -i . - - - name: Handle fix commit - id: handle_commit - uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main - with: - tool: cmake-format - working-directory: ${{ needs.setup.outputs.checkout_path }} - token: ${{ secrets.WORKFLOW_PAT }} - pr-info-ref: ${{ needs.setup.outputs.ref }} - pr-info-repo: ${{ needs.setup.outputs.repo }} - skip-comment: ${{ inputs.skip-comment }} - - - name: Update PR comment reactions - if: always() && github.event_name == 'issue_comment' && !inputs.skip-comment - uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main - with: - status: ${{ job.status }} diff --git a/.github/workflows/format-all.yaml b/.github/workflows/format-all.yaml deleted file mode 100644 index a0d267e6..00000000 --- a/.github/workflows/format-all.yaml +++ /dev/null @@ -1,128 +0,0 @@ -name: Format All -run-name: "${{ github.actor }} fixing all format issues" - -on: - issue_comment: - types: - - created - -permissions: - pull-requests: write - contents: write - issues: write - -jobs: - setup: - runs-on: ubuntu-latest - 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.setup.outputs.ref }} - repo: ${{ steps.setup.outputs.repo }} - steps: - - name: Workflow setup - id: setup - uses: Framework-R-D/phlex/.github/actions/workflow-setup@main - with: - mode: fix - - clang-format: - needs: setup - uses: ./.github/workflows/clang-format-fix.yaml - with: - ref: ${{ needs.setup.outputs.ref }} - repo: ${{ needs.setup.outputs.repo }} - skip-comment: true - secrets: inherit - - cmake-format: - needs: setup - uses: ./.github/workflows/cmake-format-fix.yaml - with: - ref: ${{ needs.setup.outputs.ref }} - repo: ${{ needs.setup.outputs.repo }} - skip-comment: true - secrets: inherit - - header-guards: - needs: setup - uses: ./.github/workflows/header-guards-fix.yaml - with: - ref: ${{ needs.setup.outputs.ref }} - repo: ${{ needs.setup.outputs.repo }} - skip-comment: true - secrets: inherit - - jsonnet-format: - needs: setup - uses: ./.github/workflows/jsonnet-format-fix.yaml - with: - ref: ${{ needs.setup.outputs.ref }} - repo: ${{ needs.setup.outputs.repo }} - skip-comment: true - secrets: inherit - - markdown: - needs: setup - uses: ./.github/workflows/markdown-fix.yaml - with: - ref: ${{ needs.setup.outputs.ref }} - repo: ${{ needs.setup.outputs.repo }} - skip-comment: true - secrets: inherit - - python: - needs: setup - uses: ./.github/workflows/python-fix.yaml - with: - ref: ${{ needs.setup.outputs.ref }} - repo: ${{ needs.setup.outputs.repo }} - skip-comment: true - secrets: inherit - - yaml: - needs: setup - uses: ./.github/workflows/yaml-fix.yaml - with: - ref: ${{ needs.setup.outputs.ref }} - repo: ${{ needs.setup.outputs.repo }} - skip-comment: true - secrets: inherit - - combine-results: - 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 - uses: Framework-R-D/phlex/.github/actions/collect-format-results@main - with: - results-json: | - { - "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 - uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1 - with: - message: ${{ steps.collect.outputs.message }} - - - name: Update PR comment reactions - 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 deleted file mode 100644 index 59b76581..00000000 --- a/.github/workflows/header-guards-check.yaml +++ /dev/null @@ -1,108 +0,0 @@ -name: Header Guards Check -run-name: "${{ github.actor }} checking header guards" - -permissions: - contents: read - pull-requests: read - -"on": - pull_request: - workflow_dispatch: - inputs: - ref: - description: "The branch, ref, or SHA to checkout. Defaults to the repository's default branch." - required: false - type: string - workflow_call: - inputs: - checkout-path: - description: "Path to check out code to" - required: false - type: string - skip-relevance-check: - description: "Bypass relevance check" - required: false - type: boolean - default: false - pr-base-sha: - description: "Base SHA of the PR for relevance check" - required: false - type: string - pr-head-sha: - description: "Head SHA of the PR for relevance check" - required: false - type: string - ref: - description: "The branch, ref, or SHA to checkout" - required: false - type: string - repo: - description: "The repository to checkout from" - required: false - type: string - -jobs: - setup: - runs-on: ubuntu-latest - outputs: - is_act: ${{ steps.setup.outputs.is_act }} - ref: ${{ steps.setup.outputs.ref }} - repo: ${{ steps.setup.outputs.repo }} - base_sha: ${{ steps.setup.outputs.base_sha }} - pr_number: ${{ steps.setup.outputs.pr_number }} - checkout_path: ${{ steps.setup.outputs.checkout_path }} - has_changes: ${{ steps.setup.outputs.has_changes }} - steps: - - name: Workflow setup - id: setup - uses: Framework-R-D/phlex/.github/actions/workflow-setup@main - 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 - if: > - always() && ( - github.event_name == 'workflow_dispatch' || - inputs.skip-relevance-check || - needs.setup.outputs.has_changes == 'true' - ) - runs-on: ubuntu-latest - permissions: - contents: read - - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - ref: ${{ needs.setup.outputs.ref }} - path: ${{ needs.setup.outputs.checkout_path }} - repository: ${{ needs.setup.outputs.repo }} - persist-credentials: false - - - name: Set up Python - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 - with: - python-version: "3.12" - - - name: Check header guards - id: check - 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 - - - name: Report results - if: always() && steps.check.outputs.has_issues == 'true' - env: - REPO: ${{ needs.setup.outputs.repo }} - run: | - REPO_NAME="${REPO##*/}" - echo "::error::Header guard check failed." - echo "::error::Comment '@${REPO_NAME}bot header-guards-fix' on the PR to auto-fix." - exit 1 diff --git a/.github/workflows/header-guards-fix.yaml b/.github/workflows/header-guards-fix.yaml deleted file mode 100644 index 86de1854..00000000 --- a/.github/workflows/header-guards-fix.yaml +++ /dev/null @@ -1,128 +0,0 @@ -name: Header Guards Fix -run-name: "${{ github.actor }} fixing header guards" - -"on": - issue_comment: - types: - - created - workflow_call: - inputs: - checkout-path: - description: "Path to check out code to" - required: false - type: string - ref: - description: "The branch name to checkout and push fixes to (must be a branch, not a commit SHA)" - required: true - type: string - repo: - description: "The repository to checkout from" - required: true - type: string - skip-comment: - description: "Skip posting PR comments" - required: false - type: boolean - default: false - outputs: - changes: - description: "Whether any fixes were applied" - value: ${{ jobs.apply_fixes.outputs.changes }} - pushed: - description: "Whether the fixes were pushed to the remote branch" - value: ${{ jobs.apply_fixes.outputs.pushed }} - commit_sha: - description: "The full commit SHA of the applied fixes" - value: ${{ jobs.apply_fixes.outputs.commit_sha }} - commit_sha_short: - description: "The short commit SHA of the applied fixes" - value: ${{ jobs.apply_fixes.outputs.commit_sha_short }} - patch_name: - description: "Name of the patch file if fixes could not be pushed" - value: ${{ jobs.apply_fixes.outputs.patch_name }} - 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." - required: false - type: string - -permissions: - pull-requests: write - contents: write - issues: write - -jobs: - setup: - runs-on: ubuntu-latest - name: Parse command - if: > - 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)) - ) - outputs: - ref: ${{ steps.setup.outputs.ref }} - repo: ${{ steps.setup.outputs.repo }} - checkout_path: ${{ steps.setup.outputs.checkout_path }} - steps: - - 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: setup - if: needs.setup.result == 'success' - outputs: - changes: ${{ steps.handle_commit.outputs.changes }} - pushed: ${{ steps.handle_commit.outputs.pushed }} - commit_sha: ${{ steps.handle_commit.outputs.commit_sha }} - commit_sha_short: ${{ steps.handle_commit.outputs.commit_sha_short }} - patch_name: ${{ steps.handle_commit.outputs.patch_name }} - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - path: ${{ needs.setup.outputs.checkout_path }} - ref: ${{ needs.setup.outputs.ref }} - repository: ${{ needs.setup.outputs.repo }} - token: ${{ secrets.WORKFLOW_PAT }} - - - name: Set up Python - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 - with: - python-version: "3.12" - - - name: Fix header guards - working-directory: ${{ needs.setup.outputs.checkout_path }} - run: | - echo "Fixing header guards..." - python3 scripts/fix_header_guards.py --root . phlex plugins form || true - - - name: Handle fix commit - id: handle_commit - uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main - with: - tool: header-guards - working-directory: ${{ needs.setup.outputs.checkout_path }} - token: ${{ secrets.WORKFLOW_PAT }} - pr-info-ref: ${{ needs.setup.outputs.ref }} - pr-info-repo: ${{ needs.setup.outputs.repo }} - skip-comment: ${{ inputs.skip-comment }} - - - name: Update PR comment reactions - if: always() && github.event_name == 'issue_comment' && !inputs.skip-comment - uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main - with: - status: ${{ job.status }} diff --git a/.github/workflows/jsonnet-format-check.yaml b/.github/workflows/jsonnet-format-check.yaml deleted file mode 100644 index 5e5b9fa7..00000000 --- a/.github/workflows/jsonnet-format-check.yaml +++ /dev/null @@ -1,110 +0,0 @@ -name: Jsonnet Format Check -run-name: "${{ github.actor }} checking Jsonnet format" - -permissions: - contents: read - pull-requests: read - -"on": - pull_request: - workflow_dispatch: - inputs: - ref: - description: "The branch, ref, or SHA to checkout. Defaults to the repository's default branch." - required: false - type: string - workflow_call: - inputs: - checkout-path: - description: "Path to check out code to" - required: false - type: string - skip-relevance-check: - description: "Bypass relevance check" - required: false - type: boolean - default: false - ref: - description: "The branch, ref, or SHA to checkout" - required: false - type: string - repo: - description: "The repository to checkout from" - required: false - type: string - pr-base-sha: - description: "Base SHA of the PR for relevance check" - required: false - type: string - pr-head-sha: - description: "Head SHA of the PR for relevance check" - required: false - type: string - -jobs: - setup: - runs-on: ubuntu-latest - outputs: - is_act: ${{ steps.setup.outputs.is_act }} - ref: ${{ steps.setup.outputs.ref }} - repo: ${{ steps.setup.outputs.repo }} - base_sha: ${{ steps.setup.outputs.base_sha }} - pr_number: ${{ steps.setup.outputs.pr_number }} - checkout_path: ${{ steps.setup.outputs.checkout_path }} - has_changes: ${{ steps.setup.outputs.has_changes }} - steps: - - name: Workflow setup - id: setup - uses: Framework-R-D/phlex/.github/actions/workflow-setup@main - 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 - if: > - 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 - - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - ref: ${{ needs.setup.outputs.ref }} - repository: ${{ needs.setup.outputs.repo }} - path: ${{ needs.setup.outputs.checkout_path }} - persist-credentials: false - - - name: Check Jsonnet formatting - id: lint - 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)' - continue-on-error: true - - - name: Evaluate Jsonnet formatting result - if: always() && steps.lint.outcome != 'skipped' - env: - REPO: ${{ needs.setup.outputs.repo }} - # yamllint disable rule:line-length - run: | - REPO_NAME="${REPO##*/}" - if [ "${{ steps.lint.outcome }}" = 'success' ]; then - echo "✅ Jsonnet formatting check passed." - else - echo "::error::Jsonnet formatting issues found. Please review the output above for details." - echo "::error::Run 'jsonnetfmt -i ' locally or comment '@${REPO_NAME}bot format' on the PR to auto-fix." - exit 1 - fi - # yamllint enable diff --git a/.github/workflows/jsonnet-format-fix.yaml b/.github/workflows/jsonnet-format-fix.yaml deleted file mode 100644 index fa730ca1..00000000 --- a/.github/workflows/jsonnet-format-fix.yaml +++ /dev/null @@ -1,129 +0,0 @@ -name: Jsonnet Format Fix -run-name: "${{ github.actor }} fixing Jsonnet format" - -"on": - issue_comment: - types: - - created - 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." - required: false - type: string - workflow_call: - inputs: - checkout-path: - description: "Path to check out code to" - required: false - type: string - ref: - description: "The branch name to checkout and push fixes to (must be a branch, not a commit SHA)" - required: true - type: string - repo: - description: "The repository to checkout from" - required: true - type: string - skip-comment: - description: "Skip posting PR comments" - required: false - type: boolean - default: false - outputs: - changes: - description: "Whether any fixes were applied" - value: ${{ jobs.apply_jsonnet_formatting.outputs.changes }} - pushed: - description: "Whether the fixes were pushed to the remote branch" - value: ${{ jobs.apply_jsonnet_formatting.outputs.pushed }} - commit_sha: - description: "The full commit SHA of the applied fixes" - value: ${{ jobs.apply_jsonnet_formatting.outputs.commit_sha }} - commit_sha_short: - description: "The short commit SHA of the applied fixes" - value: ${{ jobs.apply_jsonnet_formatting.outputs.commit_sha_short }} - patch_name: - description: "Name of the patch file if fixes could not be pushed" - value: ${{ jobs.apply_jsonnet_formatting.outputs.patch_name }} - -permissions: - pull-requests: write - contents: write - issues: write - -jobs: - setup: - runs-on: ubuntu-latest - name: Parse command - if: > - 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)) - ) - outputs: - ref: ${{ steps.setup.outputs.ref }} - repo: ${{ steps.setup.outputs.repo }} - checkout_path: ${{ steps.setup.outputs.checkout_path }} - steps: - - 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: setup - if: needs.setup.result == 'success' - outputs: - changes: ${{ steps.handle_commit.outputs.changes }} - pushed: ${{ steps.handle_commit.outputs.pushed }} - commit_sha: ${{ steps.handle_commit.outputs.commit_sha }} - commit_sha_short: ${{ steps.handle_commit.outputs.commit_sha_short }} - patch_name: ${{ steps.handle_commit.outputs.patch_name }} - - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - path: ${{ needs.setup.outputs.checkout_path }} - ref: ${{ needs.setup.outputs.ref }} - repository: ${{ needs.setup.outputs.repo }} - token: ${{ secrets.WORKFLOW_PAT }} - - - name: Apply Jsonnet formatting - id: lint - env: - 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 \ - sh -c "find \"$CHECKOUT_PATH\" \( -name '*.jsonnet' -o -name '*.libsonnet' \) -print0 | xargs -0 -r jsonnetfmt -i" - # yamllint enable - continue-on-error: true - - - name: Handle fix commit - id: handle_commit - uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main - with: - tool: jsonnetfmt - working-directory: ${{ needs.setup.outputs.checkout_path }} - token: ${{ secrets.WORKFLOW_PAT }} - pr-info-ref: ${{ needs.setup.outputs.ref }} - pr-info-repo: ${{ needs.setup.outputs.repo }} - skip-comment: ${{ inputs.skip-comment }} - - - name: Update PR comment reactions - if: always() && github.event_name == 'issue_comment' && !inputs.skip-comment - uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main - with: - status: ${{ job.status }} diff --git a/.github/workflows/markdown-check.yaml b/.github/workflows/markdown-check.yaml deleted file mode 100644 index 743d35b4..00000000 --- a/.github/workflows/markdown-check.yaml +++ /dev/null @@ -1,114 +0,0 @@ -name: Markdown Check -run-name: "${{ github.actor }} checking Markdown format" - -permissions: - contents: read - pull-requests: read - -"on": - pull_request: - workflow_dispatch: - inputs: - ref: - description: "The branch, ref, or SHA to checkout. Defaults to the repository's default branch." - required: false - type: string - workflow_call: - inputs: - checkout-path: - description: "Path to check out code to" - required: false - type: string - skip-relevance-check: - description: "Bypass relevance check" - required: false - type: boolean - default: false - pr-base-sha: - description: "Base SHA of the PR for relevance check" - required: false - type: string - pr-head-sha: - description: "Head SHA of the PR for relevance check" - required: false - type: string - ref: - description: "The branch, ref, or SHA to checkout" - required: false - type: string - repo: - description: "The repository to checkout from" - required: false - type: string - -jobs: - setup: - runs-on: ubuntu-latest - outputs: - is_act: ${{ steps.setup.outputs.is_act }} - ref: ${{ steps.setup.outputs.ref }} - repo: ${{ steps.setup.outputs.repo }} - base_sha: ${{ steps.setup.outputs.base_sha }} - pr_number: ${{ steps.setup.outputs.pr_number }} - checkout_path: ${{ steps.setup.outputs.checkout_path }} - has_changes: ${{ steps.setup.outputs.has_changes }} - steps: - - name: Workflow setup - id: setup - uses: Framework-R-D/phlex/.github/actions/workflow-setup@main - 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 - if: > - always() && ( - github.event_name == 'workflow_dispatch' || - inputs.skip-relevance-check || - needs.setup.outputs.has_changes == 'true' - ) - runs-on: ubuntu-latest - permissions: - contents: read - - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - ref: ${{ needs.setup.outputs.ref }} - path: ${{ needs.setup.outputs.checkout_path }} - repository: ${{ needs.setup.outputs.repo }} - persist-credentials: false - - - name: Add problem matcher - uses: xt0rted/markdownlint-problem-matcher@1a5fabfb577370cfdf5af944d418e4be3ea06f27 # v3.0.0 - - - name: Run markdownlint - id: lint - uses: DavidAnson/markdownlint-cli2-action@07035fd053f7be764496c0f8d8f9f41f98305101 # v22.0.0 - with: - globs: | - ${{ needs.setup.outputs.checkout_path }}/**/*.md - !${{ needs.setup.outputs.checkout_path }}/**/CHANGELOG.md - continue-on-error: true - - - name: Evaluate markdownlint result - if: always() && steps.lint.outcome != 'skipped' - env: - REPO: ${{ needs.setup.outputs.repo }} - # yamllint disable rule:line-length - run: | - REPO_NAME="${REPO##*/}" - if [ "${{ steps.lint.outcome }}" = "success" ]; then - echo "✅ Markdown formatting check passed." - else - echo "::error::Markdown formatting check failed." - echo "::error::Comment '@${REPO_NAME}bot format' or '@${REPO_NAME}bot markdown-fix' on the PR to auto-fix." - exit 1 - fi - # yamllint enable diff --git a/.github/workflows/markdown-fix.yaml b/.github/workflows/markdown-fix.yaml deleted file mode 100644 index 177229cf..00000000 --- a/.github/workflows/markdown-fix.yaml +++ /dev/null @@ -1,131 +0,0 @@ -name: Markdown Fix -run-name: "${{ github.actor }} fixing Markdown format" - -"on": - issue_comment: - types: - - created - workflow_call: - inputs: - checkout-path: - description: "Path to check out code to" - required: false - type: string - ref: - description: "The branch name to checkout and push fixes to (must be a branch, not a commit SHA)" - required: true - type: string - repo: - description: "The repository to checkout from" - required: true - type: string - skip-comment: - description: "Skip posting PR comments" - required: false - type: boolean - default: false - outputs: - changes: - description: "Whether any fixes were applied" - value: ${{ jobs.apply_fixes.outputs.changes }} - pushed: - description: "Whether the fixes were pushed to the remote branch" - value: ${{ jobs.apply_fixes.outputs.pushed }} - commit_sha: - description: "The full commit SHA of the applied fixes" - value: ${{ jobs.apply_fixes.outputs.commit_sha }} - commit_sha_short: - description: "The short commit SHA of the applied fixes" - value: ${{ jobs.apply_fixes.outputs.commit_sha_short }} - patch_name: - description: "Name of the patch file if fixes could not be pushed" - value: ${{ jobs.apply_fixes.outputs.patch_name }} - 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." - required: false - type: string - -permissions: - pull-requests: write - contents: write - issues: write - -jobs: - setup: - runs-on: ubuntu-latest - name: Parse command - if: > - 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)) - ) - outputs: - ref: ${{ steps.setup.outputs.ref }} - repo: ${{ steps.setup.outputs.repo }} - checkout_path: ${{ steps.setup.outputs.checkout_path }} - steps: - - 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: setup - if: needs.setup.result == 'success' - outputs: - changes: ${{ steps.handle_commit.outputs.changes }} - pushed: ${{ steps.handle_commit.outputs.pushed }} - commit_sha: ${{ steps.handle_commit.outputs.commit_sha }} - commit_sha_short: ${{ steps.handle_commit.outputs.commit_sha_short }} - patch_name: ${{ steps.handle_commit.outputs.patch_name }} - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - path: ${{ needs.setup.outputs.checkout_path }} - ref: ${{ needs.setup.outputs.ref }} - repository: ${{ needs.setup.outputs.repo }} - token: ${{ secrets.WORKFLOW_PAT }} - - - name: Set up Node.js - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 - with: - node-version: "20" - - - name: Install markdownlint-cli2 - run: npm install -g markdownlint-cli2 - - - name: Run markdownlint-cli2 fix - working-directory: ${{ needs.setup.outputs.checkout_path }} - run: | - echo "Fixing Markdown format with markdownlint-cli2..." - markdownlint-cli2 --fix "**/*.md" "!**/CHANGELOG.md" || true - - - name: Handle fix commit - id: handle_commit - uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main - with: - tool: markdownlint - working-directory: ${{ needs.setup.outputs.checkout_path }} - token: ${{ secrets.WORKFLOW_PAT }} - pr-info-ref: ${{ needs.setup.outputs.ref }} - pr-info-repo: ${{ needs.setup.outputs.repo }} - skip-comment: ${{ inputs.skip-comment }} - - - name: Update PR comment reactions - if: always() && github.event_name == 'issue_comment' && !inputs.skip-comment - uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main - with: - status: ${{ job.status }} diff --git a/.github/workflows/pre-commit-check.yaml b/.github/workflows/pre-commit-check.yaml new file mode 100644 index 00000000..e40d72c0 --- /dev/null +++ b/.github/workflows/pre-commit-check.yaml @@ -0,0 +1,41 @@ +name: Pre-Commit Check +run-name: "${{ github.actor }} running pre-commit checks" + +permissions: + contents: read + pull-requests: read + +"on": + pull_request: + workflow_dispatch: + +jobs: + pre-commit: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Set up Python + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + with: + python-version: "3.x" + + - name: Compute pre-commit arguments + id: pc-args + run: | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + echo "extra_args=--from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT" + else + echo "extra_args=--all-files" >> "$GITHUB_OUTPUT" + fi + + - name: Run pre-commit + uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 + with: + extra_args: ${{ steps.pc-args.outputs.extra_args }} diff --git a/.github/workflows/pre-commit-fix.yaml b/.github/workflows/pre-commit-fix.yaml new file mode 100644 index 00000000..b8b46351 --- /dev/null +++ b/.github/workflows/pre-commit-fix.yaml @@ -0,0 +1,77 @@ +name: Pre-Commit Fix +run-name: "${{ github.actor }} fixing pre-commit issues" + +"on": + issue_comment: + types: + - created + 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. + required: false + type: string + +permissions: + pull-requests: write + contents: write + issues: write + +jobs: + setup: + runs-on: ubuntu-latest + name: Parse command + if: > + 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 pre-commit-fix', github.event.repository.name)) || + startsWith(github.event.comment.body, format('@{0}bot format', github.event.repository.name)) + ) + ) + outputs: + ref: ${{ steps.setup.outputs.ref }} + repo: ${{ steps.setup.outputs.repo }} + steps: + - name: Workflow setup + id: setup + uses: Framework-R-D/phlex/.github/actions/workflow-setup@main + with: + mode: fix + ref: ${{ inputs.ref }} + + apply_fixes: + runs-on: ubuntu-latest + name: Apply fixes + needs: setup + if: needs.setup.result == 'success' + steps: + - name: Checkout code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + ref: ${{ needs.setup.outputs.ref }} + repository: ${{ needs.setup.outputs.repo }} + token: ${{ secrets.WORKFLOW_PAT }} + + - name: Set up Python + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 + with: + python-version: "3.x" + + - name: Run pre-commit + run: | + pip install pre-commit + pre-commit run --all-files || true + + - name: Commit and push fixes + uses: pre-commit-ci/lite-action@5d6cc0eb514c891a40562a58a8e71576c5c7fb43 # v1.1.0 + + - name: Update PR comment reactions + if: always() && github.event_name == 'issue_comment' + uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main + with: + status: ${{ job.status }} diff --git a/.github/workflows/python-check.yaml b/.github/workflows/python-check.yaml deleted file mode 100644 index 0cdd5b2f..00000000 --- a/.github/workflows/python-check.yaml +++ /dev/null @@ -1,128 +0,0 @@ -name: Python Check -run-name: "${{ github.actor }} checking Python code" - -permissions: - contents: read - pull-requests: read - -"on": - pull_request: - workflow_dispatch: - inputs: - ref: - description: "The branch, ref, or SHA to checkout. Defaults to the repository's default branch." - required: false - type: string - workflow_call: - inputs: - checkout-path: - description: "Path to check out code to" - required: false - type: string - skip-relevance-check: - description: "Bypass relevance check" - required: false - type: boolean - default: false - pr-base-sha: - description: "Base SHA of the PR for relevance check" - required: false - type: string - pr-head-sha: - description: "Head SHA of the PR for relevance check" - required: false - type: string - ref: - description: "The branch, ref, or SHA to checkout" - required: false - type: string - repo: - description: "The repository to checkout from" - required: false - type: string - -jobs: - setup: - runs-on: ubuntu-latest - outputs: - is_act: ${{ steps.setup.outputs.is_act }} - ref: ${{ steps.setup.outputs.ref }} - repo: ${{ steps.setup.outputs.repo }} - base_sha: ${{ steps.setup.outputs.base_sha }} - pr_number: ${{ steps.setup.outputs.pr_number }} - checkout_path: ${{ steps.setup.outputs.checkout_path }} - has_changes: ${{ steps.setup.outputs.has_changes }} - steps: - - name: Workflow setup - id: setup - uses: Framework-R-D/phlex/.github/actions/workflow-setup@main - 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 - if: > - always() && ( - github.event_name == 'workflow_dispatch' || - inputs.skip-relevance-check || - needs.setup.outputs.has_changes == 'true' - ) - runs-on: ubuntu-latest - permissions: - contents: read - - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - ref: ${{ needs.setup.outputs.ref }} - path: ${{ needs.setup.outputs.checkout_path }} - repository: ${{ needs.setup.outputs.repo }} - persist-credentials: false - - - name: Set up Python - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 - with: - python-version: "3.x" - - - name: Install Python dependencies - run: | - pip install ruff mypy - - - name: Run ruff check - id: ruff - working-directory: ${{ needs.setup.outputs.checkout_path }} - env: - FORCE_COLOR: 1 - run: | - echo "➡️ Checking Python code with ruff..." - ruff check - continue-on-error: true - - - name: Run MyPy check - id: mypy - working-directory: ${{ needs.setup.outputs.checkout_path }} - run: | - echo "➡️ Checking Python code with MyPy..." - mypy --color-output . - continue-on-error: true - - - name: Evaluate Python checks result - if: always() && (steps.ruff.outcome != 'skipped' || steps.mypy.outcome != 'skipped') - env: - REPO: ${{ needs.setup.outputs.repo }} - # yamllint disable rule:line-length - run: | - REPO_NAME="${REPO##*/}" - if [ "${{ steps.ruff.outcome }}" = 'success' ] && [ "${{ steps.mypy.outcome }}" = 'success' ]; then - echo "✅ Python checks passed." - else - echo "::error::Python checks failed. Comment '@${REPO_NAME}bot python-fix' on the PR to attempt auto-fix." - exit 1 - fi - # yamllint enable diff --git a/.github/workflows/python-fix.yaml b/.github/workflows/python-fix.yaml deleted file mode 100644 index d8928744..00000000 --- a/.github/workflows/python-fix.yaml +++ /dev/null @@ -1,135 +0,0 @@ -name: Python Fix -run-name: "${{ github.actor }} fixing Python code" - -"on": - issue_comment: - types: - - created - 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." - required: false - type: string - workflow_call: - inputs: - checkout-path: - description: "Path to check out code to" - required: false - type: string - ref: - description: "The branch name to checkout and push fixes to (must be a branch, not a commit SHA)" - required: true - type: string - repo: - description: "The repository to checkout from" - required: true - type: string - skip-comment: - description: "Skip posting PR comments" - required: false - type: boolean - default: false - outputs: - changes: - description: "Whether any fixes were applied" - value: ${{ jobs.apply_fixes.outputs.changes }} - pushed: - description: "Whether the fixes were pushed to the remote branch" - value: ${{ jobs.apply_fixes.outputs.pushed }} - commit_sha: - description: "The full commit SHA of the applied fixes" - value: ${{ jobs.apply_fixes.outputs.commit_sha }} - commit_sha_short: - description: "The short commit SHA of the applied fixes" - value: ${{ jobs.apply_fixes.outputs.commit_sha_short }} - patch_name: - description: "Name of the patch file if fixes could not be pushed" - value: ${{ jobs.apply_fixes.outputs.patch_name }} - -permissions: - pull-requests: write - contents: write - issues: write - -jobs: - setup: - runs-on: ubuntu-latest - name: Parse command - if: > - 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)) - ) - outputs: - ref: ${{ steps.setup.outputs.ref }} - repo: ${{ steps.setup.outputs.repo }} - checkout_path: ${{ steps.setup.outputs.checkout_path }} - steps: - - 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: setup - if: needs.setup.result == 'success' - outputs: - changes: ${{ steps.handle_commit.outputs.changes }} - pushed: ${{ steps.handle_commit.outputs.pushed }} - commit_sha: ${{ steps.handle_commit.outputs.commit_sha }} - commit_sha_short: ${{ steps.handle_commit.outputs.commit_sha_short }} - patch_name: ${{ steps.handle_commit.outputs.patch_name }} - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - path: ${{ needs.setup.outputs.checkout_path }} - ref: ${{ needs.setup.outputs.ref }} - repository: ${{ needs.setup.outputs.repo }} - token: ${{ secrets.WORKFLOW_PAT }} - - - name: Set up Python - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 - with: - python-version: "3.x" - - - name: Install Python dependencies - run: | - pip install ruff - - - name: Run ruff format and fix - working-directory: ${{ needs.setup.outputs.checkout_path }} - env: - FORCE_COLOR: 1 - run: | - echo "Fixing Python format with ruff" - ruff format . || true - echo "Fixing Python linter issues with ruff" - ruff check --fix . || true - - - name: Handle fix commit - id: handle_commit - uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main - with: - tool: ruff - working-directory: ${{ needs.setup.outputs.checkout_path }} - token: ${{ secrets.WORKFLOW_PAT }} - pr-info-ref: ${{ needs.setup.outputs.ref }} - pr-info-repo: ${{ needs.setup.outputs.repo }} - skip-comment: ${{ inputs.skip-comment }} - - - name: Update PR comment reactions - if: always() && github.event_name == 'issue_comment' && !inputs.skip-comment - uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main - with: - status: ${{ job.status }} diff --git a/.github/workflows/yaml-check.yaml b/.github/workflows/yaml-check.yaml deleted file mode 100644 index cc5d49c7..00000000 --- a/.github/workflows/yaml-check.yaml +++ /dev/null @@ -1,74 +0,0 @@ -name: YAML Check -"run-name": "${{ github.actor }} checking YAML files" - -permissions: - contents: read - -"on": - pull_request: - workflow_dispatch: - inputs: - ref: - description: "The branch, ref, or SHA to checkout. Defaults to the repository's default branch." - required: false - type: string - -jobs: - setup: - runs-on: ubuntu-latest - outputs: - is_act: ${{ steps.setup.outputs.is_act }} - ref: ${{ steps.setup.outputs.ref }} - repo: ${{ steps.setup.outputs.repo }} - base_sha: ${{ steps.setup.outputs.base_sha }} - pr_number: ${{ steps.setup.outputs.pr_number }} - checkout_path: ${{ steps.setup.outputs.checkout_path }} - has_changes: ${{ steps.setup.outputs.has_changes }} - steps: - - name: Workflow setup - id: setup - uses: Framework-R-D/phlex/.github/actions/workflow-setup@main - with: - file-type: yaml - - yaml-check: - needs: setup - if: > - always() && (github.event_name == 'workflow_dispatch' || needs.setup.outputs.has_changes == 'true') - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - ref: ${{ needs.setup.outputs.ref }} - path: ${{ needs.setup.outputs.checkout_path }} - repository: ${{ needs.setup.outputs.repo }} - persist-credentials: false - - - name: Setup Python - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 - with: - python-version: "3.x" - - - name: Install yamllint - run: pip install yamllint - - - name: Run yamllint - id: lint - working-directory: ${{ needs.setup.outputs.checkout_path }} - run: yamllint . - continue-on-error: true - - - name: Evaluate yamllint result - if: always() && steps.lint.outcome != 'skipped' - env: - REPO: ${{ needs.setup.outputs.repo }} - run: | - REPO_NAME="${REPO##*/}" - if [ "${{ steps.lint.outcome }}" = "success" ]; then - echo "✅ YAML check passed." - else - echo "::error::YAML check failed." - echo "::error::Comment '@${REPO_NAME}bot yaml-fix' on the PR to auto-fix." - exit 1 - fi diff --git a/.github/workflows/yaml-fix.yaml b/.github/workflows/yaml-fix.yaml deleted file mode 100644 index b3f2e519..00000000 --- a/.github/workflows/yaml-fix.yaml +++ /dev/null @@ -1,131 +0,0 @@ -name: YAML Fix -"run-name": "${{ github.actor }} fixing YAML files" - -"on": - issue_comment: - types: - - created - 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." - required: false - type: string - workflow_call: - inputs: - checkout-path: - description: "Path to check out code to" - required: false - type: string - ref: - description: "The branch name to checkout and push fixes to (must be a branch, not a commit SHA)" - required: true - type: string - repo: - description: "The repository to checkout from" - required: true - type: string - skip-comment: - description: "Skip posting PR comments" - required: false - type: boolean - default: false - outputs: - changes: - description: "Whether any fixes were applied" - value: ${{ jobs.apply_yaml_fixes.outputs.changes }} - pushed: - description: "Whether the fixes were pushed to the remote branch" - value: ${{ jobs.apply_yaml_fixes.outputs.pushed }} - commit_sha: - description: "The full commit SHA of the applied fixes" - value: ${{ jobs.apply_yaml_fixes.outputs.commit_sha }} - commit_sha_short: - description: "The short commit SHA of the applied fixes" - value: ${{ jobs.apply_yaml_fixes.outputs.commit_sha_short }} - patch_name: - description: "Name of the patch file if fixes could not be pushed" - value: ${{ jobs.apply_yaml_fixes.outputs.patch_name }} - -permissions: - pull-requests: write - contents: write - issues: write - -jobs: - setup: - runs-on: ubuntu-latest - name: Parse command - if: > - 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)) - ) - outputs: - ref: ${{ steps.setup.outputs.ref }} - repo: ${{ steps.setup.outputs.repo }} - checkout_path: ${{ steps.setup.outputs.checkout_path }} - steps: - - 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: setup - if: ${{ needs.setup.result == 'success' }} - outputs: - changes: ${{ steps.handle_commit.outputs.changes }} - pushed: ${{ steps.handle_commit.outputs.pushed }} - commit_sha: ${{ steps.handle_commit.outputs.commit_sha }} - commit_sha_short: ${{ steps.handle_commit.outputs.commit_sha_short }} - patch_name: ${{ steps.handle_commit.outputs.patch_name }} - - steps: - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - path: ${{ needs.setup.outputs.checkout_path }} - ref: ${{ needs.setup.outputs.ref }} - repository: ${{ needs.setup.outputs.repo }} - token: ${{ secrets.WORKFLOW_PAT }} - - - name: Setup Node.js - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 - with: - node-version: "20.x" - - - name: Install prettier - run: npm install -g prettier - - - name: Apply YAML formatting - working-directory: ${{ needs.setup.outputs.checkout_path }} - run: | - prettier --write '**/*.{yaml,yml}' - - - name: Handle fix commit - id: handle_commit - uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main - with: - tool: YAML formatter - working-directory: ${{ needs.setup.outputs.checkout_path }} - token: ${{ secrets.WORKFLOW_PAT }} - pr-info-ref: ${{ needs.setup.outputs.ref }} - pr-info-repo: ${{ needs.setup.outputs.repo }} - skip-comment: ${{ inputs.skip-comment }} - - - name: Update PR comment reactions - if: always() && github.event_name == 'issue_comment' && !inputs.skip-comment - uses: Framework-R-D/phlex/.github/actions/complete-pr-comment@main - with: - status: ${{ job.status }}