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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
354 changes: 242 additions & 112 deletions .github/REUSABLE_WORKFLOWS.md

Large diffs are not rendered by default.

23 changes: 19 additions & 4 deletions .github/actions/handle-fix-commit/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ inputs:
description: "The number of times to retry pushing the commit."
required: false
default: "6"
skip-comment:
description: "Skip posting PR comments (for workflow_call usage)"
required: false
default: "false"

runs:
using: "composite"
Expand All @@ -55,7 +59,7 @@ runs:
fi

- name: No changes to apply
if: steps.check_changes.outputs.changes == 'false'
if: steps.check_changes.outputs.changes == 'false' && inputs.skip-comment != 'true'
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
with:
message: "No automatic ${{ inputs.tool }} fixes were necessary."
Expand All @@ -66,10 +70,19 @@ runs:
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
// context.issue.number is only available when the root trigger is an
// issue_comment event. For workflow_dispatch triggers (and any other
// non-PR-comment trigger), default to false so the commit path still
// works for same-repo pushes via the first clause of the commit condition.
const prNumber = context.issue.number;
if (!prNumber) {
core.setOutput('maintainer_can_modify', 'false');
return;
}
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
pull_number: prNumber
});
core.setOutput('maintainer_can_modify', pr.maintainer_can_modify);
- name: Commit fixes
Expand Down Expand Up @@ -125,7 +138,9 @@ runs:
exit 1

- name: Notify of commit
if: steps.commit_and_push.conclusion == 'success' && steps.commit_and_push.outputs.pushed == 'true'
if:
steps.commit_and_push.conclusion == 'success' && steps.commit_and_push.outputs.pushed == 'true' &&
inputs.skip-comment != 'true'
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
with:
# yamllint disable rule:line-length
Expand Down Expand Up @@ -153,7 +168,7 @@ runs:
path: ${{ inputs.working-directory }}/${{ steps.create_patch.outputs.patch_name }}

- name: Comment with patch instructions
if: steps.create_patch.outputs.patch_name
if: steps.create_patch.outputs.patch_name && inputs.skip-comment != 'true'
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
with:
# yamllint disable rule:line-length
Expand Down
109 changes: 97 additions & 12 deletions .github/workflows/clang-format-fix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,74 @@ run-name: "${{ github.actor }} fixing C++ code format"
workflow_dispatch:
inputs:
ref:
description: "The branch, ref, or SHA to checkout. 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:
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: string
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

env:
local_checkout_path:
${{ (github.event_name == 'workflow_call' && inputs.checkout-path) || format('{0}-src',
github.event.repository.name) }}

jobs:
pre-check:
runs-on: ubuntu-latest
name: Parse command
if: >
github.event_name == 'workflow_dispatch' || (
github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' || (
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)) ||
startsWith(github.event.comment.body, format('@{0}bot clang-fix', github.event.repository.name))
)
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:
${{ (github.event_name == 'workflow_dispatch' && (github.event.inputs.ref || github.ref)) ||
steps.get_pr.outputs.ref }}
repo: ${{ steps.get_pr.outputs.repo || github.repository }}
${{ (github.event_name == 'workflow_call' && inputs.ref) || (github.event_name == 'workflow_dispatch' &&
(github.event.inputs.ref || github.ref_name)) || steps.get_pr.outputs.ref }}
repo:
${{ (github.event_name == 'workflow_call' && inputs.repo) || (github.event_name == 'workflow_dispatch' &&
github.repository) || steps.get_pr.outputs.repo }}

steps:
- name: Get PR Info
Expand All @@ -49,26 +88,72 @@ jobs:
name: Apply formatting
needs: pre-check
if: ${{ needs.pre-check.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: phlex-src
path: ${{ env.local_checkout_path }}
ref: ${{ needs.pre-check.outputs.ref }}
repository: ${{ needs.pre-check.outputs.repo }}
token: ${{ secrets.WORKFLOW_PAT }}

- uses: DoozyX/clang-format-lint-action@bcb4eb2cb0d707ee4f3e5cc3b456eb075f12cf73 # v0.20
with:
source: "./phlex-src"
source: "./${{ env.local_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: phlex-src
working-directory: ${{ env.local_checkout_path }}
token: ${{ secrets.WORKFLOW_PAT }}
pr-info-ref: ${{ needs.pre-check.outputs.ref }}
pr-info-repo: ${{ needs.pre-check.outputs.repo }}
skip-comment: ${{ github.event_name == 'workflow_call' && inputs.skip-comment || 'false' }}

- name: Remove eyes reaction
if: github.event_name == 'issue_comment'
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'
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'
});
4 changes: 2 additions & 2 deletions .github/workflows/clang-tidy-fix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name: Clang-Tidy Fix
workflow_dispatch:
inputs:
ref:
description: "The branch, ref, or SHA to checkout. 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:
Expand All @@ -35,7 +35,7 @@ jobs:
# This covers repo owners, invited collaborators, and all org members.
outputs:
ref:
${{ (github.event_name == 'workflow_dispatch' && (github.event.inputs.ref || github.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 }}
tidy_checks:
Expand Down
78 changes: 71 additions & 7 deletions .github/workflows/cmake-format-fix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ run-name: "${{ github.actor }} fixing CMake format"
workflow_dispatch:
inputs:
ref:
description: "The branch, ref, or SHA to checkout. 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:
Expand All @@ -18,13 +18,34 @@ run-name: "${{ github.actor }} fixing CMake format"
required: false
type: string
ref:
description: "The branch, ref, or SHA to checkout"
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: string
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
Expand All @@ -44,17 +65,14 @@ jobs:
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)) ||
startsWith(github.event.comment.body, format('@{0}bot cmake-fix', github.event.repository.name))
)
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:
${{ (github.event_name == 'workflow_call' && inputs.ref) || (github.event_name == 'workflow_dispatch' &&
(github.event.inputs.ref || github.ref)) || steps.get_pr.outputs.ref }}
(github.event.inputs.ref || github.ref_name)) || steps.get_pr.outputs.ref }}
repo:
${{ (github.event_name == 'workflow_call' && inputs.repo) || (github.event_name == 'workflow_dispatch' &&
github.repository) || steps.get_pr.outputs.repo }}
Expand All @@ -70,6 +88,12 @@ jobs:
name: Apply CMake formatting
needs: pre-check
if: needs.pre-check.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
Expand All @@ -93,10 +117,50 @@ jobs:
gersemi -i ${{ env.local_checkout_path }}

- name: Handle fix commit
id: handle_commit
uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main
with:
tool: cmake-format
working-directory: ${{ env.local_checkout_path }}
token: ${{ secrets.WORKFLOW_PAT }}
pr-info-ref: ${{ needs.pre-check.outputs.ref }}
pr-info-repo: ${{ needs.pre-check.outputs.repo }}
skip-comment: ${{ github.event_name == 'workflow_call' && inputs.skip-comment || 'false' }}

- name: Remove eyes reaction
if: github.event_name == 'issue_comment'
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'
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'
});
13 changes: 4 additions & 9 deletions .github/workflows/dependabot-auto-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@ jobs:
dependabot:
runs-on: ubuntu-latest
if: >-
(github.event_name == 'pull_request_target' &&
github.event.pull_request.user.login == 'dependabot[bot]' &&
github.event.pull_request.base.ref == 'main') ||
(github.event_name == 'pull_request_review' &&
github.event.pull_request.user.login == 'dependabot[bot]' &&
github.event.pull_request.base.ref == 'main') ||
(github.event_name == 'check_suite' &&
github.event.check_suite.pull_requests[0] != null &&
(github.event_name == 'pull_request_target' && github.event.pull_request.user.login == 'dependabot[bot]' &&
github.event.pull_request.base.ref == 'main') || (github.event_name == 'pull_request_review' &&
github.event.pull_request.user.login == 'dependabot[bot]' && github.event.pull_request.base.ref == 'main') ||
(github.event_name == 'check_suite' && github.event.check_suite.pull_requests[0] != null &&
startsWith(github.event.check_suite.head_branch, 'dependabot/'))
steps:
- name: Get PR details
Expand Down Expand Up @@ -76,6 +72,5 @@ jobs:
fi
fi
# yamllint enable

env:
GH_TOKEN: ${{ secrets.WORKFLOW_PAT }}
Loading
Loading