Skip to content

Commit ea8944c

Browse files
committed
Managed by Terraform: Add CONTRIBUTING.md issue template
1 parent ce33334 commit ea8944c

1 file changed

Lines changed: 269 additions & 0 deletions

File tree

.github/CONTRIBUTING.md

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
# Contributing to Tencentcloud Plugin
2+
3+
**First:** if you're unsure or afraid of _anything_, just ask or submit the
4+
issue or pull request anyway. You won't be yelled at for giving your best
5+
effort. The worst that can happen is that you'll be politely asked to change
6+
something. We appreciate any sort of contributions, and don't want a wall of
7+
rules to get in the way of that.
8+
9+
However, for those individuals who want a bit more guidance on the best way to
10+
contribute to the project, read on. This document will cover what we're looking
11+
for. By addressing all the points we're looking for, it raises the chances we
12+
can quickly merge or address your contributions.
13+
14+
When contributing in any way to the Packer project (new issue, PR, etc), please
15+
be aware that our team identifies with many gender pronouns. Please remember to
16+
use nonbinary pronouns (they/them) and gender neutral language ("Hello folks")
17+
when addressing our team. For more reading on our code of conduct, please see the
18+
[HashiCorp community guidelines](https://www.hashicorp.com/community-guidelines).
19+
20+
## Issues
21+
22+
### Reporting an Issue
23+
24+
- Make sure you test against the latest released version. It is possible we
25+
already fixed the bug you're experiencing.
26+
27+
- Run packer with debug output with the environment variable `PACKER_LOG`.
28+
For example: `PACKER_LOG=1 packer build template.pkr.hcl`. Take the _entire_
29+
output and create a [gist](https://gist.github.com) for linking to in your
30+
issue. Packer should strip sensitive keys from the output, but take a look
31+
through just in case.
32+
33+
- Provide a reproducible test case. If a contributor can't reproduce an issue,
34+
then it dramatically lowers the chances it'll get fixed. And in some cases,
35+
the issue will eventually be closed.
36+
37+
- Respond promptly to any questions made by the Packer team to your issue. Stale
38+
issues will be closed.
39+
40+
### Issue Lifecycle
41+
42+
1. The issue is reported.
43+
44+
2. The issue is verified and categorized by a Packer collaborator.
45+
Categorization is done via tags. For example, bugs are marked as "bugs" and
46+
simple fixes are marked as "good first issue".
47+
48+
3. Unless it is critical, the issue is left for a period of time (sometimes many
49+
weeks), giving outside contributors a chance to address the issue.
50+
51+
4. The issue is addressed in a pull request or commit. The issue will be
52+
referenced in the commit message so that the code that fixes it is clearly
53+
linked.
54+
55+
5. Sometimes, if you have a specialized environment or use case, the maintainers
56+
may ask for your help testing the patch.
57+
58+
6. The issue is closed.
59+
60+
61+
62+
## Setting up Go
63+
64+
If you have never worked with Go before, you will have to install its
65+
runtime in order to build packer with the Tencentcloud plugin.
66+
67+
1. This project always releases from the latest version of golang.
68+
[Install go](https://golang.org/doc/install#install) To properly build from
69+
source, you need to have golang >= v1.16
70+
71+
## Setting up Tencentcloud plugin for dev
72+
73+
With Go installed, you can already `go get` the Tencentcloud plugin and `make dev` in
74+
order to compile and test it. These instructions target
75+
POSIX-like environments (macOS, Linux, Cygwin, etc.) so you may need to
76+
adjust them for Windows or other shells.
77+
78+
1. Download the Tencentcloud plugin source (and its dependencies) by running
79+
`go get github.com/hashicorp/packer-plugin-tencentcloud`. This will download the source to
80+
`$GOPATH/src/github.com/hashicorp/packer-plugin-tencentcloud`.
81+
82+
2. When working on the Tencentcloud plugin, first `cd $GOPATH/src/github.com/hashicorp/packer-plugin-tencentcloud`
83+
so you can run `make dev` and easily access other files. `make dev` will build the packer-plugin-tencentcloud binary and install it under `$HOME/.packer.d/plugins/`.
84+
85+
3. Make your changes to the Tencentcloud plugin source. You can run `make dev` to build and install locally, and `make test` to run unit tests.
86+
Any compilation errors will be shown when the binaries are rebuilding. If you don't have `make` you can simply run `go build -o packer-plugin-tencentcloud` from the project root, and `mv packer-plugin-tencentcloud ~/.packer.d/plugins/packer-plugin-tencentcloud` to install the plugin.
87+
88+
4. After building the Tencentcloud plugin successfully, use the latest version of Packer to build a machine and verify your changes. In the [example folder](https://github.com/hashicorp/packer-plugin-tencentcloud/blob/main/example) we provide a basic template. Comment out the `packer {}` block to force Packer use the development binary installed in the previous step.
89+
90+
5. If everything works well and the tests pass, run `go fmt ./...` on your code before
91+
submitting a pull-request.
92+
93+
94+
### Opening a Pull Request
95+
96+
Thank you for contributing! When you are ready to open a pull-request, you will
97+
need to [fork the Tencentcloud plugin](https://github.com/hashicorp/packer-plugin-tencentcloud#fork-destination-box), push your
98+
changes to your fork, and then open a pull-request.
99+
100+
For example, my github username is `myuser`, so I would do the following:
101+
102+
```
103+
git checkout -b f-my-feature
104+
# Develop a patch.
105+
git push https://github.com/myuser/packer-plugin-tencentcloud f-my-feature
106+
```
107+
108+
From there, open your fork in your browser to open a new pull-request.
109+
110+
### Pull Request Lifecycle
111+
112+
1. You are welcome to submit your pull request for commentary or review before
113+
it is fully completed. Please prefix the title of your pull request with
114+
"[WIP]" to indicate this. It's also a good idea to include specific questions
115+
or items you'd like feedback on.
116+
117+
2. Once you believe your pull request is ready to be merged, you can remove any
118+
"[WIP]" prefix from the title and a core team member will review.
119+
120+
3. One of Tencentcloud plugin's core team members will look over your contribution and
121+
either merge, or provide comments letting you know if there is anything left
122+
to do. We do our best to provide feedback in a timely manner, but it may take
123+
some time for us to respond. We may also have questions that we need answered
124+
about the code, either because something doesn't make sense to us or because
125+
we want to understand your thought process.
126+
127+
4. If we have requested changes, you can either make those changes or, if you
128+
disagree with the suggested changes, we can have a conversation about our
129+
reasoning and agree on a path forward. This may be a multi-step process. Our
130+
view is that pull requests are a chance to collaborate, and we welcome
131+
conversations about how to do things better. It is the contributor's
132+
responsibility to address any changes requested. While reviewers are happy to
133+
give guidance, it is unsustainable for us to perform the coding work necessary
134+
to get a PR into a mergeable state.
135+
136+
5. Once all outstanding comments and checklist items have been addressed, your
137+
contribution will be merged! Merged PRs will be included in the next
138+
Packer release. The core team takes care of updating the
139+
[CHANGELOG.md](../CHANGELOG.md) as they merge.
140+
141+
6. In rare cases, we might decide that a PR should be closed without merging.
142+
We'll make sure to provide clear reasoning when this happens.
143+
144+
### Tips for Working on Packer
145+
146+
#### Getting Your Pull Requests Merged Faster
147+
148+
It is much easier to review pull requests that are:
149+
150+
1. Well-documented: Try to explain in the pull request comments what your
151+
change does, why you have made the change, and provide instructions for how
152+
to produce the new behavior introduced in the pull request. If you can,
153+
provide screen captures or terminal output to show what the changes look
154+
like. This helps the reviewers understand and test the change.
155+
156+
2. Small: Try to only make one change per pull request. If you found two bugs
157+
and want to fix them both, that's _awesome_, but it's still best to submit
158+
the fixes as separate pull requests. This makes it much easier for reviewers
159+
to keep in their heads all of the implications of individual code changes,
160+
and that means the PR takes less effort and energy to merge. In general, the
161+
smaller the pull request, the sooner reviewers will be able to make time to
162+
review it.
163+
164+
3. Passing Tests: Based on how much time we have, we may not review pull
165+
requests which aren't passing our tests. (Look below for advice on how to
166+
run unit tests). If you need help figuring out why tests are failing, please
167+
feel free to ask, but while we're happy to give guidance it is generally
168+
your responsibility to make sure that tests are passing. If your pull request
169+
changes an interface or invalidates an assumption that causes a bunch of
170+
tests to fail, then you need to fix those tests before we can merge your PR.
171+
172+
If we request changes, try to make those changes in a timely manner. Otherwise,
173+
PRs can go stale and be a lot more work for all of us to merge in the future.
174+
175+
Even with everyone making their best effort to be responsive, it can be
176+
time-consuming to get a PR merged. It can be frustrating to deal with
177+
the back-and-forth as we make sure that we understand the changes fully. Please
178+
bear with us, and please know that we appreciate the time and energy you put
179+
into the project.
180+
181+
#### Working on forks
182+
183+
The easiest way to work on a fork is to set it as a remote of the the Tencentcloud plugin
184+
project. After following the steps in "Setting up Go to work on the Tencentcloud plugin":
185+
186+
1. Navigate to the code:
187+
188+
`cd $GOPATH/src/github.com/hashicorp/packer-plugin-tencentcloud`
189+
190+
2. Add the remote by running:
191+
192+
`git remote add <name of remote> <github url of fork>`
193+
194+
For example:
195+
196+
`git remote add myuser https://github.com/myuser/packer-plugin-tencentcloud.git`
197+
198+
3. Checkout a feature branch:
199+
200+
`git checkout -b new-feature`
201+
202+
4. Make changes.
203+
5. (Optional) Push your changes to the fork:
204+
205+
`git push -u <name of remote> new-feature`
206+
207+
This way you can push to your fork to create a PR, but the code on disk still
208+
lives in the spot where the go cli tools are expecting to find it.
209+
210+
#### Go modules & go vendor
211+
212+
If you are submitting a change that requires new or updated dependencies,
213+
please include them in `go.mod`/`go.sum`. This
214+
helps everything get tested properly in CI.
215+
216+
Note that you will need to use [go
217+
mod](https://github.com/golang/go/wiki/Modules) to do this. This step is
218+
recommended but not required.
219+
220+
Use `go get <project>` to add dependencies to the project. See [go mod quick
221+
start](https://github.com/golang/go/wiki/Modules#quick-start) for examples.
222+
223+
Please only apply the minimal vendor changes to get your PR to work. The Tencentcloud plugin
224+
does not attempt to track the latest version for each dependency.
225+
226+
#### HCL2 Spec code generation
227+
228+
Packer relies on `go generate` to generate HCL2's bridging code. First you should install the command with `go install github.com/hashicorp/packer/cmd/mapstructure-to-hcl2`, then you generate with
229+
`go generate ./...`. This should update/create `*.hcl2spec.go` file(s).
230+
231+
#### Running Unit Tests
232+
233+
You can run tests for individual packages using commands like this:
234+
235+
```
236+
make test TEST=./builder/ebs/...
237+
```
238+
239+
#### Running Builder Acceptance Tests
240+
241+
If the Tencentcloud Plugin has [acceptance tests](https://en.wikipedia.org/wiki/Acceptance_testing), these probably have some requirements such as environment variables to be set for API tokens and keys. Each test should error and tell you what are missing, so those are not documented here.
242+
243+
If you're working on a feature and want to verify it is functioning (and also hasn't broken anything else), we recommend creating or running the acceptance tests.
244+
245+
**Warning:** The acceptance tests create/destroy/modify _real resources_, which
246+
may incur costs for real money. In the presence of a bug, it is possible that
247+
resources may be left behind, which can cost money even though you were not
248+
using them. We recommend running tests in an account used only for that purpose
249+
so it is easy to see if there are any dangling resources, and so production
250+
resources are not accidentally destroyed or overwritten during testing.
251+
252+
To run the acceptance tests, invoke `make testacc`:
253+
254+
```
255+
make testacc TEST=./builder/ebs
256+
...
257+
```
258+
259+
The `TEST` variable lets you narrow the scope of the acceptance tests to a
260+
specific package / folder.
261+
262+
#### Debugging Plugins
263+
264+
Each packer plugin runs in a separate process and communicates via RPC over a
265+
socket therefore using a debugger will not work (be complicated at least).
266+
267+
The Packer and plugins code provides more detailed logs when ran with PACKER_LOG
268+
turned on. If that doesn't work, adding some extra debug print outs when you have
269+
homed in on the problem is usually enough.

0 commit comments

Comments
 (0)