-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add script to add PR & Issue templates to all IaC repos #58
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9a3a52b
add script to add pr and issue templates to all iac repos
robmorgan d24f661
remove data dir.
robmorgan 3c32bbd
address NITs in script
robmorgan dc999e9
update url for coding methology
robmorgan 248e7eb
fix pr template indentation
robmorgan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script will ensure a repo has the necessary pull request and issue templates as | ||
# part of our contributing guide: https://doc.gruntwork.io/guides/contributing/ | ||
# | ||
# It creates or replaces the following files: | ||
# .github/ISSUE_TEMPLATE/bug_report.md | ||
# .github/ISSUE_TEMPLATE/feature_request.md | ||
# .github/pull_request_template.md | ||
|
||
function create_bug_issue_template { | ||
cat << "EOF" > .github/ISSUE_TEMPLATE/bug_report.md | ||
--- | ||
name: Bug report | ||
about: Create a bug report to help us improve. | ||
title: '' | ||
labels: bug | ||
assignees: '' | ||
|
||
--- | ||
|
||
<!-- | ||
Have any questions? Check out the contributing docs at https://gruntwork.notion.site/Gruntwork-Coding-Methodology-02fdcd6e4b004e818553684760bf691e, or | ||
ask in this issue and a Gruntwork core maintainer will be happy to help :) | ||
--> | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior including the relevant Terraform/Terragrunt/Packer version number and any code snippets and module inputs you used. | ||
|
||
```hcl | ||
// paste code snippets here | ||
``` | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Nice to have** | ||
- [ ] Terminal output | ||
- [ ] Screenshots | ||
|
||
**Additional context** | ||
Add any other context about the problem here. | ||
EOF | ||
} | ||
|
||
function create_feature_issue_template { | ||
cat << "EOF" > .github/ISSUE_TEMPLATE/feature_request.md | ||
--- | ||
name: Feature request | ||
about: Submit a feature request for this repo. | ||
title: '' | ||
labels: enhancement | ||
assignees: '' | ||
|
||
--- | ||
|
||
<!-- | ||
Have any questions? Check out the contributing docs at https://gruntwork.notion.site/Gruntwork-Coding-Methodology-02fdcd6e4b004e818553684760bf691e, or | ||
ask in this issue and a Gruntwork core maintainer will be happy to help :) | ||
--> | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. | ||
EOF | ||
} | ||
|
||
function create_pr_template { | ||
cat << "EOF" > .github/pull_request_template.md | ||
<!-- | ||
Have any questions? Check out the contributing docs at https://gruntwork.notion.site/Gruntwork-Coding-Methodology-02fdcd6e4b004e818553684760bf691e, or | ||
ask in this Pull Request and a Gruntwork core maintainer will be happy to help :) | ||
Note: Remember to add '[WIP]' to the beginning of the title if this PR is still a work-in-progress. | ||
--> | ||
|
||
## Description | ||
|
||
<!-- Write a brief description of the changes introduced by this PR --> | ||
|
||
### Documentation | ||
|
||
<!-- | ||
If this is a feature PR, then where is it documented? | ||
|
||
- If docs exist: | ||
- Update any references, if relevant. | ||
- If no docs exist: | ||
- Create a stub for documentation including bullet points for how to use the feature, code snippets (including from happy path tests), etc. | ||
--> | ||
|
||
<!-- Important: Did you make any backwards incompatible changes? If yes, then you must write a migration guide! --> | ||
|
||
## TODOs | ||
|
||
- [ ] Ensure the branch is named correctly with the issue number. e.g: `feature/new-vpc-endpoints-955` or `bug/missing-count-param-434`. | ||
- [ ] Update the docs. | ||
- [ ] Keep the changes backwards compatible where possible. | ||
- [ ] Run the pre-commit checks successfully. | ||
- [ ] Run the relevant tests successfully. | ||
- [ ] Ensure any 3rd party code adheres with our license policy: https://www.notion.so/gruntwork/Gruntwork-licenses-and-open-source-usage-policy-f7dece1f780341c7b69c1763f22b1378 | ||
- [ ] _Maintainers Only._ If necessary, release a new version of this repo. | ||
- [ ] _Maintainers Only._ If there were backwards incompatible changes, include a migration guide in the release notes. | ||
- [ ] _Maintainers Only._ Add to the next version of the monthly newsletter (see https://www.notion.so/gruntwork/Monthly-Newsletter-9198cbe7f8914d4abce23dca7b435f43). | ||
|
||
|
||
## Related Issues | ||
|
||
<!-- | ||
Link to the issue that is fixed by this PR (if there is one) | ||
e.g. Fixes #1234 | ||
|
||
Link to an issue that is partially addressed by this PR (if there are any) | ||
e.g. Addresses #1234 | ||
|
||
Link to related issues (if there are any) | ||
e.g. Related to #1234 | ||
--> | ||
EOF | ||
} | ||
|
||
# Ensure the GitHub template directories exist | ||
mkdir -p .github | ||
mkdir -p .github/ISSUE_TEMPLATE | ||
|
||
# if the repo does not contain a bug_report.md file, then create one or replace the existing one | ||
if [[ ! -f ".github/ISSUE_TEMPLATE/bug_report.md" ]]; then | ||
echo "Could not find file at .github/ISSUE_TEMPLATE/bug_report.md, so adding one..." | ||
create_bug_issue_template | ||
else | ||
echo "Found file at .github/ISSUE_TEMPLATE/bug_report.md, so replacing it..." | ||
rm .github/ISSUE_TEMPLATE/bug_report.md | ||
create_bug_issue_template | ||
fi | ||
|
||
# if the repo does not contain a feature_request.md file, then create one or replace the existing one | ||
if [[ ! -f ".github/ISSUE_TEMPLATE/feature_request.md" ]]; then | ||
echo "Could not find file at .github/ISSUE_TEMPLATE/feature_request.md, so adding one..." | ||
create_feature_issue_template | ||
else | ||
echo "Found file at .github/ISSUE_TEMPLATE/feature_request.md, so replacing it..." | ||
rm .github/ISSUE_TEMPLATE/feature_request.md | ||
create_feature_issue_template | ||
fi | ||
|
||
# if the repo does not contain a pull_request_template.md file, then create one or replace the existing one | ||
if [[ ! -f ".github/pull_request_template.md" ]]; then | ||
echo "Could not find file at .github/pull_request_template.md, so adding one..." | ||
create_pr_template | ||
else | ||
echo "Found file at .github/pull_request_template.md, so replacing it..." | ||
rm .github/pull_request_template.md | ||
create_pr_template | ||
fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: should these be
.md
files checked into thisgit-xargs
repo? You could then usecp
to copy them to the proper destination. It would then make it easier to read / edit / preview those files than when they are inlined within a Bash script.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brikis98 we can, but it would be the first script example that copies external files to a repo. I guess this is not such a bad thing, but it will also make the script slightly less portable. I.e. The user would need to ensure they copy a folder containing the script and all of the required templates for it to work 100% correctly. We could fail hard if one of the templates is missing. @zackproser what are your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving the markdown files to the
git-xargs
repo would make them slightly easier to read, but we'd also have the extra step of ensuring we've updated and pulled on the repo each time for running the latest script, as Rob points out. I don't have a strong opinion here, so I'd say go with whatever is easier for you.Makes me think
git-xargs
might do well with a means of fingerprinting the script or command it ran each time and adding that info to a PR description or something - for easier coordination in the common workflow of needing to make several small updates to a script following the first couple of runs. This would make it easier for colleagues to know which version of a script generated which PRs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's a good idea. We've been in a very similar territory recently planning an internal project. It appears RenovateBot actually stores a fair bit of state using pull requests. i.e: It knows whether a repo has been onboarded or not based on the status of a PR. I think it would be handy if
git-xargs
could by default sprinkle some metadata into the PRs.