Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add check for outdated generated code on terramate run #163

Merged
merged 29 commits into from
Jan 14, 2022

Conversation

katcipis
Copy link
Contributor

@katcipis katcipis commented Jan 13, 2022

Changed the design to make it easier to check only a specific set of stacks, was thinking way too much on terms of "check all the project", but that doesn't work well with cwd etc. Certainly space for future improvements, but should work. Here is an example script:

#!/bin/bash

set -o nounset

basedir=$(mktemp -d)

cd "${basedir}"

cat > terramate.tm.hcl <<- EOM
terramate {
  config {
  }
}
EOM

mkdir -p stacks/stack-1
terramate stacks init stacks/stack-1

mkdir -p stacks/stack-2
terramate stacks init stacks/stack-2


echo "terramate run: should work:"
echo

terramate run cat terramate.tm.hcl

echo

cat > stacks/stack-1/terramate.tm.hcl <<- EOM
stack {}

export_as_locals {
  path = terramate.path
}
EOM

echo
echo "terramate run: should fail for all stacks:"
echo

terramate run cat terramate.tm.hcl

echo
echo "terramate run: should fail for stack-1:"
echo

terramate run -C stacks/stack-1 cat terramate.tm.hcl

echo
echo "terramate run: should work for stack-2:"
echo

terramate run -C stacks/stack-2 cat terramate.tm.hcl

cat > stacks/stack-2/terramate.tm.hcl <<- EOM
stack {}

terramate {
  backend "test" {}
}

export_as_locals {
  path = terramate.path
}
EOM

echo
echo "terramate run: should fail for all stacks:"
echo

terramate run cat terramate.tm.hcl

echo
echo "terramate generate: updating code"

terramate generate

echo "terramate generate: code updated"
echo "terramate run: should work for all stacks:"
echo

terramate run cat terramate.tm.hcl

@codecov-commenter
Copy link

Codecov Report

Merging #163 (ba08bbb) into main (bbd81ea) will increase coverage by 0.15%.
The diff coverage is 56.31%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #163      +/-   ##
==========================================
+ Coverage   61.41%   61.57%   +0.15%     
==========================================
  Files          29       29              
  Lines        4694     4734      +40     
==========================================
+ Hits         2883     2915      +32     
  Misses       1656     1656              
- Partials      155      163       +8     
Flag Coverage Δ
tests 61.57% <56.31%> (+0.15%) ⬆️

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

Impacted Files Coverage Δ
cmd/terramate/cli/cli.go 0.00% <0.00%> (ø)
generate/generate.go 91.47% <74.46%> (-1.53%) ⬇️
metadata.go 94.11% <88.46%> (-5.89%) ⬇️
git/git.go 74.95% <0.00%> (+0.33%) ⬆️
stack/loader.go 60.37% <0.00%> (+9.43%) ⬆️
stack/stack.go 80.00% <0.00%> (+12.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bbd81ea...ba08bbb. Read the comment docs.

@katcipis katcipis marked this pull request as ready for review January 13, 2022 14:07
@katcipis katcipis requested a review from i4ki January 13, 2022 14:07
@katcipis katcipis self-assigned this Jan 13, 2022
@katcipis katcipis marked this pull request as draft January 13, 2022 14:08
@katcipis katcipis marked this pull request as ready for review January 13, 2022 14:11
@katcipis katcipis requested a review from thiesen January 13, 2022 16:12
Copy link
Contributor

@mariux mariux left a comment

Choose a reason for hiding this comment

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

❤️

i4ki
i4ki previously approved these changes Jan 14, 2022
cmd/terramate/cli/cli_runner_test.go Outdated Show resolved Hide resolved
@katcipis katcipis merged commit 4dc3a3b into main Jan 14, 2022
@katcipis katcipis deleted the katcipis-generate-check-on-run branch January 14, 2022 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants