Skip to content

Check skipenv #24

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

Merged
merged 7 commits into from
Apr 2, 2020
Merged

Check skipenv #24

merged 7 commits into from
Apr 2, 2020

Conversation

yorinasub17
Copy link
Contributor

Introduce a pre-commit hook that uses a regex based method of checking for uncommented os.Setenv calls for setting terratest skip environments.

@yorinasub17 yorinasub17 requested a review from brikis98 as a code owner April 1, 2020 19:16
unit_test:
machine:
enabled: true
image: "ubuntu-1604:201903-01"
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the machine executor here? Or would tests run faster in a Docker executor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, so that I can run against py2 and py3.

def has_setenv_skip(fpath):
with open(fpath) as f:
for line in f:
if re.match(r'^\s+os.Setenv\(\"SKIP_', line):
Copy link
Member

Choose a reason for hiding this comment

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

It's not likely, but perhaps possible someone calls os.Setenv right at the start of a line of code? Also, there may be extra whitespace.

Suggested change
if re.match(r'^\s+os.Setenv\(\"SKIP_', line):
if re.match(r'^\s*os.Setenv\s*\(\s*\"SKIP_', line):

Also, consider checking for os.Setenv("TERRATEST_REGION

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not likely, but perhaps possible someone calls os.Setenv right at the start of a line of code? Also, there may be extra whitespace.

This would be formatted away with go fmt, so I don't think it is necessary.

Also, consider checking for os.Setenv("TERRATEST_REGION

Added in! e20ca37

@yorinasub17
Copy link
Contributor Author

Ok going to merge and release. Thanks for review!

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.

2 participants