cdk-diff-summary 1.1.1__tar.gz → 1.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {cdk_diff_summary-1.1.1/src/cdk_diff_summary.egg-info → cdk_diff_summary-1.1.2}/PKG-INFO +49 -24
  2. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/README.md +44 -19
  3. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/pyproject.toml +5 -5
  4. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/src/cdk_diff_summary/__init__.py +1 -1
  5. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/src/cdk_diff_summary/cli.py +2 -2
  6. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2/src/cdk_diff_summary.egg-info}/PKG-INFO +49 -24
  7. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/tests/test_cli.py +36 -19
  8. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/LICENSE +0 -0
  9. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/setup.cfg +0 -0
  10. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/src/cdk_diff_summary/config.py +0 -0
  11. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/src/cdk_diff_summary/diff.py +0 -0
  12. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/src/cdk_diff_summary/policy.py +0 -0
  13. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/src/cdk_diff_summary/py.typed +0 -0
  14. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/src/cdk_diff_summary/render.py +0 -0
  15. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/src/cdk_diff_summary.egg-info/SOURCES.txt +0 -0
  16. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/src/cdk_diff_summary.egg-info/dependency_links.txt +0 -0
  17. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/src/cdk_diff_summary.egg-info/entry_points.txt +0 -0
  18. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/src/cdk_diff_summary.egg-info/requires.txt +0 -0
  19. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/src/cdk_diff_summary.egg-info/top_level.txt +0 -0
  20. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/tests/test_diff.py +0 -0
  21. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/tests/test_policy.py +0 -0
  22. {cdk_diff_summary-1.1.1 → cdk_diff_summary-1.1.2}/tests/test_render.py +0 -0
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cdk-diff-summary
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: Summarize AWS CDK diff JSON as compact Markdown.
5
5
  Author: cdk-diff-summary contributors
6
6
  License-Expression: MIT
7
- Project-URL: Homepage, https://github.com/jalcock501/cdk-diff-summary-pypi
8
- Project-URL: Repository, https://github.com/jalcock501/cdk-diff-summary-pypi
9
- Project-URL: Documentation, https://github.com/jalcock501/cdk-diff-summary-pypi#readme
10
- Project-URL: Issues, https://github.com/jalcock501/cdk-diff-summary-pypi/issues
7
+ Project-URL: Homepage, https://github.com/jalcock501/cdk-diff-summary
8
+ Project-URL: Repository, https://github.com/jalcock501/cdk-diff-summary
9
+ Project-URL: Documentation, https://github.com/jalcock501/cdk-diff-summary#readme
10
+ Project-URL: Issues, https://github.com/jalcock501/cdk-diff-summary/issues
11
11
  Keywords: aws,cdk,cloudformation,github-actions,diff
12
12
  Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Environment :: Console
@@ -33,24 +33,50 @@ Dynamic: license-file
33
33
 
34
34
  `cdk-diff-summary` reads AWS CDK diff JSON and renders a compact Markdown summary.
35
35
 
36
- It is useful locally, in CI systems, and in GitHub Actions workflows where raw CDK or CloudFormation diffs are too noisy. It groups adds, modifies, removes, replacements, security group rule changes, and other changes while reducing common churn from IAM policy documents and CDK asset hashes.
36
+ This repository is the source of truth for both:
37
+
38
+ - the GitHub Marketplace composite action `jalcock501/cdk-diff-summary`
39
+ - the PyPI package `cdk-diff-summary`
40
+
41
+ It is designed for pull requests and CI jobs where raw CDK or CloudFormation diffs are too noisy. The summary groups adds, modifies, removes, replacements, security group rule changes, and other changes while reducing common churn from IAM policy documents and CDK asset hashes.
37
42
 
38
43
  The tool deliberately shows changed field paths only, not before/after values, to avoid exposing sensitive infrastructure values in summaries.
39
44
 
40
- ## Install
45
+ ## GitHub Action Usage
41
46
 
42
- ```bash
43
- pipx install cdk-diff-summary
47
+ ```yaml
48
+ - name: Generate CDK diff JSON
49
+ run: npx cdk diff --json > cdk-diff.json
50
+
51
+ - name: Summarize CDK diff
52
+ uses: jalcock501/cdk-diff-summary@v1
53
+ with:
54
+ diff-json-path: cdk-diff.json
44
55
  ```
45
56
 
46
- or:
57
+ The composite action runs the local checked-out code from the action tag. It does not install `cdk-diff-summary` from PyPI at runtime.
58
+
59
+ ## Action Inputs
60
+
61
+ | Input | Required | Default | Description |
62
+ | --- | --- | --- | --- |
63
+ | `diff-json-path` | yes | | Path to JSON produced by `cdk diff --json`. |
64
+ | `summary-title` | no | `CDK diff summary` | Markdown heading for the summary. |
65
+ | `max-changed-fields` | no | `8` | Maximum changed field paths shown per resource. |
66
+ | `collapse-iam-policies` | no | `true` | Collapse large IAM policy document diffs to a single path such as `PolicyDocument`. |
67
+ | `collapse-assets` | no | `true` | Suppress or collapse common CDK asset/hash churn such as asset hashes, S3 object keys, Lambda code hashes, Docker image asset hashes, and CDK metadata asset paths. |
68
+ | `fail-on-remove` | no | `false` | Write the summary, then fail the step if visible removes exist. |
69
+ | `fail-on-replace` | no | `false` | Write the summary, then fail the step if visible replacements exist. |
70
+ | `summary-output-path` | no | | Optional file path to also append the generated Markdown summary. |
71
+
72
+ ## PyPI / CLI Usage
73
+
74
+ Install with `pipx`:
47
75
 
48
76
  ```bash
49
- python -m pip install cdk-diff-summary
77
+ pipx install cdk-diff-summary
50
78
  ```
51
79
 
52
- ## Usage
53
-
54
80
  Generate CDK diff JSON:
55
81
 
56
82
  ```bash
@@ -92,8 +118,8 @@ cdk-diff-summary cdk-diff.json --fail-on-remove --fail-on-replace
92
118
  | `--max-changed-fields` | Maximum changed field paths shown per resource. Defaults to `8`. |
93
119
  | `--collapse-iam-policies` / `--no-collapse-iam-policies` | Collapse large IAM policy document diffs to compact paths. Enabled by default. |
94
120
  | `--collapse-assets` / `--no-collapse-assets` | Collapse common CDK asset/hash churn. Enabled by default. |
95
- | `--fail-on-remove` | Write the summary, then exit non-zero if visible resource removes exist. |
96
- | `--fail-on-replace` | Write the summary, then exit non-zero if visible resource replacements exist. |
121
+ | `--fail-on-remove` / `--no-fail-on-remove` | Write the summary, then exit non-zero if visible resource removes exist. Disabled by default. |
122
+ | `--fail-on-replace` / `--no-fail-on-replace` | Write the summary, then exit non-zero if visible resource replacements exist. Disabled by default. |
97
123
  | `--output` | Optional path to append the generated Markdown summary. |
98
124
  | `--github-step-summary` | Optional path to append GitHub Step Summary Markdown. Defaults to `$GITHUB_STEP_SUMMARY`. |
99
125
 
@@ -113,6 +139,8 @@ CLI arguments take precedence over environment variables.
113
139
 
114
140
  ## Example Output
115
141
 
142
+ ![Screenshot of a larger CDK diff summary in GitHub Step Summary](docs/assets/cdk-diff-summary-larger-example.png)
143
+
116
144
  ```markdown
117
145
  ## CDK diff summary
118
146
 
@@ -150,21 +178,18 @@ python -m build
150
178
  twine check dist/*
151
179
  ```
152
180
 
153
- Run from source:
181
+ Run the action wrapper directly:
154
182
 
155
183
  ```bash
156
- cdk-diff-summary example_cdk_diff_json/cdk-diff-json-tiny.json
184
+ DIFF_JSON_PATH=example_cdk_diff_json/cdk-diff-json-tiny.json \
185
+ GITHUB_STEP_SUMMARY=/tmp/cdk-summary.md \
186
+ python scripts/cdk_diff_summary.py
157
187
  ```
158
188
 
159
- ## Publishing
160
-
161
- This package is ready for PyPI trusted publishing. Create a PyPI project named `cdk-diff-summary`, configure a trusted publisher for this repository and the `publish.yml` workflow, then create a GitHub release.
162
-
163
- For a manual dry run:
189
+ Run the installed CLI:
164
190
 
165
191
  ```bash
166
- python -m build
167
- twine check dist/*
192
+ cdk-diff-summary example_cdk_diff_json/cdk-diff-json-tiny.json
168
193
  ```
169
194
 
170
195
  CDK diff JSON shape can vary by CDK version. If parsing fails, please open an issue with a sanitized example of the JSON shape that failed.
@@ -2,24 +2,50 @@
2
2
 
3
3
  `cdk-diff-summary` reads AWS CDK diff JSON and renders a compact Markdown summary.
4
4
 
5
- It is useful locally, in CI systems, and in GitHub Actions workflows where raw CDK or CloudFormation diffs are too noisy. It groups adds, modifies, removes, replacements, security group rule changes, and other changes while reducing common churn from IAM policy documents and CDK asset hashes.
5
+ This repository is the source of truth for both:
6
+
7
+ - the GitHub Marketplace composite action `jalcock501/cdk-diff-summary`
8
+ - the PyPI package `cdk-diff-summary`
9
+
10
+ It is designed for pull requests and CI jobs where raw CDK or CloudFormation diffs are too noisy. The summary groups adds, modifies, removes, replacements, security group rule changes, and other changes while reducing common churn from IAM policy documents and CDK asset hashes.
6
11
 
7
12
  The tool deliberately shows changed field paths only, not before/after values, to avoid exposing sensitive infrastructure values in summaries.
8
13
 
9
- ## Install
14
+ ## GitHub Action Usage
10
15
 
11
- ```bash
12
- pipx install cdk-diff-summary
16
+ ```yaml
17
+ - name: Generate CDK diff JSON
18
+ run: npx cdk diff --json > cdk-diff.json
19
+
20
+ - name: Summarize CDK diff
21
+ uses: jalcock501/cdk-diff-summary@v1
22
+ with:
23
+ diff-json-path: cdk-diff.json
13
24
  ```
14
25
 
15
- or:
26
+ The composite action runs the local checked-out code from the action tag. It does not install `cdk-diff-summary` from PyPI at runtime.
27
+
28
+ ## Action Inputs
29
+
30
+ | Input | Required | Default | Description |
31
+ | --- | --- | --- | --- |
32
+ | `diff-json-path` | yes | | Path to JSON produced by `cdk diff --json`. |
33
+ | `summary-title` | no | `CDK diff summary` | Markdown heading for the summary. |
34
+ | `max-changed-fields` | no | `8` | Maximum changed field paths shown per resource. |
35
+ | `collapse-iam-policies` | no | `true` | Collapse large IAM policy document diffs to a single path such as `PolicyDocument`. |
36
+ | `collapse-assets` | no | `true` | Suppress or collapse common CDK asset/hash churn such as asset hashes, S3 object keys, Lambda code hashes, Docker image asset hashes, and CDK metadata asset paths. |
37
+ | `fail-on-remove` | no | `false` | Write the summary, then fail the step if visible removes exist. |
38
+ | `fail-on-replace` | no | `false` | Write the summary, then fail the step if visible replacements exist. |
39
+ | `summary-output-path` | no | | Optional file path to also append the generated Markdown summary. |
40
+
41
+ ## PyPI / CLI Usage
42
+
43
+ Install with `pipx`:
16
44
 
17
45
  ```bash
18
- python -m pip install cdk-diff-summary
46
+ pipx install cdk-diff-summary
19
47
  ```
20
48
 
21
- ## Usage
22
-
23
49
  Generate CDK diff JSON:
24
50
 
25
51
  ```bash
@@ -61,8 +87,8 @@ cdk-diff-summary cdk-diff.json --fail-on-remove --fail-on-replace
61
87
  | `--max-changed-fields` | Maximum changed field paths shown per resource. Defaults to `8`. |
62
88
  | `--collapse-iam-policies` / `--no-collapse-iam-policies` | Collapse large IAM policy document diffs to compact paths. Enabled by default. |
63
89
  | `--collapse-assets` / `--no-collapse-assets` | Collapse common CDK asset/hash churn. Enabled by default. |
64
- | `--fail-on-remove` | Write the summary, then exit non-zero if visible resource removes exist. |
65
- | `--fail-on-replace` | Write the summary, then exit non-zero if visible resource replacements exist. |
90
+ | `--fail-on-remove` / `--no-fail-on-remove` | Write the summary, then exit non-zero if visible resource removes exist. Disabled by default. |
91
+ | `--fail-on-replace` / `--no-fail-on-replace` | Write the summary, then exit non-zero if visible resource replacements exist. Disabled by default. |
66
92
  | `--output` | Optional path to append the generated Markdown summary. |
67
93
  | `--github-step-summary` | Optional path to append GitHub Step Summary Markdown. Defaults to `$GITHUB_STEP_SUMMARY`. |
68
94
 
@@ -82,6 +108,8 @@ CLI arguments take precedence over environment variables.
82
108
 
83
109
  ## Example Output
84
110
 
111
+ ![Screenshot of a larger CDK diff summary in GitHub Step Summary](docs/assets/cdk-diff-summary-larger-example.png)
112
+
85
113
  ```markdown
86
114
  ## CDK diff summary
87
115
 
@@ -119,21 +147,18 @@ python -m build
119
147
  twine check dist/*
120
148
  ```
121
149
 
122
- Run from source:
150
+ Run the action wrapper directly:
123
151
 
124
152
  ```bash
125
- cdk-diff-summary example_cdk_diff_json/cdk-diff-json-tiny.json
153
+ DIFF_JSON_PATH=example_cdk_diff_json/cdk-diff-json-tiny.json \
154
+ GITHUB_STEP_SUMMARY=/tmp/cdk-summary.md \
155
+ python scripts/cdk_diff_summary.py
126
156
  ```
127
157
 
128
- ## Publishing
129
-
130
- This package is ready for PyPI trusted publishing. Create a PyPI project named `cdk-diff-summary`, configure a trusted publisher for this repository and the `publish.yml` workflow, then create a GitHub release.
131
-
132
- For a manual dry run:
158
+ Run the installed CLI:
133
159
 
134
160
  ```bash
135
- python -m build
136
- twine check dist/*
161
+ cdk-diff-summary example_cdk_diff_json/cdk-diff-json-tiny.json
137
162
  ```
138
163
 
139
164
  CDK diff JSON shape can vary by CDK version. If parsing fails, please open an issue with a sanitized example of the JSON shape that failed.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cdk-diff-summary"
7
- version = "1.1.1"
7
+ version = "1.1.2"
8
8
  description = "Summarize AWS CDK diff JSON as compact Markdown."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -38,10 +38,10 @@ dev = [
38
38
  cdk-diff-summary = "cdk_diff_summary.cli:main"
39
39
 
40
40
  [project.urls]
41
- Homepage = "https://github.com/jalcock501/cdk-diff-summary-pypi"
42
- Repository = "https://github.com/jalcock501/cdk-diff-summary-pypi"
43
- Documentation = "https://github.com/jalcock501/cdk-diff-summary-pypi#readme"
44
- Issues = "https://github.com/jalcock501/cdk-diff-summary-pypi/issues"
41
+ Homepage = "https://github.com/jalcock501/cdk-diff-summary"
42
+ Repository = "https://github.com/jalcock501/cdk-diff-summary"
43
+ Documentation = "https://github.com/jalcock501/cdk-diff-summary#readme"
44
+ Issues = "https://github.com/jalcock501/cdk-diff-summary/issues"
45
45
 
46
46
  [tool.setuptools]
47
47
  package-dir = { "" = "src" }
@@ -1,3 +1,3 @@
1
1
  """Summarize AWS CDK diff JSON as compact Markdown."""
2
2
 
3
- __version__ = "1.1.1"
3
+ __version__ = "1.1.2"
@@ -77,13 +77,13 @@ def parse_args(argv: list[str] | None = None) -> CliConfig:
77
77
  )
78
78
  parser.add_argument(
79
79
  "--fail-on-remove",
80
- action="store_true",
80
+ action=argparse.BooleanOptionalAction,
81
81
  default=parse_bool(environ.get("FAIL_ON_REMOVE"), default=False),
82
82
  help="Exit non-zero after writing the summary if visible removes exist.",
83
83
  )
84
84
  parser.add_argument(
85
85
  "--fail-on-replace",
86
- action="store_true",
86
+ action=argparse.BooleanOptionalAction,
87
87
  default=parse_bool(environ.get("FAIL_ON_REPLACE"), default=False),
88
88
  help="Exit non-zero after writing the summary if visible replacements exist.",
89
89
  )
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cdk-diff-summary
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: Summarize AWS CDK diff JSON as compact Markdown.
5
5
  Author: cdk-diff-summary contributors
6
6
  License-Expression: MIT
7
- Project-URL: Homepage, https://github.com/jalcock501/cdk-diff-summary-pypi
8
- Project-URL: Repository, https://github.com/jalcock501/cdk-diff-summary-pypi
9
- Project-URL: Documentation, https://github.com/jalcock501/cdk-diff-summary-pypi#readme
10
- Project-URL: Issues, https://github.com/jalcock501/cdk-diff-summary-pypi/issues
7
+ Project-URL: Homepage, https://github.com/jalcock501/cdk-diff-summary
8
+ Project-URL: Repository, https://github.com/jalcock501/cdk-diff-summary
9
+ Project-URL: Documentation, https://github.com/jalcock501/cdk-diff-summary#readme
10
+ Project-URL: Issues, https://github.com/jalcock501/cdk-diff-summary/issues
11
11
  Keywords: aws,cdk,cloudformation,github-actions,diff
12
12
  Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Environment :: Console
@@ -33,24 +33,50 @@ Dynamic: license-file
33
33
 
34
34
  `cdk-diff-summary` reads AWS CDK diff JSON and renders a compact Markdown summary.
35
35
 
36
- It is useful locally, in CI systems, and in GitHub Actions workflows where raw CDK or CloudFormation diffs are too noisy. It groups adds, modifies, removes, replacements, security group rule changes, and other changes while reducing common churn from IAM policy documents and CDK asset hashes.
36
+ This repository is the source of truth for both:
37
+
38
+ - the GitHub Marketplace composite action `jalcock501/cdk-diff-summary`
39
+ - the PyPI package `cdk-diff-summary`
40
+
41
+ It is designed for pull requests and CI jobs where raw CDK or CloudFormation diffs are too noisy. The summary groups adds, modifies, removes, replacements, security group rule changes, and other changes while reducing common churn from IAM policy documents and CDK asset hashes.
37
42
 
38
43
  The tool deliberately shows changed field paths only, not before/after values, to avoid exposing sensitive infrastructure values in summaries.
39
44
 
40
- ## Install
45
+ ## GitHub Action Usage
41
46
 
42
- ```bash
43
- pipx install cdk-diff-summary
47
+ ```yaml
48
+ - name: Generate CDK diff JSON
49
+ run: npx cdk diff --json > cdk-diff.json
50
+
51
+ - name: Summarize CDK diff
52
+ uses: jalcock501/cdk-diff-summary@v1
53
+ with:
54
+ diff-json-path: cdk-diff.json
44
55
  ```
45
56
 
46
- or:
57
+ The composite action runs the local checked-out code from the action tag. It does not install `cdk-diff-summary` from PyPI at runtime.
58
+
59
+ ## Action Inputs
60
+
61
+ | Input | Required | Default | Description |
62
+ | --- | --- | --- | --- |
63
+ | `diff-json-path` | yes | | Path to JSON produced by `cdk diff --json`. |
64
+ | `summary-title` | no | `CDK diff summary` | Markdown heading for the summary. |
65
+ | `max-changed-fields` | no | `8` | Maximum changed field paths shown per resource. |
66
+ | `collapse-iam-policies` | no | `true` | Collapse large IAM policy document diffs to a single path such as `PolicyDocument`. |
67
+ | `collapse-assets` | no | `true` | Suppress or collapse common CDK asset/hash churn such as asset hashes, S3 object keys, Lambda code hashes, Docker image asset hashes, and CDK metadata asset paths. |
68
+ | `fail-on-remove` | no | `false` | Write the summary, then fail the step if visible removes exist. |
69
+ | `fail-on-replace` | no | `false` | Write the summary, then fail the step if visible replacements exist. |
70
+ | `summary-output-path` | no | | Optional file path to also append the generated Markdown summary. |
71
+
72
+ ## PyPI / CLI Usage
73
+
74
+ Install with `pipx`:
47
75
 
48
76
  ```bash
49
- python -m pip install cdk-diff-summary
77
+ pipx install cdk-diff-summary
50
78
  ```
51
79
 
52
- ## Usage
53
-
54
80
  Generate CDK diff JSON:
55
81
 
56
82
  ```bash
@@ -92,8 +118,8 @@ cdk-diff-summary cdk-diff.json --fail-on-remove --fail-on-replace
92
118
  | `--max-changed-fields` | Maximum changed field paths shown per resource. Defaults to `8`. |
93
119
  | `--collapse-iam-policies` / `--no-collapse-iam-policies` | Collapse large IAM policy document diffs to compact paths. Enabled by default. |
94
120
  | `--collapse-assets` / `--no-collapse-assets` | Collapse common CDK asset/hash churn. Enabled by default. |
95
- | `--fail-on-remove` | Write the summary, then exit non-zero if visible resource removes exist. |
96
- | `--fail-on-replace` | Write the summary, then exit non-zero if visible resource replacements exist. |
121
+ | `--fail-on-remove` / `--no-fail-on-remove` | Write the summary, then exit non-zero if visible resource removes exist. Disabled by default. |
122
+ | `--fail-on-replace` / `--no-fail-on-replace` | Write the summary, then exit non-zero if visible resource replacements exist. Disabled by default. |
97
123
  | `--output` | Optional path to append the generated Markdown summary. |
98
124
  | `--github-step-summary` | Optional path to append GitHub Step Summary Markdown. Defaults to `$GITHUB_STEP_SUMMARY`. |
99
125
 
@@ -113,6 +139,8 @@ CLI arguments take precedence over environment variables.
113
139
 
114
140
  ## Example Output
115
141
 
142
+ ![Screenshot of a larger CDK diff summary in GitHub Step Summary](docs/assets/cdk-diff-summary-larger-example.png)
143
+
116
144
  ```markdown
117
145
  ## CDK diff summary
118
146
 
@@ -150,21 +178,18 @@ python -m build
150
178
  twine check dist/*
151
179
  ```
152
180
 
153
- Run from source:
181
+ Run the action wrapper directly:
154
182
 
155
183
  ```bash
156
- cdk-diff-summary example_cdk_diff_json/cdk-diff-json-tiny.json
184
+ DIFF_JSON_PATH=example_cdk_diff_json/cdk-diff-json-tiny.json \
185
+ GITHUB_STEP_SUMMARY=/tmp/cdk-summary.md \
186
+ python scripts/cdk_diff_summary.py
157
187
  ```
158
188
 
159
- ## Publishing
160
-
161
- This package is ready for PyPI trusted publishing. Create a PyPI project named `cdk-diff-summary`, configure a trusted publisher for this repository and the `publish.yml` workflow, then create a GitHub release.
162
-
163
- For a manual dry run:
189
+ Run the installed CLI:
164
190
 
165
191
  ```bash
166
- python -m build
167
- twine check dist/*
192
+ cdk-diff-summary example_cdk_diff_json/cdk-diff-json-tiny.json
168
193
  ```
169
194
 
170
195
  CDK diff JSON shape can vary by CDK version. If parsing fails, please open an issue with a sanitized example of the JSON shape that failed.
@@ -3,27 +3,9 @@ from __future__ import annotations
3
3
  import json
4
4
  from pathlib import Path
5
5
 
6
- import pytest
7
-
8
6
  from cdk_diff_summary import cli
9
7
 
10
8
 
11
- @pytest.fixture(autouse=True)
12
- def clear_cdk_summary_environment(monkeypatch: pytest.MonkeyPatch) -> None:
13
- for name in (
14
- "DIFF_JSON_PATH",
15
- "SUMMARY_TITLE",
16
- "MAX_CHANGED_FIELDS",
17
- "COLLAPSE_IAM_POLICIES",
18
- "COLLAPSE_ASSETS",
19
- "FAIL_ON_REMOVE",
20
- "FAIL_ON_REPLACE",
21
- "SUMMARY_OUTPUT_PATH",
22
- "GITHUB_STEP_SUMMARY",
23
- ):
24
- monkeypatch.delenv(name, raising=False)
25
-
26
-
27
9
  def write_diff(path: Path, *, action: str = "modify", replacement: bool = False) -> None:
28
10
  path.write_text(
29
11
  json.dumps(
@@ -48,9 +30,11 @@ def write_diff(path: Path, *, action: str = "modify", replacement: bool = False)
48
30
  )
49
31
 
50
32
 
51
- def test_prints_to_stdout_when_no_output_paths(capsys, tmp_path: Path) -> None:
33
+ def test_prints_to_stdout_when_no_output_paths(monkeypatch, capsys, tmp_path: Path) -> None:
52
34
  diff_path = tmp_path / "diff.json"
53
35
  write_diff(diff_path)
36
+ monkeypatch.delenv("GITHUB_STEP_SUMMARY", raising=False)
37
+ monkeypatch.delenv("SUMMARY_OUTPUT_PATH", raising=False)
54
38
 
55
39
  assert cli.main([str(diff_path)]) == 0
56
40
 
@@ -79,6 +63,19 @@ def test_appends_to_github_step_summary(monkeypatch, tmp_path: Path) -> None:
79
63
  assert "## CDK diff summary" in summary_path.read_text(encoding="utf-8")
80
64
 
81
65
 
66
+ def test_optional_summary_output_path(monkeypatch, tmp_path: Path) -> None:
67
+ diff_path = tmp_path / "diff.json"
68
+ step_summary_path = tmp_path / "step.md"
69
+ output_path = tmp_path / "out.md"
70
+ write_diff(diff_path)
71
+ monkeypatch.setenv("DIFF_JSON_PATH", str(diff_path))
72
+ monkeypatch.setenv("GITHUB_STEP_SUMMARY", str(step_summary_path))
73
+ monkeypatch.setenv("SUMMARY_OUTPUT_PATH", str(output_path))
74
+
75
+ assert cli.main([]) == 0
76
+ assert output_path.read_text(encoding="utf-8") == step_summary_path.read_text(encoding="utf-8")
77
+
78
+
82
79
  def test_cli_arguments_override_environment(monkeypatch, tmp_path: Path) -> None:
83
80
  env_diff_path = tmp_path / "env-diff.json"
84
81
  cli_diff_path = tmp_path / "cli-diff.json"
@@ -103,6 +100,16 @@ def test_fail_on_remove_writes_summary_then_fails(tmp_path: Path) -> None:
103
100
  assert "### Removes" in output_path.read_text(encoding="utf-8")
104
101
 
105
102
 
103
+ def test_no_fail_on_remove_overrides_environment(monkeypatch, tmp_path: Path) -> None:
104
+ diff_path = tmp_path / "diff.json"
105
+ output_path = tmp_path / "summary.md"
106
+ write_diff(diff_path, action="delete")
107
+ monkeypatch.setenv("FAIL_ON_REMOVE", "true")
108
+
109
+ assert cli.main([str(diff_path), "--output", str(output_path), "--no-fail-on-remove"]) == 0
110
+ assert "### Removes" in output_path.read_text(encoding="utf-8")
111
+
112
+
106
113
  def test_fail_on_replace_writes_summary_then_fails(tmp_path: Path) -> None:
107
114
  diff_path = tmp_path / "diff.json"
108
115
  output_path = tmp_path / "summary.md"
@@ -112,6 +119,16 @@ def test_fail_on_replace_writes_summary_then_fails(tmp_path: Path) -> None:
112
119
  assert "### Replacements" in output_path.read_text(encoding="utf-8")
113
120
 
114
121
 
122
+ def test_no_fail_on_replace_overrides_environment(monkeypatch, tmp_path: Path) -> None:
123
+ diff_path = tmp_path / "diff.json"
124
+ output_path = tmp_path / "summary.md"
125
+ write_diff(diff_path, replacement=True)
126
+ monkeypatch.setenv("FAIL_ON_REPLACE", "true")
127
+
128
+ assert cli.main([str(diff_path), "--output", str(output_path), "--no-fail-on-replace"]) == 0
129
+ assert "### Replacements" in output_path.read_text(encoding="utf-8")
130
+
131
+
115
132
  def test_invalid_max_changed_fields(tmp_path: Path) -> None:
116
133
  diff_path = tmp_path / "diff.json"
117
134
  output_path = tmp_path / "summary.md"