Skip to content

Commit 961a51d

Browse files
Modernize Markdown workflows and update documentation
- Updated `markdown-check.yaml` and `markdown-fix.yaml` for consistency with other repository workflows (e.g., `cmake-format-check`). - Added robust `workflow_call` support with standard inputs. - Implemented trigger type emulation in `markdown-check.yaml` to intelligently handle relevance checks for automatic vs. manual callers. - Standardized job naming, checkout paths, and dynamic bot command logic. - Updated `REUSABLE_WORKFLOWS.md` with comprehensive documentation for markdown check/fix workflows and fixed pre-existing linting issues. Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
1 parent 64f0d63 commit 961a51d

File tree

2 files changed

+53
-14
lines changed

2 files changed

+53
-14
lines changed

.github/REUSABLE_WORKFLOWS.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ Additionally, you can configure your own fork of Phlex to run CI checks on local
1212

1313
If you are a Phlex-affiliated developer working on a dependent package of Phlex, or on a different Cetmodules-using package, or on Cetmodules itself, you may be able to invoke these workflows on your own project following the information in this guide. However, this is only supported for Phlex-affiliated developers, and even then on a best effort basis. We do **not** support or encourage others to utilize these workflows at this time.
1414

15-
#### Running Workflows Manually (`workflow_dispatch`)
15+
### Running Workflows Manually (`workflow_dispatch`)
1616

1717
Most workflows in this repository can be run manually on any branch, tag, or commit. This is useful for testing changes without creating a pull request or for applying fixes to a specific branch.
1818

1919
To run a workflow manually:
2020

21-
1. Navigate to the **Actions** tab of the Phlex repository (or your fork).
22-
1. In the left sidebar, click the workflow you want to run (e.g., **Clang-Format Check**).
23-
1. Above the list of workflow runs, you will see a banner that says "This workflow has a `workflow_dispatch` event trigger." Click the **Run workflow** dropdown on the right.
24-
1. Use the **Branch/tag** dropdown to select the branch you want to run the workflow on.
25-
1. Some workflows have additional inputs (e.g., the `cmake-build` workflow allows you to specify build combinations). Fill these out as needed.
26-
1. Click the **Run workflow** button.
21+
1. Navigate to the **Actions** tab of the Phlex repository (or your fork).
22+
1. In the left sidebar, click the workflow you want to run (e.g., **Clang-Format Check**).
23+
1. Above the list of workflow runs, you will see a banner that says "This workflow has a `workflow_dispatch` event trigger." Click the **Run workflow** dropdown on the right.
24+
1. Use the **Branch/tag** dropdown to select the branch you want to run the workflow on.
25+
1. Some workflows have additional inputs (e.g., the `cmake-build` workflow allows you to specify build combinations). Fill these out as needed.
26+
1. Click the **Run workflow** button.
2727

2828
### For Contributors Working on a Fork of Phlex
2929

@@ -185,6 +185,27 @@ Automatically formats Markdown files using `markdownlint` and commits the change
185185
- `ref` (string, **required**): The branch or ref to check out.
186186
- `repo` (string, **required**): The repository to check out from.
187187

188+
### 6. `markdown-check.yaml`
189+
190+
Checks Markdown files for formatting issues using `markdownlint`.
191+
192+
#### Usage Example
193+
194+
```yaml
195+
jobs:
196+
check_markdown:
197+
uses: Framework-R-D/phlex/.github/workflows/markdown-check.yaml@cef968c52aab432b836bb28119a9661c82c8b0d1
198+
```
199+
200+
#### All Inputs
201+
202+
- `checkout-path` (string, optional): Path to check out code to.
203+
- `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.
204+
- `pr-base-sha` (string, optional): Base SHA of the PR for relevance check.
205+
- `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.
208+
188209
### Other Workflows
189210

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

.github/workflows/markdown-check.yaml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ on:
3333
description: "Head SHA of the PR for relevance check"
3434
required: false
3535
type: string
36+
ref:
37+
description: "The branch, ref, or SHA to checkout"
38+
required: false
39+
type: string
3640
repo:
3741
description: "The repository to checkout from"
3842
required: false
@@ -54,9 +58,16 @@ jobs:
5458
detect-changes:
5559
needs: pre-check
5660
if: >
57-
github.event_name != 'workflow_dispatch' &&
58-
(github.event_name != 'workflow_call' || inputs.skip-relevance-check != 'true') &&
59-
needs.pre-check.outputs.is_act != 'true'
61+
needs.pre-check.outputs.is_act != 'true' &&
62+
(
63+
github.event_name == 'pull_request' ||
64+
github.event_name == 'push' ||
65+
(
66+
github.event_name == 'workflow_call' &&
67+
inputs.skip-relevance-check != 'true' &&
68+
(github.event.pull_request || github.event.before)
69+
)
70+
)
6071
runs-on: ubuntu-latest
6172
permissions:
6273
contents: read
@@ -106,7 +117,7 @@ jobs:
106117
- name: Checkout code
107118
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
108119
with:
109-
ref: ${{ (github.event_name == 'workflow_call' && inputs.pr-head-sha) || (github.event_name == 'workflow_dispatch' && github.event.inputs.ref) || github.ref }}
120+
ref: ${{ (github.event_name == 'workflow_call' && (inputs.ref || inputs.pr-head-sha)) || (github.event_name == 'workflow_dispatch' && github.event.inputs.ref) || github.ref }}
110121
path: ${{ env.local_checkout_path }}
111122
repository: ${{ (github.event_name == 'workflow_call' && inputs.repo) || github.repository }}
112123

@@ -136,9 +147,16 @@ jobs:
136147
markdown-check-skipped:
137148
needs: [pre-check, detect-changes]
138149
if: >
139-
github.event_name != 'workflow_dispatch' &&
140-
(github.event_name != 'workflow_call' || inputs.skip-relevance-check != 'true') &&
141150
needs.pre-check.outputs.is_act != 'true' &&
151+
(
152+
github.event_name == 'pull_request' ||
153+
github.event_name == 'push' ||
154+
(
155+
github.event_name == 'workflow_call' &&
156+
inputs.skip-relevance-check != 'true' &&
157+
(github.event.pull_request || github.event.before)
158+
)
159+
) &&
142160
(needs.detect-changes.result == 'success' && needs.detect-changes.outputs.matched != 'true')
143161
runs-on: ubuntu-latest
144162
permissions:

0 commit comments

Comments
 (0)