Skip to content

Commit 4e66479

Browse files
committed
Correctly collapse long outputs
Adds tests for very long outputs
1 parent 98582c7 commit 4e66479

File tree

5 files changed

+50
-5
lines changed

5 files changed

+50
-5
lines changed

.github/workflows/test-apply.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,3 +1173,22 @@ jobs:
11731173
uses: ./terraform-apply
11741174
with:
11751175
path: tests/workflows/test-apply/long_outputs
1176+
1177+
outputs:
1178+
runs-on: ubuntu-latest
1179+
name: Apply a plan with outputs
1180+
env:
1181+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1182+
steps:
1183+
- name: Checkout
1184+
uses: actions/checkout@v3
1185+
1186+
- name: Plan
1187+
uses: ./terraform-plan
1188+
with:
1189+
path: tests/workflows/test-apply/outputs
1190+
1191+
- name: Apply
1192+
uses: ./terraform-apply
1193+
with:
1194+
path: tests/workflows/test-apply/outputs

image/src/github_pr_comment/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,13 +411,13 @@ def format_plan_text(plan_text: str) -> Tuple[str, str]:
411411

412412
def format_output_status(outputs: Optional[dict], remaining_size: int) -> str:
413413
status = f':white_check_mark: Plan applied in {job_markdown_ref()}'
414-
if outputs is not None:
415-
stripped_output = render_outputs(outputs).strip()
414+
stripped_output = render_outputs(outputs).strip()
416415

416+
if stripped_output:
417417
if len(stripped_output) > remaining_size:
418418
stripped_output = truncate(stripped_output, remaining_size, 'Outputs are too large to fit in a PR comment. See the full outputs in the workflow log.')
419419

420-
open_att = ' open' if len(stripped_output.splitlines()) > 6 else ''
420+
open_att = ' open' if len(stripped_output.splitlines()) < 6 else ''
421421

422422
status += f'''\n<details{open_att}><summary>Outputs</summary>
423423
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
variable "input" {
22
type = string
3-
default = "This is my long string\n"
3+
default = "This is my long string"
44
}
55

66
output "output" {
7-
value = repeat(var.input, 5000)
7+
value = join('\n', [for i in range(0, 5000): var.input])
88
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
output "sensitive" {
2+
value = "This is a sensistive value"
3+
sensitive = true
4+
}
5+
6+
output "not_sensitive" {
7+
value = "This is not a sensistive value"
8+
}
9+
10+
output "sensitive_map" {
11+
value = {
12+
"password" = "passw0rd"
13+
}
14+
sensitive = true
15+
}
16+
17+
output "not_sensitive_complex" {
18+
value = [
19+
{
20+
"hello" = "world"
21+
},
22+
{
23+
"hello" = "again"
24+
}
25+
]
26+
}

0 commit comments

Comments
 (0)