Skip to content

feat: Add --format=github for terraform output and unified pkg/env package#1985

Merged
aknysh merged 27 commits intomainfrom
osterman/fix-running-format
Jan 21, 2026
Merged

feat: Add --format=github for terraform output and unified pkg/env package#1985
aknysh merged 27 commits intomainfrom
osterman/fix-running-format

Conversation

@osterman
Copy link
Copy Markdown
Member

@osterman osterman commented Jan 16, 2026

what

  • Created unified pkg/env/ package for environment variable formatting (env, dotenv, bash, github formats)
  • Created pkg/github/actions/env/ package with GitHub Actions environment file helpers
  • Added --format=github support for atmos terraform output that writes to $GITHUB_OUTPUT
  • Eliminated code duplication between cmd/env and pkg/terraform/output by refactoring to use pkg/env
  • All output formats now consistently sort keys alphabetically for deterministic output

why

  • Reduces code maintenance burden by consolidating format logic into a single package
  • Enables GitHub Actions workflows to directly consume terraform outputs
  • Supports multiline values via heredoc syntax for GitHub Actions compatibility
  • Provides flexible options pattern for key transformation (uppercase, flatten with separator)

references

Part of environment variable formatting consolidation effort.

Summary by CodeRabbit

  • New Features

    • Added --format=github to export Terraform outputs to GitHub Actions ($GITHUB_OUTPUT or custom file)
    • Unified environment-variable formatting across formats (env, dotenv, bash, github) with options for uppercase keys, flattening, and export-prefix control
  • Documentation

    • Added docs and examples for GitHub Actions integration and sharing outputs between workflow steps

✏️ Tip: You can customize this high-level summary in your review settings.

osterman and others added 2 commits January 16, 2026 17:26
…ckage

This commit adds GitHub Actions integration for terraform outputs and creates
a unified environment variable formatting package to eliminate code duplication.

Key changes:

1. New `pkg/env/` package for environment variable formatting:
   - Supports env, dotenv, bash, and github formats
   - Options pattern: WithUppercase(), WithFlatten()
   - Sorted keys for deterministic output
   - Shell escaping for single-quoted literals
   - GitHub heredoc syntax for multiline values

2. New `pkg/github/actions/env/` package:
   - GetOutputPath(), GetEnvPath(), GetPathPath(), GetSummaryPath()
   - IsGitHubActions() detection

3. `atmos terraform output --format=github`:
   - Writes outputs to $GITHUB_OUTPUT or --output-file
   - Supports --uppercase and --flatten options
   - Uses heredoc syntax for multiline values

4. Refactored cmd/env and pkg/terraform/output to use pkg/env:
   - Eliminated duplicate formatting code
   - Consistent behavior across all format commands

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…v directly

Eliminates unnecessary indirection by having consumers import directly from
pkg/github/actions/env instead of going through a thin wrapper in pkg/env.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@osterman osterman requested a review from a team as a code owner January 16, 2026 23:36
@github-actions github-actions bot added the size/xl Extra large size PR label Jan 16, 2026
@mergify
Copy link
Copy Markdown

mergify bot commented Jan 16, 2026

Warning

This PR exceeds the recommended limit of 1,000 lines.

Large PRs are difficult to review and may be rejected due to their size.

Please verify that this PR does not address multiple issues.
Consider refactoring it into smaller, more focused PRs to facilitate a smoother review process.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 16, 2026

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

Move GitHub Actions utilities from pkg/github/actions/env/ to pkg/github/actions/.
The nested env/ subpackage was confusing since it's unrelated to pkg/env/.

Changes:
- Create pkg/github/actions/actions.go with path helpers
- Create pkg/github/actions/format.go with GitHub formatting (heredoc)
- Create pkg/github/actions/actions_test.go with comprehensive tests
- Update pkg/env/formatters.go to delegate to ghactions.FormatValue()
- Update cmd imports to use ghactions alias
- Delete pkg/github/actions/env/ directory

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@osterman osterman added the minor New features that do not break anything label Jan 16, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

Adds a dedicated --format=github for terraform output, new env formatting package and GitHub Actions helpers, threads an authManager through Terraform output call chain, and implements file-writing helpers and tests to support writing outputs to $GITHUB_OUTPUT or a custom file.

Changes

Cohort / File(s) Summary
Environment Variable Formatting Infrastructure
pkg/env/format.go, pkg/env/format_test.go
New Format type (env,dotenv,bash,github) with ParseFormat, FormatData, FormatValue; flattening, uppercase option, deterministic key ordering, JSON encoding for complex values, and extensive tests.
Environment Formatting Helpers
pkg/env/formatters.go, pkg/env/options.go, pkg/env/value.go, pkg/env/file.go
Internal formatters for env/dotenv/bash/github, Option pattern (WithUppercase, WithFlatten, WithExport), ValueToString, and public WriteToFile for appending/creating files.
GitHub Actions Integration
pkg/github/actions/actions.go, pkg/github/actions/format.go, pkg/github/actions/actions_test.go
New package with CI detection and getters (GetOutputPath, GetEnvPath, GetPathPath, GetSummaryPath) and GitHub-specific formatting (HEREDOC for multiline via FormatValue, batch FormatData) plus tests.
Terraform Output Formatting Updates
pkg/terraform/output/format.go, pkg/terraform/output/format_test.go, pkg/terraform/output/output.go, pkg/terraform/output/output_test.go
Added FormatGitHub, refactored env/dotenv/bash to use envfmt, added deterministic recursive sorting for JSON/YAML, and tests for GitHub formatting and ordering.
Terraform Output Execution Chain
pkg/terraform/output/executor.go, pkg/terraform/output/get.go, internal/exec/terraform_output_getter.go
Threaded new authManager parameter through Executor.GetAllOutputs, fetchAndCacheOutputs, GetComponentOutputs, and GetComponentOutputsWithExecutor (call sites updated to pass nil where appropriate).
Command Implementation
cmd/terraform/output.go, cmd/terraform/output_test.go
New executeGitHubOutput path that resolves $GITHUB_OUTPUT or --output, formats via envfmt/ghactions, writes to file, and emits UI messages; tests for file I/O, single vs multiple outputs, uppercase and heredoc behaviors.
CLI env Command Refactor
cmd/env/env.go, cmd/env/env_test.go
Replaced per-format formatters with envfmt.FormatData/WriteToFile flow, added --export flag handling and convertToAnyMap adapter; tests updated accordingly.
Spinner / UI routing
pkg/terraform/output/spinner.go
Routing UI output via iolib.UI for spinner and non-TTY fallback adjustments.
Module & License
go.mod, LICENSE.md
Added direct require for al.essio.dev/pkg/shellescape v1.5.1 and added MIT licensed-dependency entry.
Docs & Roadmap
website/blog/2026-01-16-github-output-format.mdx, website/docs/cli/commands/terraform/terraform-output.mdx, website/src/data/roadmap.js
New blog and doc entries describing --format=github behavior and examples; roadmap updated to mark feature shipped.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI as terraform output cmd
    participant TF as Terraform / FormatModule
    participant EnvFmt as pkg/env
    participant GHActions as pkg/github/actions
    participant FS as File System

    User->>CLI: run --format=github
    CLI->>TF: GetComponentOutputs(...)
    TF->>TF: collect outputs
    CLI->>GHActions: GetOutputPath()
    GHActions-->>CLI: path or ""
    CLI->>EnvFmt: FormatData(outputs, FormatGitHub, opts...)
    EnvFmt-->>CLI: formatted string (HEREDOCs, JSON for complex)
    CLI->>GHActions: FormatValue(key,value) (ensure HEREDOC delimiter)
    CLI->>FS: WriteToFile(path, content)
    FS-->>CLI: write result
    CLI-->>User: success / error
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested reviewers

  • osterman
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.87% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding GitHub Actions format support to terraform output and introducing a unified environment formatting package.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch osterman/fix-running-format

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 16, 2026

Caution

Review failed

The head commit changed during the review from f01907f to 3097823.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch osterman/fix-running-format

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 16, 2026

Codecov Report

❌ Patch coverage is 83.72093% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.17%. Comparing base (6afea27) to head (3de8676).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/env/env.go 15.90% 37 Missing ⚠️
cmd/terraform/output.go 71.87% 8 Missing and 1 partial ⚠️
pkg/env/file.go 77.77% 1 Missing and 1 partial ⚠️
pkg/terraform/output/get.go 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1985      +/-   ##
==========================================
+ Coverage   75.10%   75.17%   +0.07%     
==========================================
  Files         777      784       +7     
  Lines       71636    71802     +166     
==========================================
+ Hits        53803    53978     +175     
+ Misses      14347    14346       -1     
+ Partials     3486     3478       -8     
Flag Coverage Δ
unittests 75.17% <83.72%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/exec/terraform_output_getter.go 100.00% <100.00%> (+25.00%) ⬆️
pkg/env/format.go 100.00% <100.00%> (ø)
pkg/env/formatters.go 100.00% <100.00%> (ø)
pkg/env/options.go 100.00% <100.00%> (ø)
pkg/env/value.go 100.00% <100.00%> (ø)
pkg/github/actions/actions.go 100.00% <100.00%> (ø)
pkg/github/actions/format.go 100.00% <100.00%> (ø)
pkg/terraform/output/executor.go 85.38% <100.00%> (+0.05%) ⬆️
pkg/terraform/output/format.go 86.66% <100.00%> (+3.50%) ⬆️
pkg/terraform/output/output.go 100.00% <ø> (ø)
... and 5 more

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Add flexible export control for bash format output:
- `atmos env --format=bash` outputs `export KEY='value'` (default)
- `atmos env --format=bash --export=false` outputs `KEY='value'`

Changes:
- Add WithExport(bool) option to pkg/env for controlling export prefix
- Add ParseFormat() function for cleaner format string conversion
- Simplify cmd/env/env.go by removing duplicate switch statements
- Add comprehensive tests for new functionality

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace custom EscapeSingleQuotes with battle-tested shellescape library:
- shellescape.Quote handles all edge cases properly
- Only quotes values when needed (simple values stay unquoted)
- Uses `'"'"'` pattern for single quote escaping
- Remove unused EscapeSingleQuotes function

Output format changes:
- Simple values: `export FOO=bar` (was: `export FOO='bar'`)
- Quoted values: `export MSG='it'"'"'s'` (was: `export MSG='it'\''s'`)

Both formats are valid shell syntax.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
pkg/terraform/output/executor.go (1)

178-205: Validate authManager type in GetAllOutputs for consistency.
GetOutput checks authManager and returns a typed error; GetAllOutputs should do the same to fail fast with a clear message.

🐛 Suggested fix
 func (e *Executor) GetAllOutputs(
 	atmosConfig *schema.AtmosConfiguration,
 	component string,
 	stack string,
 	skipInit bool,
 	authManager any,
 ) (map[string]any, error) {
 	defer perf.Track(atmosConfig, "output.Executor.GetAllOutputs")()
 
+	if authManager != nil {
+		if _, ok := authManager.(auth.AuthManager); !ok {
+			return nil, fmt.Errorf("%w: expected auth.AuthManager", errUtils.ErrInvalidAuthManagerType)
+		}
+	}
+
 	stackSlug := fmt.Sprintf("%s-%s", stack, component)
pkg/terraform/output/format_test.go (3)

78-91: Test assertions mismatch implementation - CI is failing.

Pipeline failures indicate the dotenv format implementation no longer wraps simple values in single quotes. The test expects url='https://example.com' but the actual output is url=https://example.com.

Either the tests need updating to match the new implementation, or the implementation has a bug. Please reconcile.

🔧 If implementation changed intentionally, update tests:
 func TestFormatOutputs_Dotenv(t *testing.T) {
 	// ...
-	assert.Contains(t, result, "url='https://example.com'\n")
-	assert.Contains(t, result, "port='8080'\n")
-	assert.Contains(t, result, "enabled='true'\n")
+	assert.Contains(t, result, "url=https://example.com\n")
+	assert.Contains(t, result, "port=8080\n")
+	assert.Contains(t, result, "enabled=true\n")
 }

93-106: Bash format test failures - same quoting mismatch.

Same issue: tests expect export url='https://example.com' but implementation produces export url=https://example.com.

🔧 Update if quoting behavior changed:
 func TestFormatOutputs_Bash(t *testing.T) {
 	// ...
-	assert.Contains(t, result, "export url='https://example.com'\n")
-	assert.Contains(t, result, "export port='8080'\n")
-	assert.Contains(t, result, "export enabled='true'\n")
+	assert.Contains(t, result, "export url=https://example.com\n")
+	assert.Contains(t, result, "export port=8080\n")
+	assert.Contains(t, result, "export enabled=true\n")
 }

362-392: Table-driven scalar tests need updates for dotenv/bash.

Lines 379-380 expect quoted values for dotenv and bash formats but CI shows unquoted output. Update these test cases to match implementation.

🔧 Proposed fix:
-		{"dotenv string", "url", "https://example.com", FormatDotenv, "url='https://example.com'\n"},
-		{"bash string", "url", "https://example.com", FormatBash, "export url='https://example.com'\n"},
+		{"dotenv string", "url", "https://example.com", FormatDotenv, "url=https://example.com\n"},
+		{"bash string", "url", "https://example.com", FormatBash, "export url=https://example.com\n"},
🤖 Fix all issues with AI agents
In `@NOTICE`:
- Around line 951-954: Regenerate the NOTICE file because it is out of date
after adding the alessio/shellescape dependency; run the project’s notice
generator script (./scripts/generate-notice.sh) locally, review the updated
NOTICE output to ensure the new MIT entry for al.essio.dev/pkg/shellescape is
present, then commit the updated NOTICE file to the branch so the pipeline will
pass.

In `@pkg/github/actions/format.go`:
- Around line 14-21: The heredoc delimiter generation in FormatValue can collide
with the value content causing premature termination; update FormatValue to
ensure the delimiter is unique by checking that the chosen delimiter (currently
built as fmt.Sprintf("ATMOS_EOF_%s", key) stored in variable delimiter) does not
occur in value and, if it does, iterate (e.g., append a counter or random/UUID
suffix) until delimiter is absent from value, then emit the heredoc using that
unique delimiter; ensure the uniqueness check and iteration happen only when
strings.Contains(value, "\n") is true so single-line behavior is unchanged.

In `@website/blog/2026-01-16-github-output-format.mdx`:
- Around line 1-6: Replace the placeholder authors value in the frontmatter
("authors: [atmos]") with the actual contributor key from
website/blog/authors.yml (for example "osterman" or "aknysh") so the authors
field references the real content author; locate the frontmatter in the
github-output-format post and update the authors array to the correct author key
(e.g., authors: [osterman]) before merging.
🧹 Nitpick comments (8)
pkg/env/file.go (1)

17-31: Implementation is solid, but there's duplication.

The function follows Go idioms with proper error wrapping and perf tracking. However, pkg/terraform/output/output.go has a nearly identical WriteToFile function (lines 104-116). Consider consolidating to avoid maintaining two copies.

pkg/env/value.go (1)

46-59: Minor edge case to consider.

The comparison v == float32(int64(v)) works well for typical values, but floats larger than int64 max (~9.2e18) would overflow. This is unlikely in practice for environment variable values, so it's acceptable.

pkg/github/actions/actions_test.go (2)

11-73: Prefer t.Setenv without os.Unsetenv in tests.
os.Getenv treats unset and empty the same, so t.Setenv("", "") is enough and keeps env management scoped to the test.

♻️ Suggested cleanup
 	t.Run("returns false when not in CI", func(t *testing.T) {
 		// Unset by setting to empty value via t.Setenv.
 		t.Setenv("GITHUB_ACTIONS", "")
-		os.Unsetenv("GITHUB_ACTIONS")
 		assert.False(t, IsGitHubActions())
 	})
@@
 	t.Run("returns empty when not set", func(t *testing.T) {
 		t.Setenv("GITHUB_OUTPUT", "")
-		os.Unsetenv("GITHUB_OUTPUT")
 		assert.Empty(t, GetOutputPath())
 	})
@@
 	t.Run("returns empty when not set", func(t *testing.T) {
 		t.Setenv("GITHUB_ENV", "")
-		os.Unsetenv("GITHUB_ENV")
 		assert.Empty(t, GetEnvPath())
 	})
@@
 	t.Run("returns empty when not set", func(t *testing.T) {
 		t.Setenv("GITHUB_PATH", "")
-		os.Unsetenv("GITHUB_PATH")
 		assert.Empty(t, GetPathPath())
 	})
@@
 	t.Run("returns empty when not set", func(t *testing.T) {
 		t.Setenv("GITHUB_STEP_SUMMARY", "")
-		os.Unsetenv("GITHUB_STEP_SUMMARY")
 		assert.Empty(t, GetSummaryPath())
 	})
Based on learnings, prefer `t.Setenv` for test-scoped env changes.

29-135: Consider table-driven tests for the repeated getter/format cases.
It would reduce duplication across similar t.Run blocks and make it easier to extend scenarios.

Based on learnings, prefer table-driven tests for multi-scenario coverage.

pkg/terraform/output/format_test.go (1)

953-966: Minor: unused assignment in helper function.

Line 958 assigns idx but it's never used before being overwritten in the loop. Line 964 uses _ = idx to suppress warnings, but the assignment itself is unnecessary.

✨ Cleaner helper:
 func findSubstringIndex(s, substr string, startIdx int) int {
 	if startIdx >= len(s) {
 		return -1
 	}
-	idx := len(s[:startIdx]) + len(substr)
 	for i := startIdx; i <= len(s)-len(substr); i++ {
 		if s[i:i+len(substr)] == substr {
 			return i
 		}
 	}
-	_ = idx // Avoid unused variable warning.
 	return -1
 }
pkg/env/options.go (1)

17-23: Consider: perf.Track in option constructors.

These option constructors are typically trivial and called once per formatting operation. The perf.Track calls add overhead for what are essentially simple function returns. This is fine if tracing granularity is desired, but could be omitted per the guideline exceptions for "trivial getters/setters" and "simple factories."

cmd/env/env_test.go (1)

269-307: TestOutputEnvAsJSON verifies JSON output path.

The test initializes I/O context and verifies the JSON output path doesn't error. Consider adding assertions on actual output content for stronger coverage.

pkg/terraform/output/get_test.go (1)

112-136: LGTM!

Test updated correctly for the new signature. The mock setup and assertions look good.

One thought: since authManager is now part of the API, you might want to add a test case that verifies behavior when a non-nil authManager is passed, especially if it affects the output retrieval flow.

osterman and others added 2 commits January 17, 2026 10:30
Update test expectations to match shellescape.Quote behavior:
- Simple values like "vpc-123", "localhost" are not quoted
- Only values requiring escaping get quotes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Regenerate NOTICE file with updated dependencies
- Fix heredoc delimiter collision in FormatValue by adding suffix iteration
- Add tests for delimiter collision avoidance
- Update blog post author from 'atmos' to 'osterman'

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 20, 2026
- Update label to be more descriptive and action-oriented
- Fuse description and benefits for clearer messaging
- Emphasize multiline value support without jq/manual heredocs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@website/src/data/roadmap.js`:
- Around line 321-326: The shipped milestone object for "Easily share Terraform
outputs between GitHub Actions steps" is missing the PR number; update that
milestone (the object with label 'Easily share Terraform outputs between GitHub
Actions steps', status 'shipped') to include a pr property with the value 1985
(e.g., add pr: 1985 alongside docs/changelog/version fields) so the shipped
entry is traceable and consistent with roadmap policy.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 21, 2026
@mergify
Copy link
Copy Markdown

mergify bot commented Jan 21, 2026

💥 This pull request now has conflicts. Could you fix it @osterman? 🙏

@mergify mergify bot added the conflict This PR has conflicts label Jan 21, 2026
Merge main branch to incorporate recent changes including:
- GitHub Actions PATH integration (PR #1979)
- Locals YAML functions support
- Toolchain improvements
- Various bug fixes and enhancements

Resolved conflicts in:
- website/plugins/fetch-latest-release/index.js
- website/src/data/roadmap.js

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@cmd/env/env.go`:
- Around line 103-107: Replace raw returns of errors from envfmt.FormatData and
envfmt.WriteToFile with the project's standard/static error builder so errors
are wrapped with context; e.g., when calling envfmt.FormatData(dataMap,
envfmt.FormatGitHub) wrap the error as a static-wrapped error (include context
like "formatting env data") instead of returning err directly, and do the same
for the envfmt.WriteToFile(path, formatted) call (include context like "writing
env file"); apply the same wrapping change for the similar block around lines
111-120.

In `@cmd/terraform/output_test.go`:
- Around line 348-394: Replace OS-specific string concatenation when building
test file paths by using filepath.Join: change all occurrences that create
outputFile as tmpDir + "/github_output" to filepath.Join(tmpDir,
"github_output") in the subtests that call executeGitHubOutput (the tests that
create tmpDir and call executeGitHubOutput with tfoutput.FormatOptions), add
"path/filepath" to the test imports, and modify the "write to file error"
subtest to use a temp-dir-based non-writable path (e.g., join t.TempDir() with a
filename in a non-creatable nested directory) instead of the absolute
"/nonexistent/dir/file.txt" so the test is cross-platform and still triggers the
expected open/write error.
🧹 Nitpick comments (1)
cmd/terraform/output_test.go (1)

348-383: Strengthen GitHub output tests by asserting file contents.

These subtests only assert “no error,” so a no-op write would still pass. Consider reading the output file and checking for expected keys/values (or heredoc markers) in at least one subtest to validate real output.
As per coding guidelines, tests should be comprehensive.

@aknysh aknysh merged commit 7c24836 into main Jan 21, 2026
58 checks passed
@aknysh aknysh deleted the osterman/fix-running-format branch January 21, 2026 14:50
@github-actions
Copy link
Copy Markdown

These changes were released in v1.204.1-rc.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor New features that do not break anything size/xl Extra large size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants