Skip to content

Commit e52cdd5

Browse files
Improve workflow documentation and job output naming
- Standardized `REUSABLE_WORKFLOWS.md` with consistent structure, full usage examples, and comprehensive input documentation for all workflows. - Added documentation for missing workflows to `REUSABLE_WORKFLOWS.md`. - Ensured consistency in job outputs (`has_changes`) across modernized workflows. Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
1 parent 961a51d commit e52cdd5

File tree

2 files changed

+130
-28
lines changed

2 files changed

+130
-28
lines changed

.github/REUSABLE_WORKFLOWS.md

Lines changed: 127 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Overview and General Instructions
44

5-
The workflows in `Framework-R-D/phlex/` maybe invoked as follows:
5+
The workflows in `Framework-R-D/phlex/` may be invoked as follows:
66

77
1. Automatically as part of CI checks on a PR submitted to `Framework-R-D/phlex`, at PR creation time and thereafter on pushes to the PR branch. This should work whether your PR branch is situated in the primary repository or a fork.
88
1. Via triggering comments on the PR (`@phlexbot <action>`).
@@ -97,35 +97,35 @@ jobs:
9797
- `build-path` (string, optional): Path for build artifacts.
9898
- `skip-relevance-check` (boolean, optional, default: `false`): Bypass the check that only runs the build if C++ or CMake files have changed.
9999
- `build-combinations` (string, optional): A space-separated list of build combinations to run.
100-
- `ref` (string, optional): The branch or ref to check out.
101-
- `repo` (string, optional): The repository to check out from (e.g., `my-org/my-repo`).
100+
- `ref` (string, optional): The branch, ref, or SHA to check out.
101+
- `repo` (string, optional): The repository to check out from.
102102
- `pr-base-sha` (string, optional): Base SHA of the PR for relevance check.
103103
- `pr-head-sha` (string, optional): Head SHA of the PR for relevance check.
104104

105-
### 2. `python-check.yaml`
105+
### 2. `cmake-format-check.yaml`
106106

107-
Checks Python code for formatting and type errors using `ruff` and `mypy`.
107+
Checks CMake files for formatting issues using `gersemi`.
108108

109109
#### Usage Example
110110

111111
```yaml
112112
jobs:
113-
check_python:
114-
uses: Framework-R-D/phlex/.github/workflows/python-check.yaml@cef968c52aab432b836bb28119a9661c82c8b0d1
113+
check_cmake_format:
114+
uses: Framework-R-D/phlex/.github/workflows/cmake-format-check.yaml@cef968c52aab432b836bb28119a9661c82c8b0d1
115115
```
116116

117117
#### All Inputs
118118

119119
- `checkout-path` (string, optional): Path to check out code to.
120-
- `skip-relevance-check` (boolean, optional, default: `false`): Bypass the check that only runs if Python files have changed.
120+
- `skip-relevance-check` (boolean, optional, default: `false`): Bypass the check that only runs if CMake files have changed.
121121
- `pr-base-sha` (string, optional): Base SHA of the PR for relevance check.
122122
- `pr-head-sha` (string, optional): Head SHA of the PR for relevance check.
123123

124124
### 3. `cmake-format-fix.yaml`
125125

126126
Automatically formats CMake files using `gersemi` and commits the changes. Typically triggered by an `issue_comment`.
127127

128-
#### Usage Example (in a workflow triggered by `issue_comment`)
128+
#### Usage Example
129129

130130
```yaml
131131
name: 'Bot Commands'
@@ -154,35 +154,60 @@ jobs:
154154
#### All Inputs
155155

156156
- `checkout-path` (string, optional): Path to check out code to.
157-
- `ref` (string, **required**): The branch or ref to check out.
157+
- `ref` (string, **required**): The branch, ref, or SHA to check out.
158158
- `repo` (string, **required**): The repository to check out from.
159159

160-
### 4. `python-fix.yaml`
160+
### 4. `python-check.yaml`
161161

162-
Automatically formats and fixes Python code using `ruff` and commits the changes. Typically triggered by an `issue_comment`.
162+
Checks Python code for formatting and type errors using `ruff` and `mypy`.
163163

164-
#### Usage Example (in a workflow triggered by `issue_comment`)
164+
#### Usage Example
165165

166-
*Similar to `cmake-format-fix.yaml`, but triggered by a command like `@<repo>bot python-fix`.*
166+
```yaml
167+
jobs:
168+
check_python:
169+
uses: Framework-R-D/phlex/.github/workflows/python-check.yaml@cef968c52aab432b836bb28119a9661c82c8b0d1
170+
```
167171

168172
#### All Inputs
169173

170174
- `checkout-path` (string, optional): Path to check out code to.
171-
- `ref` (string, **required**): The branch or ref to check out.
172-
- `repo` (string, **required**): The repository to check out from.
175+
- `skip-relevance-check` (boolean, optional, default: `false`): Bypass the check that only runs if Python files have changed.
176+
- `pr-base-sha` (string, optional): Base SHA of the PR for relevance check.
177+
- `pr-head-sha` (string, optional): Head SHA of the PR for relevance check.
173178

174-
### 5. `markdown-fix.yaml`
179+
### 5. `python-fix.yaml`
175180

176-
Automatically formats Markdown files using `markdownlint` and commits the changes. Typically triggered by an `issue_comment`.
181+
Automatically formats and fixes Python code using `ruff` and commits the changes. Typically triggered by an `issue_comment`.
182+
183+
#### Usage Example
177184

178-
#### Usage Example: `markdown-fix.yaml` (in a workflow triggered by `issue_comment`)
185+
```yaml
186+
name: 'Bot Commands'
187+
on:
188+
issue_comment:
189+
types: [created]
179190
180-
*Similar to `cmake-format-fix.yaml`, but triggered by a command like `@<repo>bot markdown-fix`.*
191+
jobs:
192+
fix-python:
193+
# Run only on comments from collaborators/owners that start with the bot command
194+
if: >
195+
github.event.issue.pull_request &&
196+
(github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'OWNER') &&
197+
startsWith(github.event.comment.body, format('@{0}bot python-fix', github.event.repository.name))
198+
uses: Framework-R-D/phlex/.github/workflows/python-fix.yaml@cef968c52aab432b836bb28119a9661c82c8b0d1
199+
with:
200+
# The ref and repo of the PR need to be retrieved and passed
201+
ref: ${{ steps.get_pr_info.outputs.ref }}
202+
repo: ${{ steps.get_pr_info.outputs.repo }}
203+
secrets:
204+
WORKFLOW_PAT: ${{ secrets.WORKFLOW_PAT }}
205+
```
181206

182-
#### All Inputs: `markdown-fix.yaml`
207+
#### All Inputs
183208

184209
- `checkout-path` (string, optional): Path to check out code to.
185-
- `ref` (string, **required**): The branch or ref to check out.
210+
- `ref` (string, **required**): The branch, ref, or SHA to check out.
186211
- `repo` (string, **required**): The repository to check out from.
187212

188213
### 6. `markdown-check.yaml`
@@ -203,9 +228,86 @@ jobs:
203228
- `skip-relevance-check` (boolean, optional, default: `false`): Bypass the check that only runs if Markdown files have changed. Note that this workflow automatically emulates the trigger type of the caller; it will run relevance checks if called from a `pull_request` or `push` event, and skip them (running on all files) otherwise.
204229
- `pr-base-sha` (string, optional): Base SHA of the PR for relevance check.
205230
- `pr-head-sha` (string, optional): Head SHA of the PR for relevance check.
206-
- `ref` (string, optional): The branch, ref, or SHA to checkout.
207-
- `repo` (string, optional): The repository to checkout from.
231+
- `ref` (string, optional): The branch, ref, or SHA to check out.
232+
- `repo` (string, optional): The repository to check out from.
233+
234+
### 7. `markdown-fix.yaml`
235+
236+
Automatically formats Markdown files using `markdownlint` and commits the changes. Typically triggered by an `issue_comment`.
237+
238+
#### Usage Example
239+
240+
```yaml
241+
name: 'Bot Commands'
242+
on:
243+
issue_comment:
244+
types: [created]
245+
246+
jobs:
247+
fix-markdown:
248+
# Run only on comments from collaborators/owners that start with the bot command
249+
if: >
250+
github.event.issue.pull_request &&
251+
(github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'OWNER') &&
252+
(
253+
startsWith(github.event.comment.body, format('@{0}bot format', github.event.repository.name)) ||
254+
startsWith(github.event.comment.body, format('@{0}bot markdown-fix', github.event.repository.name))
255+
)
256+
uses: Framework-R-D/phlex/.github/workflows/markdown-fix.yaml@cef968c52aab432b836bb28119a9661c82c8b0d1
257+
with:
258+
# The ref and repo of the PR need to be retrieved and passed
259+
ref: ${{ steps.get_pr_info.outputs.ref }}
260+
repo: ${{ steps.get_pr_info.outputs.repo }}
261+
secrets:
262+
WORKFLOW_PAT: ${{ secrets.WORKFLOW_PAT }}
263+
```
264+
265+
#### All Inputs
266+
267+
- `checkout-path` (string, optional): Path to check out code to.
268+
- `ref` (string, **required**): The branch, ref, or SHA to check out.
269+
- `repo` (string, **required**): The repository to check out from.
270+
271+
### 8. `actionlint-check.yaml`
272+
273+
Checks GitHub Actions workflow files for errors and best practices using `actionlint`.
274+
275+
#### Usage Example
276+
277+
```yaml
278+
jobs:
279+
check_actions:
280+
uses: Framework-R-D/phlex/.github/workflows/actionlint-check.yaml@cef968c52aab432b836bb28119a9661c82c8b0d1
281+
```
282+
283+
#### All Inputs
284+
285+
- `checkout-path` (string, optional): Path to check out code to.
286+
- `skip-relevance-check` (boolean, optional, default: `false`): Bypass the check that only runs if workflow files have changed.
287+
- `pr-base-sha` (string, optional): Base SHA of the PR for relevance check.
288+
- `pr-head-sha` (string, optional): Head SHA of the PR for relevance check.
289+
290+
### 9. `codeql-analysis.yaml`
291+
292+
Performs static analysis on the codebase using GitHub CodeQL to identify potential security vulnerabilities and coding errors.
293+
294+
#### Usage Example
295+
296+
```yaml
297+
jobs:
298+
analyze:
299+
uses: Framework-R-D/phlex/.github/workflows/codeql-analysis.yaml@cef968c52aab432b836bb28119a9661c82c8b0d1
300+
```
301+
302+
#### All Inputs
303+
304+
- `checkout-path` (string, optional): Path to check out code to.
305+
- `build-path` (string, optional): Path for build artifacts.
306+
- `language-matrix` (string, optional, default: `'["cpp", "python", "actions"]'`): JSON array of languages to analyze.
307+
- `pr-number` (string, optional): PR number if run in PR context.
308+
- `pr-head-repo` (string, optional): The full name of the PR head repository.
309+
- `pr-base-repo` (string, optional): The full name of the PR base repository.
208310

209311
### Other Workflows
210312

211-
The repository also provides `actionlint-check.yaml`, `cmake-format-check.yaml`, and `codeql-analysis.yaml`, which can be used in a similar manner.
313+
The repository also provides `clang-format-check.yaml`, `clang-format-fix.yaml`, `clang-tidy-check.yaml`, and `clang-tidy-fix.yaml`, which can be used in a similar manner.

.github/workflows/markdown-check.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
contents: read
7474
packages: read
7575
outputs:
76-
matched: ${{ steps.filter.outputs.matched }}
76+
has_changes: ${{ steps.filter.outputs.matched }}
7777
steps:
7878
- name: Checkout code
7979
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -107,7 +107,7 @@ jobs:
107107
needs.detect-changes.result == 'skipped' ||
108108
(
109109
needs.detect-changes.result == 'success' &&
110-
needs.detect-changes.outputs.matched == 'true'
110+
needs.detect-changes.outputs.has_changes == 'true'
111111
)
112112
runs-on: ubuntu-latest
113113
permissions:
@@ -157,7 +157,7 @@ jobs:
157157
(github.event.pull_request || github.event.before)
158158
)
159159
) &&
160-
(needs.detect-changes.result == 'success' && needs.detect-changes.outputs.matched != 'true')
160+
(needs.detect-changes.result == 'success' && needs.detect-changes.outputs.has_changes != 'true')
161161
runs-on: ubuntu-latest
162162
permissions:
163163
contents: read

0 commit comments

Comments
 (0)