Skip to content

Commit 7b9cee6

Browse files
emmanuelnkclaudebcheidemann
authored
feat: diagnostics reporter and action improvements (#71)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Ben Heidemann <ben@heidemann.dev>
1 parent e1c69c3 commit 7b9cee6

File tree

58 files changed

+4934
-547
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4934
-547
lines changed

AGENTS.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55
pnpm install
66
```
77

8-
## Schema Change Fix
8+
## Development Guidance
9+
### Generating Action Types
10+
From the root directory, run
11+
```
12+
pnpm generate-action-types
13+
```
14+
to correctly update action types.
15+
16+
### Schema Change Fix
917
1. When the schema (source: schemastore) changes, we want to update the types:
1018
```bash
1119
pnpm generate-workflow-types
@@ -17,10 +25,10 @@ pnpm install
1725
Ensure Coverage remains at 100%. If not, create the necessary test(s) to keep it at 100%.
1826

1927
3. Commit the change
20-
a. The branch name should be of the format `chore/schema-update-YYMMDD` if the change only contains schema changes. If the branch contains more changes, use conventional commit and branch naming style.
21-
b. The commit message should have the title format `chore: update types` if only schema changes else use conventional commit style.
22-
c. You can add more detail to the commit message but be succint and concise.
23-
d. Finally, the pre-commit script will run and ensure that workflow files are regenerated.
28+
1. The branch name should be of the format `chore/schema-update-YYMMDD` if the change only contains schema changes. If the branch contains more changes, use conventional commit and branch naming style.
29+
2. The commit message should have the title format `chore: update types` if only schema changes else use conventional commit style.
30+
3. You can add more detail to the commit message but be succint and concise.
31+
4. Finally, the pre-commit script will run and ensure that workflow files are regenerated.
2432

2533
4. Create the pull request
2634
a. When you create the PR, be equally succinct and concise in the PR description.

CLAUDE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
**Note**: This project uses AGENTS.md files for detailed guidance.
6+
7+
## Primary Reference
8+
9+
Please see `AGENTS.md` in this same directory for the main project documentation and guidance.
10+
11+
## Additional Component-Specific Guidance
12+
13+
For detailed module-specific implementation guides, also check for AGENTS.md files in subdirectories throughout the project.
14+
These component-specific AGENTS.md files contain targeted guidance for working with those particular areas of the codebase.
15+
16+
## Updating AGENTS.md Files
17+
18+
When you discover new information that would be helpful for future development work, please:
19+
20+
- **Update existing AGENTS.md files** when you learn implementation details, debugging insights, or architectural patterns specific to that component
21+
- **Create new AGENTS.md files** in relevant directories when working with areas that don't yet have documentation
22+
- **Add valuable insights** such as common pitfalls, debugging techniques, dependency relationships, or implementation patterns
23+
24+
This helps build a comprehensive knowledge base for the codebase over time.

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,61 @@ If you want to change how github-actions-workflow-ts generates the yaml files, y
321321
| refs | If true, convert duplicate objects into references in YAML | `Boolean` | false |
322322
| headerText | Replace the header text in generated YAML files with your own text. <br>If you want the source filename and path in the text, use `<source-file-path>` in<br>the text and it will be replaced with the path to the source-file. | `Array<string>` | # ----DO-NOT-MODIFY-THIS-FILE----<br># This file was automatically generated by github-actions-workflow-ts. <br># Instead, modify `<source-file-path>`<br># ----DO-NOT-MODIFY-THIS-FILE---- |
323323
| dumpOptions | Options for the dump function of js-yaml. See [all the options here](https://github.com/nodeca/js-yaml#dump-object---options-) | Record <string, any> | Uses the default options |
324+
| diagnostics | Configure diagnostic warnings emitted during build. See [Diagnostics Configuration](#diagnostics-configuration) below. | `Object` | undefined |
325+
326+
</details>
327+
328+
### Diagnostics Configuration
329+
When using `@github-actions-workflow-ts/actions`, the CLI emits warnings for version mismatches (e.g., using `actions/checkout@v3` with `ActionsCheckoutV4`). You can configure these diagnostics in `wac.config.json`:
330+
331+
<details><summary>See diagnostics options</summary>
332+
333+
```json
334+
{
335+
"diagnostics": {
336+
"rules": {
337+
"action-version-unverifiable": "off",
338+
"action-version-semver-violation": {
339+
"severity": "warn",
340+
"exclude": ["actions/checkout@*"]
341+
}
342+
}
343+
}
344+
}
345+
```
346+
347+
**Diagnostic Codes:**
348+
- `action-version-unverifiable`: When the action version cannot be verified (non-semver ref or different repo)
349+
- `action-version-semver-violation`: When the action version doesn't satisfy the expected semver constraint
350+
351+
**Severity Levels:**
352+
- `"off"`: Suppress the diagnostic entirely
353+
- `"warn"`: Emit as a warning (default)
354+
- `"error"`: Upgrade to an error
355+
356+
**Exclude Patterns:**
357+
Use `exclude` to suppress warnings for specific actions. Supports wildcards:
358+
- `"actions/checkout@v3"` - exact match
359+
- `"actions/checkout@*"` - matches any version of actions/checkout
360+
- `"actions/*"` - matches all actions from the `actions` org
361+
362+
**In-Code Suppression:**
363+
You can also suppress warnings directly in code using `suppressWarnings` prop or `Diagnostics.suppress()`:
364+
365+
```typescript
366+
// Using suppressWarnings prop
367+
new ActionsCheckoutV4({
368+
uses: 'actions/checkout@v3',
369+
suppressWarnings: ['action-version-semver-violation'],
370+
})
371+
372+
// Using Diagnostics.suppress()
373+
new ActionsCheckoutV4({
374+
uses: Diagnostics.suppress('actions/checkout@v3', 'action-version-semver-violation'),
375+
})
376+
```
377+
378+
See the [Typed Actions documentation](./packages/actions/README.md) for more details.
324379

325380
</details>
326381

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"name": "github-actions-workflow-ts-monorepo",
33
"private": true,
44
"description": "Generate GitHub Actions workflow files using TypeScript",

packages/actions/README.md

Lines changed: 139 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { ActionsCheckoutV4, ActionsSetupNodeV4 } from '@github-actions-workflow-
1818

1919
const checkout = new ActionsCheckoutV4({
2020
name: 'Checkout code',
21-
// fields are validated and typed with descriptions
21+
// fields are validated and typed with descriptions
2222
with: {
2323
'fetch-depth': 0,
2424
},
@@ -51,31 +51,147 @@ const job = new NormalJob('build', { 'runs-on': 'ubuntu-latest' })
5151
.addStep(setupNode)
5252
```
5353

54+
## Version Validation & Diagnostics
55+
56+
When using typed actions, the CLI validates that the action version you specify matches the expected version. For example, if you use `ActionsCheckoutV4` but override the `uses` field to `actions/checkout@v3`, a warning will be emitted during build.
57+
58+
### Diagnostic Codes
59+
60+
| Code | Description |
61+
|------|-------------|
62+
| `action-version-unverifiable` | The action version cannot be verified because the git ref is not a valid semver (e.g., `@main`, `@feature-branch`) or the repository doesn't match |
63+
| `action-version-semver-violation` | The action version doesn't satisfy the expected semver constraint (e.g., using `@v3` with a `V4` typed action) |
64+
65+
### Configuring Diagnostics
66+
67+
You can configure how these diagnostics are handled in your `wac.config.json`:
68+
69+
```json
70+
{
71+
"diagnostics": {
72+
"rules": {
73+
"action-version-unverifiable": "off",
74+
"action-version-semver-violation": "error"
75+
}
76+
}
77+
}
78+
```
79+
80+
#### Severity Levels
81+
82+
- `"off"` - Suppress the diagnostic entirely
83+
- `"warn"` - Emit as a warning (default behavior)
84+
- `"error"` - Upgrade to an error
85+
86+
#### Advanced: Per-Action Rules
87+
88+
You can suppress diagnostics for specific actions while keeping them enabled for others:
89+
90+
```json
91+
{
92+
"diagnostics": {
93+
"rules": {
94+
"action-version-semver-violation": {
95+
"severity": "error",
96+
"exclude": [
97+
"actions/checkout@*",
98+
"actions/setup-node@v3"
99+
]
100+
}
101+
}
102+
}
103+
}
104+
```
105+
106+
The `exclude` array supports patterns:
107+
- Exact match: `"actions/checkout@v3"`
108+
- Wildcard version: `"actions/checkout@*"` (matches any version)
109+
- Wildcard repo: `"actions/*"` (matches all actions from an org)
110+
111+
### Example: Intentionally Using an Older Version
112+
113+
If you need to use an older action version for compatibility reasons, you can suppress the warning in two ways:
114+
115+
#### Option 1: In-Code Suppression with `suppressWarnings` prop
116+
117+
```typescript
118+
import { ActionsCheckoutV4 } from '@github-actions-workflow-ts/actions'
119+
120+
const checkout = new ActionsCheckoutV4({
121+
name: 'Checkout',
122+
uses: 'actions/checkout@v3',
123+
suppressWarnings: ['action-version-semver-violation'],
124+
})
125+
```
126+
127+
#### Option 2: In-Code Suppression with `Diagnostics.suppress()`
128+
129+
```typescript
130+
import { ActionsCheckoutV4 } from '@github-actions-workflow-ts/actions'
131+
import { Diagnostics } from '@github-actions-workflow-ts/lib'
132+
133+
const checkout = new ActionsCheckoutV4({
134+
name: 'Checkout',
135+
uses: Diagnostics.suppress(
136+
'actions/checkout@v3',
137+
'action-version-semver-violation',
138+
'Using v3 for legacy compatibility' // optional reason
139+
),
140+
})
141+
```
142+
143+
You can also suppress multiple codes:
144+
145+
```typescript
146+
const checkout = new ActionsCheckoutV4({
147+
uses: Diagnostics.suppress(
148+
'actions/checkout@v3',
149+
['action-version-semver-violation', 'action-version-unverifiable'],
150+
),
151+
})
152+
```
153+
154+
#### Option 3: Configuration-based Suppression
155+
156+
Add to `wac.config.json`:
157+
158+
```json
159+
{
160+
"diagnostics": {
161+
"rules": {
162+
"action-version-semver-violation": {
163+
"exclude": ["actions/checkout@v3"]
164+
}
165+
}
166+
}
167+
}
168+
```
169+
54170
## Available Actions
55171

56172
<!-- GENERATED-ACTIONS-TABLE:START -->
57-
| Action | Versions | Links |
58-
|--------|----------|-------|
59-
| actions/cache | `ActionsCacheV3`, `ActionsCacheV4` | [GitHub](https://github.com/actions/cache) · [Marketplace](https://github.com/marketplace/actions/cache) |
60-
| actions/checkout | `ActionsCheckoutV3`, `ActionsCheckoutV4`, `ActionsCheckoutV5`, `ActionsCheckoutV6` | [GitHub](https://github.com/actions/checkout) · [Marketplace](https://github.com/marketplace/actions/checkout) |
61-
| actions/download-artifact | `ActionsDownloadArtifactV3`, `ActionsDownloadArtifactV4` | [GitHub](https://github.com/actions/download-artifact) · [Marketplace](https://github.com/marketplace/actions/download-artifact) |
62-
| actions/github-script | `ActionsGithubScriptV6`, `ActionsGithubScriptV7`, `ActionsGithubScriptV8` | [GitHub](https://github.com/actions/github-script) · [Marketplace](https://github.com/marketplace/actions/github-script) |
63-
| actions/setup-node | `ActionsSetupNodeV3`, `ActionsSetupNodeV4` | [GitHub](https://github.com/actions/setup-node) · [Marketplace](https://github.com/marketplace/actions/setup-node) |
64-
| actions/setup-python | `ActionsSetupPythonV4`, `ActionsSetupPythonV5` | [GitHub](https://github.com/actions/setup-python) · [Marketplace](https://github.com/marketplace/actions/setup-python) |
65-
| actions/upload-artifact | `ActionsUploadArtifactV3`, `ActionsUploadArtifactV4` | [GitHub](https://github.com/actions/upload-artifact) · [Marketplace](https://github.com/marketplace/actions/upload-artifact) |
66-
| aws-actions/amazon-ecr-login | `AwsActionsAmazonEcrLoginV2` | [GitHub](https://github.com/aws-actions/amazon-ecr-login) · [Marketplace](https://github.com/marketplace/actions/amazon-ecr-login) |
67-
| aws-actions/amazon-ecs-deploy-task-definition | `AwsActionsAmazonEcsDeployTaskDefinitionV2` | [GitHub](https://github.com/aws-actions/amazon-ecs-deploy-task-definition) · [Marketplace](https://github.com/marketplace/actions/amazon-ecs-deploy-task-definition) |
68-
| aws-actions/amazon-ecs-render-task-definition | `AwsActionsAmazonEcsRenderTaskDefinitionV1` | [GitHub](https://github.com/aws-actions/amazon-ecs-render-task-definition) · [Marketplace](https://github.com/marketplace/actions/amazon-ecs-render-task-definition) |
69-
| aws-actions/aws-cloudformation-github-deploy | `AwsActionsAwsCloudformationGithubDeployV1` | [GitHub](https://github.com/aws-actions/aws-cloudformation-github-deploy) · [Marketplace](https://github.com/marketplace/actions/aws-cloudformation-github-deploy) |
70-
| aws-actions/aws-codebuild-run-build | `AwsActionsAwsCodebuildRunBuildV1` | [GitHub](https://github.com/aws-actions/aws-codebuild-run-build) · [Marketplace](https://github.com/marketplace/actions/aws-codebuild-run-build) |
71-
| aws-actions/configure-aws-credentials | `AwsActionsConfigureAwsCredentialsV3`, `AwsActionsConfigureAwsCredentialsV4`, `AwsActionsConfigureAwsCredentialsV5` | [GitHub](https://github.com/aws-actions/configure-aws-credentials) · [Marketplace](https://github.com/marketplace/actions/configure-aws-credentials) |
72-
| docker/build-push-action | `DockerBuildPushActionV5`, `DockerBuildPushActionV6` | [GitHub](https://github.com/docker/build-push-action) · [Marketplace](https://github.com/marketplace/actions/build-push-action) |
73-
| docker/login-action | `DockerLoginActionV2`, `DockerLoginActionV3` | [GitHub](https://github.com/docker/login-action) · [Marketplace](https://github.com/marketplace/actions/login-action) |
74-
| docker/setup-buildx-action | `DockerSetupBuildxActionV2`, `DockerSetupBuildxActionV3` | [GitHub](https://github.com/docker/setup-buildx-action) · [Marketplace](https://github.com/marketplace/actions/setup-buildx-action) |
75-
| github/codeql-action | `GithubCodeqlActionV2`, `GithubCodeqlActionV3` | [GitHub](https://github.com/github/codeql-action) · [Marketplace](https://github.com/marketplace/actions/codeql-action) |
76-
| peaceiris/actions-gh-pages | `PeaceirisActionsGhPagesV3`, `PeaceirisActionsGhPagesV4` | [GitHub](https://github.com/peaceiris/actions-gh-pages) · [Marketplace](https://github.com/marketplace/actions/actions-gh-pages) |
77-
| release-drafter/release-drafter | `ReleaseDrafterReleaseDrafterV6` | [GitHub](https://github.com/release-drafter/release-drafter) · [Marketplace](https://github.com/marketplace/actions/release-drafter) |
78-
| softprops/action-gh-release | `SoftpropsActionGhReleaseV1`, `SoftpropsActionGhReleaseV2` | [GitHub](https://github.com/softprops/action-gh-release) · [Marketplace](https://github.com/marketplace/actions/action-gh-release) |
173+
| Action | Versions | GitHub |
174+
|--------|----------|--------|
175+
| actions/cache | `ActionsCacheV3`, `ActionsCacheV4` | [GitHub](https://github.com/actions/cache) |
176+
| actions/checkout | `ActionsCheckoutV3`, `ActionsCheckoutV4`, `ActionsCheckoutV5`, `ActionsCheckoutV6` | [GitHub](https://github.com/actions/checkout) |
177+
| actions/download-artifact | `ActionsDownloadArtifactV3`, `ActionsDownloadArtifactV4` | [GitHub](https://github.com/actions/download-artifact) |
178+
| actions/github-script | `ActionsGithubScriptV6`, `ActionsGithubScriptV7`, `ActionsGithubScriptV8` | [GitHub](https://github.com/actions/github-script) |
179+
| actions/setup-node | `ActionsSetupNodeV3`, `ActionsSetupNodeV4` | [GitHub](https://github.com/actions/setup-node) |
180+
| actions/setup-python | `ActionsSetupPythonV4`, `ActionsSetupPythonV5` | [GitHub](https://github.com/actions/setup-python) |
181+
| actions/upload-artifact | `ActionsUploadArtifactV3`, `ActionsUploadArtifactV4` | [GitHub](https://github.com/actions/upload-artifact) |
182+
| aws-actions/amazon-ecr-login | `AwsActionsAmazonEcrLoginV2` | [GitHub](https://github.com/aws-actions/amazon-ecr-login) |
183+
| aws-actions/amazon-ecs-deploy-task-definition | `AwsActionsAmazonEcsDeployTaskDefinitionV2` | [GitHub](https://github.com/aws-actions/amazon-ecs-deploy-task-definition) |
184+
| aws-actions/amazon-ecs-render-task-definition | `AwsActionsAmazonEcsRenderTaskDefinitionV1` | [GitHub](https://github.com/aws-actions/amazon-ecs-render-task-definition) |
185+
| aws-actions/aws-cloudformation-github-deploy | `AwsActionsAwsCloudformationGithubDeployV1` | [GitHub](https://github.com/aws-actions/aws-cloudformation-github-deploy) |
186+
| aws-actions/aws-codebuild-run-build | `AwsActionsAwsCodebuildRunBuildV1` | [GitHub](https://github.com/aws-actions/aws-codebuild-run-build) |
187+
| aws-actions/configure-aws-credentials | `AwsActionsConfigureAwsCredentialsV3`, `AwsActionsConfigureAwsCredentialsV4`, `AwsActionsConfigureAwsCredentialsV5` | [GitHub](https://github.com/aws-actions/configure-aws-credentials) |
188+
| docker/build-push-action | `DockerBuildPushActionV5`, `DockerBuildPushActionV6` | [GitHub](https://github.com/docker/build-push-action) |
189+
| docker/login-action | `DockerLoginActionV2`, `DockerLoginActionV3` | [GitHub](https://github.com/docker/login-action) |
190+
| docker/setup-buildx-action | `DockerSetupBuildxActionV2`, `DockerSetupBuildxActionV3` | [GitHub](https://github.com/docker/setup-buildx-action) |
191+
| github/codeql-action | `GithubCodeqlActionV2`, `GithubCodeqlActionV3` | [GitHub](https://github.com/github/codeql-action) |
192+
| peaceiris/actions-gh-pages | `PeaceirisActionsGhPagesV3`, `PeaceirisActionsGhPagesV4` | [GitHub](https://github.com/peaceiris/actions-gh-pages) |
193+
| release-drafter/release-drafter | `ReleaseDrafterReleaseDrafterV6` | [GitHub](https://github.com/release-drafter/release-drafter) |
194+
| softprops/action-gh-release | `SoftpropsActionGhReleaseV1`, `SoftpropsActionGhReleaseV2` | [GitHub](https://github.com/softprops/action-gh-release) |
79195
<!-- GENERATED-ACTIONS-TABLE:END -->
80196

81197
# Development

0 commit comments

Comments
 (0)