Skip to content

Commit 83fc259

Browse files
docs: resolve markdownlint issues and finalize workflows
- Fix .markdownlint.jsonc configuration structure - Clean up .github/CodeQL-README.md formatting - Resolve repo-wide markdownlint issues (MD001, MD012, MD024, MD060, etc.) - Add 'md' file type detection to detect-relevant-changes action - Enable workflow_call support in markdown-fix.yaml - Pin actions to SHAs with full semantic version annotations (e.g., # v1.1.0) - Support @<repo>bot format command in markdown-fix.yaml Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
1 parent 3876e62 commit 83fc259

File tree

12 files changed

+111
-77
lines changed

12 files changed

+111
-77
lines changed

.github/CodeQL-README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
```markdown
21
# CodeQL scanning for this repository
32

43
This repository uses C++ (C++20 / moving to C++23) built with CMake under the phlex-src directory, plus some Python and CI bits (Bash). The repository includes a CodeQL GitHub Actions workflow on branch `copilot/codeql-workflow` that:
@@ -9,22 +8,26 @@ This repository uses C++ (C++20 / moving to C++23) built with CMake under the ph
98
- Uses RelWithDebInfo build type in CI so debug symbols are present while keeping realistic optimization.
109

1110
Important workflow-specific notes
11+
1212
- The workflow sets `autobuild: false` during the CodeQL init so the repository's own configure / build steps run. This is intentional: the Phlex build actions are used to build exactly what you ship.
1313
- The workflow tries to locate and copy a compile_commands.json (from `phlex-src/build/` or `phlex-build/`) to the workspace root so diagnostic tools and manual inspection have a predictable path.
1414
- The workflow runs inside the repository container image (if provided) so it uses the same toolchain and environment your CI expects.
1515

1616
How the workflow is targeted at phlex-src
17+
1718
- The CMake configure & build steps are run with `-S phlex-src -B phlex-src/build` (or your Phlex-specific helpers are invoked in that context) so compile units, compiler flags, and generated compile_commands reference files under `phlex-src`.
1819
- The CodeQL config (`.github/codeql/codeql-config.yml`) contains an explicit `paths.include: - phlex-src/**` entry and excludes common vendor/build directories. This ensures CodeQL focuses on the intended code and not third-party or generated artifacts.
1920

2021
Recommended build type for CodeQL runs
22+
2123
- Use RelWithDebInfo (the workflow is already set to use this). Rationale:
2224
- RelWithDebInfo produces debug symbols (required for better mapping of findings to source/stack traces) while compiling with optimizations closer to production.
2325
- Pure Debug (-O0 -g) can be used for local triage of tricky alerts but is slower and sometimes produces analysis results that differ from optimized builds.
2426
- Release (no debug info) is not recommended for CodeQL because missing debug symbols reduce the quality of evidence and traces in findings.
2527

2628
How to run CodeQL locally (examples)
27-
1. Install the CodeQL CLI: https://codeql.github.com/docs/codeql-cli/getting-started/
29+
30+
1. Install the CodeQL CLI: <https://codeql.github.com/docs/codeql-cli/getting-started/>
2831
2. Create a C++ database for the phlex-src tree (example):
2932
- From repository root:
3033
codeql database create codeql-db --language=cpp --command="cmake -S phlex-src -B phlex-src/build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=ON && cmake --build phlex-src/build -- -j$(nproc)"
@@ -36,17 +39,20 @@ How to run CodeQL locally (examples)
3639
5. Open the SARIF in VS Code via the CodeQL extension or upload results via the GitHub UI.
3740

3841
Triage tips and workflows
42+
3943
- Start with high-confidence, high-severity alerts.
4044
- Use the evidence shown in the CodeQL alert to locate the vulnerable trace. RelWithDebInfo gives better evidence than Release.
4145
- When marking false positives, add a short rationale in the Code Scanning UI (this helps future auditors).
4246
- If the repo has many historical findings, consider a triage sprint to baseline or create a SARIF baseline to ignore existing alerts temporarily while blocking new ones.
4347

4448
How to add or change query packs
49+
4550
- The repository currently selects the language security-and-quality packs for C++ and Python. That is a good default.
4651
- If you want to add additional packs (experimental or specialized) you can:
4752
- Edit `.github/codeql/codeql-config.yml` and add additional packs there (use the canonical pack name), or
4853
- Add them to the init step in the workflow (`with: queries:`).
4954
- Example of adding packs in the workflow init:
55+
5056
```yaml
5157
uses: github/codeql-action/init@v4
5258
with:
@@ -59,12 +65,14 @@ How to add or change query packs
5965
```
6066
6167
Action-specific / workflow scanning
68+
6269
- There are CodeQL query packs that specifically analyze GitHub Actions workflow files (YAML) to find insecure patterns (for example: unsafe use of secrets, untrusted inputs in workflow run steps, usage of unpinned actions, etc.). If you rely on custom workflows or pass secrets/inputs to actions, consider enabling the GitHub Actions query pack if it is available in your CodeQL pack index.
6370
- To discover whether an official GitHub Actions pack exists or to find its exact name, see the CodeQL packs index (the canonical source) or search the public CodeQL repository:
64-
- https://github.com/github/codeql/tree/main/packs
71+
- <https://github.com/github/codeql/tree/main/packs>
6572
- Search for "github-actions" or "actions" in the CodeQL repo to find action-related packs and their exact pack names.
6673
6774
Recommended query packs for this repository (starting point)
75+
6876
- github/codeql/cpp-security-and-quality
6977
- Purpose: Core security and quality queries for C and C++ codebases. Good coverage of common memory safety, API misuse, and typical C/C++ pitfalls.
7078
- Why: Phlex is primarily C++, so this pack is the most important starting point.
@@ -73,6 +81,7 @@ Recommended query packs for this repository (starting point)
7381
- Why: Phlex contains some Python; include this pack so those files are analyzed.
7482
7583
Other useful pack categories to consider
84+
7685
- Language experimental packs (e.g., "cpp-experimental" / "python-experimental")
7786
- These provide newer/experimental queries that are not yet in the stable security-and-quality pack. Use cautiously: they can produce more findings and more false positives.
7887
- Action/workflow packs (GitHub Actions specific)
@@ -81,15 +90,17 @@ Other useful pack categories to consider
8190
- If Phlex heavily uses a certain third-party library that has its own pack, consider enabling it to get library-specific rules.
8291
8392
How to find the exact pack names and descriptions
93+
8494
- Official source: the GitHub CodeQL packs and QL repos:
85-
- https://github.com/github/codeql/tree/main/packs
86-
- https://github.com/github/codeql/tree/main/ql
95+
- <https://github.com/github/codeql/tree/main/packs>
96+
- <https://github.com/github/codeql/tree/main/ql>
8797
- CodeQL CLI (partial support for pack discovery):
8898
- You can use `codeql pack` and `codeql resolve` commands to inspect installed packs. The CodeQL CLI documentation shows usage for installing and listing packs.
8999
- GitHub docs:
90100
- Code scanning docs and the CodeQL repo README often list recommended packs and query categories.
91101

92102
Suggested immediate next steps
103+
93104
1. Keep the current packs (cpp-security-and-quality and python-security-and-quality) enabled in `.github/codeql/codeql-config.yml` — they are the right baseline.
94105
2. Search the CodeQL packs index for any GitHub Actions pack and enable it if you want workflow-level checks.
95106
3. If you want more thorough coverage, enable the experimental packs temporarily in a non-blocking run, review the alerts, then decide whether to include them in CI permanently.
@@ -125,4 +136,3 @@ When a PR is opened from a fork, the `GITHUB_TOKEN` does not have permission to
125136
## Contact / Ownership
126137

127138
- Consider adding a CODEOWNERS file for the phlex-src tree so triage notifications reach the most appropriate maintainers.
128-
```

.github/REUSABLE_WORKFLOWS.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ Once you have done this, you can trigger the auto-fix workflows by commenting on
2828
For workflows that automatically commit fixes to pull requests (e.g., formatters), you must create a Personal Access Token (PAT) and add it as a secret to your repository.
2929

3030
1. **Create a PAT:** Follow the GitHub documentation to [create a fine-grained personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token).
31-
- Give it a descriptive name (e.g., `WORKFLOW_FIXES_PAT`).
32-
- Grant it the following repository permissions:
33-
- `Contents`: `Read and write`
34-
- `Pull requests`: `Read and write`
31+
- Give it a descriptive name (e.g., `WORKFLOW_FIXES_PAT`).
32+
- Grant it the following repository permissions:
33+
- `Contents`: `Read and write`
34+
- `Pull requests`: `Read and write`
3535
2. **Add the PAT as a Repository Secret:**
36-
- In your repository, go to `Settings` > `Secrets and variables` > `Actions`.
37-
- Create a new repository secret named `WORKFLOW_PAT` and paste your PAT as the value.
36+
- In your repository, go to `Settings` > `Secrets and variables` > `Actions`.
37+
- Create a new repository secret named `WORKFLOW_PAT` and paste your PAT as the value.
3838

3939
### Calling a Reusable Workflow from a Different Repository
4040

@@ -80,14 +80,14 @@ jobs:
8080

8181
#### All Inputs
8282

83-
- `checkout-path` (string, optional): Path to check out code to.
84-
- `build-path` (string, optional): Path for build artifacts.
85-
- `skip-relevance-check` (boolean, optional, default: `false`): Bypass the check that only runs the build if C++ or CMake files have changed.
86-
- `build-combinations` (string, optional): A space-separated list of build combinations to run.
87-
- `ref` (string, optional): The branch or ref to check out.
88-
- `repo` (string, optional): The repository to check out from (e.g., `my-org/my-repo`).
89-
- `pr-base-sha` (string, optional): Base SHA of the PR for relevance check.
90-
- `pr-head-sha` (string, optional): Head SHA of the PR for relevance check.
83+
- `checkout-path` (string, optional): Path to check out code to.
84+
- `build-path` (string, optional): Path for build artifacts.
85+
- `skip-relevance-check` (boolean, optional, default: `false`): Bypass the check that only runs the build if C++ or CMake files have changed.
86+
- `build-combinations` (string, optional): A space-separated list of build combinations to run.
87+
- `ref` (string, optional): The branch or ref to check out.
88+
- `repo` (string, optional): The repository to check out from (e.g., `my-org/my-repo`).
89+
- `pr-base-sha` (string, optional): Base SHA of the PR for relevance check.
90+
- `pr-head-sha` (string, optional): Head SHA of the PR for relevance check.
9191

9292
### 2. `python-check.yaml`
9393

@@ -103,10 +103,10 @@ jobs:
103103

104104
#### All Inputs
105105

106-
- `checkout-path` (string, optional): Path to check out code to.
107-
- `skip-relevance-check` (boolean, optional, default: `false`): Bypass the check that only runs if Python files have changed.
108-
- `pr-base-sha` (string, optional): Base SHA of the PR for relevance check.
109-
- `pr-head-sha` (string, optional): Head SHA of the PR for relevance check.
106+
- `checkout-path` (string, optional): Path to check out code to.
107+
- `skip-relevance-check` (boolean, optional, default: `false`): Bypass the check that only runs if Python files have changed.
108+
- `pr-base-sha` (string, optional): Base SHA of the PR for relevance check.
109+
- `pr-head-sha` (string, optional): Head SHA of the PR for relevance check.
110110

111111
### 3. `cmake-format-fix.yaml`
112112

@@ -140,9 +140,9 @@ jobs:
140140

141141
#### All Inputs
142142

143-
- `checkout-path` (string, optional): Path to check out code to.
144-
- `ref` (string, **required**): The branch or ref to check out.
145-
- `repo` (string, **required**): The repository to check out from.
143+
- `checkout-path` (string, optional): Path to check out code to.
144+
- `ref` (string, **required**): The branch or ref to check out.
145+
- `repo` (string, **required**): The repository to check out from.
146146

147147
### 4. `python-fix.yaml`
148148

@@ -154,23 +154,23 @@ Automatically formats and fixes Python code using `ruff` and commits the changes
154154

155155
#### All Inputs
156156

157-
- `checkout-path` (string, optional): Path to check out code to.
158-
- `ref` (string, **required**): The branch or ref to check out.
159-
- `repo` (string, **required**): The repository to check out from.
157+
- `checkout-path` (string, optional): Path to check out code to.
158+
- `ref` (string, **required**): The branch or ref to check out.
159+
- `repo` (string, **required**): The repository to check out from.
160160

161161
### 5. `markdown-fix.yaml`
162162

163163
Automatically formats Markdown files using `markdownlint` and commits the changes. Typically triggered by an `issue_comment`.
164164

165-
#### Usage Example (in a workflow triggered by `issue_comment`)
165+
#### Usage Example: `markdown-fix.yaml` (in a workflow triggered by `issue_comment`)
166166

167167
*Similar to `cmake-format-fix.yaml`, but triggered by a command like `@<repo>bot markdown-fix`.*
168168

169-
#### All Inputs
169+
#### All Inputs: `markdown-fix.yaml`
170170

171-
- `checkout-path` (string, optional): Path to check out code to.
172-
- `ref` (string, **required**): The branch or ref to check out.
173-
- `repo` (string, **required**): The repository to check out from.
171+
- `checkout-path` (string, optional): Path to check out code to.
172+
- `ref` (string, **required**): The branch or ref to check out.
173+
- `repo` (string, **required**): The repository to check out from.
174174

175175
### Other Workflows
176176

.github/actions/detect-relevant-changes/action.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ runs:
5353
DEFAULT_TYPE_PATTERNS[cpp]=$'*.cpp\n*.hpp'
5454
DEFAULT_TYPE_PATTERNS[cmake]=$'CMakeLists.txt\n*.cmake'
5555
DEFAULT_TYPE_PATTERNS[python]=$'*.py'
56+
DEFAULT_TYPE_PATTERNS[md]=$'*.md'
5657
5758
parse_list() {
5859
local input="$1"

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ If the workspace root contains a `srcs/` directory, it may contain symbolic link
9494

9595
## Text Formatting Standards
9696

97-
**CRITICAL: Apply to ALL files you create or edit (bash scripts, Python, C++, YAML, Markdown, etc.)**
97+
### CRITICAL: Apply to ALL files you create or edit (bash scripts, Python, C++, YAML, Markdown, etc.)
9898

9999
- All text files must have their final line be non-empty and terminated with a single newline character, leaving no trailing blank lines
100100
- **Never add trailing whitespace on any line** (spaces or tabs at end of lines)

.github/workflows/markdown-check.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ jobs:
7070
path: phlex-src
7171

7272
- name: Add problem matcher
73-
uses: xt0rted/markdownlint-problem-matcher@v1
73+
uses: xt0rted/markdownlint-problem-matcher@b643b0751c371f357690337d4549221347c0e1bc # v1.1.0
7474

7575
- name: Run markdownlint
76-
uses: DavidAnson/markdownlint-cli2-action@v11
76+
uses: DavidAnson/markdownlint-cli2-action@8f3516061301755c97ff833a8e933f09282cc5b5 # v11.0.0
7777
with:
7878
globs: |
7979
phlex-src/**/*.md

.github/workflows/markdown-fix.yaml

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ on:
55
issue_comment:
66
types:
77
- created
8+
workflow_call:
9+
inputs:
10+
checkout-path:
11+
description: "Path to check out code to"
12+
required: false
13+
type: string
14+
ref:
15+
description: "The branch or ref to checkout"
16+
required: true
17+
type: string
18+
repo:
19+
description: "The repository to checkout from"
20+
required: true
21+
type: string
822
workflow_dispatch:
923
inputs:
1024
ref:
@@ -16,18 +30,23 @@ permissions:
1630
pull-requests: write
1731
contents: write
1832

33+
env:
34+
local_checkout_path: ${{ (github.event_name == 'workflow_call' && inputs.checkout-path) || format('{0}-src', github.event.repository.name) }}
35+
1936
jobs:
20-
pre-check:
37+
parse-command:
2138
runs-on: ubuntu-latest
22-
name: Parse command
39+
name: Parse bot command
2340
if: >
2441
github.event_name == 'workflow_dispatch' ||
2542
(
2643
github.event_name == 'issue_comment' &&
2744
github.event.issue.pull_request &&
2845
(
2946
startsWith(github.event.comment.body, '@phlexbot format') ||
30-
startsWith(github.event.comment.body, '@phlexbot markdown-fix')
47+
startsWith(github.event.comment.body, '@phlexbot markdown-fix') ||
48+
startsWith(github.event.comment.body, format('@{0}bot format', github.event.repository.name)) ||
49+
startsWith(github.event.comment.body, format('@{0}bot markdown-fix', github.event.repository.name))
3150
)
3251
)
3352
outputs:
@@ -43,29 +62,29 @@ jobs:
4362
apply_fixes:
4463
runs-on: ubuntu-latest
4564
name: Apply fixes
46-
needs: pre-check
47-
if: ${{ needs.pre-check.result == 'success' }}
65+
needs: parse-command
66+
if: github.event_name == 'workflow_call' || needs.parse-command.result == 'success'
4867
steps:
4968
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5069
with:
51-
path: phlex-src
52-
ref: ${{ needs.pre-check.outputs.ref }}
53-
repository: ${{ needs.pre-check.outputs.repo }}
70+
path: ${{ env.local_checkout_path }}
71+
ref: ${{ (github.event_name == 'workflow_call' && inputs.ref) || needs.parse-command.outputs.ref }}
72+
repository: ${{ (github.event_name == 'workflow_call' && inputs.repo) || needs.parse-command.outputs.repo }}
5473
token: ${{ secrets.WORKFLOW_PAT }}
5574

5675
- name: Run markdownlint
57-
uses: DavidAnson/markdownlint-cli2-action@v11
76+
uses: DavidAnson/markdownlint-cli2-action@8f3516061301755c97ff833a8e933f09282cc5b5 # v11.0.0
5877
with:
5978
globs: |
60-
phlex-src/**/*.md
61-
!phlex-src/**/CHANGELOG.md
79+
${{ env.local_checkout_path }}/**/*.md
80+
!${{ env.local_checkout_path }}/**/CHANGELOG.md
6281
fix: true
6382

6483
- name: Handle fix commit
65-
uses: ./phlex-src/.github/actions/handle-fix-commit
84+
uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main
6685
with:
6786
tool: markdownlint
68-
working-directory: phlex-src
87+
working-directory: ${{ env.local_checkout_path }}
6988
token: ${{ secrets.WORKFLOW_PAT }}
70-
pr-info-ref: ${{ needs.pre-check.outputs.ref }}
71-
pr-info-repo: ${{ needs.pre-check.outputs.repo }}
89+
pr-info-ref: ${{ (github.event_name == 'workflow_call' && inputs.ref) || needs.parse-command.outputs.ref }}
90+
pr-info-repo: ${{ (github.event_name == 'workflow_call' && inputs.repo) || needs.parse-command.outputs.repo }}

.markdownlint.jsonc

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
{
2-
"config": {
3-
"default": true,
4-
"MD012": true,
5-
"MD013": false,
6-
"MD022": true,
7-
"MD031": true,
8-
"MD032": true,
9-
"MD034": true,
10-
"MD036": {
11-
"punctuation": ".,;:!?"
12-
},
13-
"MD040": true
14-
}
2+
"default": true,
3+
"MD012": true,
4+
"MD013": false,
5+
"MD022": true,
6+
"MD031": true,
7+
"MD032": true,
8+
"MD034": true,
9+
"MD036": {
10+
"punctuation": ".,;:!?"
11+
},
12+
"MD040": true
1513
}

DEVELOPING.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ The project automatically runs coverage analysis on every PR and push to main/de
114114

115115
Coverage reports are uploaded to Codecov for tracking and PR integration, with automatic comments on PRs showing coverage changes.
116116

117-
118117
## On GitHub Copilot
119118

120119
The `.github/copilot-instructions.md` contains various "ground rules" to be observed by GitHub Copilot for every session. They are intended to be useful for everyone, but you can override or augment them yourself by creating a `<workspace>/.github/copilot-instructions.md` file. If this file exists, its contents will be merged with—but take precedence over—the repository level instructions.

0 commit comments

Comments
 (0)