Skip to content

ci: add shared gitHub shared workflows for PR checks, tag release#360

Closed
anket-cd wants to merge 7 commits intomasterfrom
ci/github-shared-workflows
Closed

ci: add shared gitHub shared workflows for PR checks, tag release#360
anket-cd wants to merge 7 commits intomasterfrom
ci/github-shared-workflows

Conversation

@anket-cd
Copy link
Copy Markdown
Contributor

@anket-cd anket-cd commented Apr 6, 2026

This PR introduces shared GitHub Actions workflows to standardize CI/CD processes across repositories.


Changes Included

  • Added PR check workflow
    • Runs validation on pull requests
    • Ensures code quality and prevents breaking changes
  • Added tag-based release workflow
    • Triggers on new version tags
    • Automates release process

@anket-cd anket-cd self-assigned this Apr 6, 2026
@anket-cd anket-cd requested review from a team, anmolnagpal and clouddrove-ci as code owners April 6, 2026 16:47
@anket-cd anket-cd added the patch for semantic version path label Apr 6, 2026
@anket-cd anket-cd requested review from dverma-cd and removed request for a team April 6, 2026 16:47
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the Plan function in internal/terraform/plan.go to simplify change detection by utilizing the boolean return value from tf.Plan instead of manually parsing output buffers. This change removes significant string manipulation and JSON filtering logic. Feedback was provided regarding a potential silent failure path when os.Stat fails on a plan file and a minor typo in a log message.

Comment on lines 125 to 140
if out != "" {
// We saved a plan file, examine it to determine if there are changes
plan, err := tf.ShowPlanFile(context.Background(), out)
if err == nil && plan != nil {
hasChanges = len(plan.ResourceChanges) > 0
} else {
// Fallback: check if the plan file has content
if fileInfo, err := os.Stat(out); err == nil && fileInfo.Size() > 0 {
// Plan file exists and has content, assume there are changes
hasChanges = true
}
}
} else {
// No plan file saved, we need to check the output
// The easiest way is to check if the output contains "Plan:"
outputStr := outputBuffer.String()
if strings.Contains(outputStr, "Plan:") && !strings.Contains(outputStr, "Plan: 0 to add") {
hasChanges = true
}
}

// Handle based on whether changes were detected
if hasChanges {
if out != "" {
Success("\nTerraform plan saved to: %s", out)
// Check if plan file was created and has content
if fileInfo, err := os.Stat(out); err == nil && fileInfo.Size() > 0 {
Success("Terraform plan saved to: %s", out)
Info("To apply this plan, run: smurf stf apply %s", out)
} else {
Success("\nTerraform plan executed successfully. Review the changes above before applying.")
}
} else {
Success("\nNo changes. Your infrastructure matches the configuration.")

if out != "" {
// If we saved a plan file but there are no changes, it's still saved but empty
Info("Note: Plan file was saved even though no changes detected: %s", out)
} else if !hasChanges {
Success("No changes; the infrastructure is up to date with the current configuration.")
// Clean up empty plan file
if fileInfo, err := os.Stat(out); err == nil && fileInfo.Size() == 0 {
os.Remove(out)
Info("Removed empty plan file: %s", out)
}
os.Remove(out)
Info(" Removed empty plan file: %s", out)
}
} else if !hasChanges {
Success("No changes; the infrastructure is up to date with the current configuration.")
} else {
Success("Terraform plan executed successfully. Review the changes above before applying.")
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The current logic for success messages contains a silent failure path: if out is set and hasChanges is true, but os.Stat(out) fails, no feedback is given to the user. Additionally, there is a typo (leading space) in the log message on line 134. Refactoring to handle the !hasChanges case first simplifies the logic and ensures all scenarios are covered correctly.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 8, 2026

@anket-cd anket-cd closed this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch for semantic version path

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant