You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+80-38
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
##Contributing
1
+
# Contributing
2
2
3
3
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
4
4
@@ -22,14 +22,38 @@ Here are a few things you can do that will increase the likelihood of your pull
22
22
- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
23
23
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
24
24
25
+
## Quick End-To-End Example
26
+
27
+
This section describes a typical sequence performed when developing locally. Full details of available tooling are available in the next section on [Automated And Manual Testing](#automated-and-manual-testing).
28
+
29
+
1. Export necessary configuration for authenticating your provider with GitHub
30
+
```sh
31
+
export GITHUB_TOKEN=<token of a user with an organization account>
32
+
export GITHUB_ORGANIZATION=<name of an organization>
33
+
```
34
+
1. Write a test describing what you will fix. See [`github_label`](./github/resource_github_issue_label_test.go) for an example format.
35
+
1. Run your test and observe it fail. Enabling debug output allows for observing the underlying requests and responses made as well as viewing state (search `STATE:`) generated during the acceptance test run.
36
+
```sh
37
+
TF_LOG=DEBUG TF_ACC=1 go test -v ./... -run ^TestAccGithubIssueLabel
38
+
```
39
+
1. Align the resource's implementation to your test case and observe it pass:
40
+
```sh
41
+
TF_ACC=1 go test -v ./... -run ^TestAccGithubIssueLabel
42
+
```
43
+
44
+
Note that some resources still use a previous format that is incompatible with automated test runs, which depend on using the `skipUnlessMode` helper. When encountering these resources, tests are rewritten to the latest format.
45
+
46
+
Also note that there is no build / `terraform init` / `terraform plan` sequence here. It is uncommon to run into a bug or feature that requires iteration without using tests. When these cases arise, the `examples/` directory is used to approach the problem, which is detailed in the next section.
47
+
25
48
## Automated And Manual Testing
26
49
27
50
### Overview
28
51
29
-
When raising a pull request against this project, automated tests will be launched to run our test suite.
52
+
When raising a pull request against this project, automated tests will be launched to run a subset of our test suite.
30
53
31
-
In line with Terraform Provider testing best practices, these tests exercise against a live, public GitHub deployment (referred to as `dotcom`). Tests may also run against an Enterprise GitHub deployment (referred to as `ghes`), which is sometimes available during parts of a month. If your change requires testing against a specific version of GitHub, please let a maintainer know and this may be arranged.
54
+
Full acceptance testing is run [daily][acc-daily]. In line with Terraform Provider testing best practices, these tests exercise against a live, public GitHub deployment (referred to as `dotcom`). Tests may also run against an Enterprise GitHub deployment (referred to as `ghes`), which is sometimes available during parts of a month. If your change requires testing against a specific version of GitHub, please let a maintainer know and this may be arranged.
32
55
56
+
Partial acceptance testing can be run manually by creating a branch prefixed with `test/`. Simple detection of changes and related test files is performed and a subset of acceptance tests are run against commits to these branches. This is a useful workflow for reviewing PRs submitted by the community, but local testing is preferred for contributors while iterating towards publishing a PR.
An example file is available in our `examples` directory and resembles:
79
+
80
+
```hcl
81
+
provider_installation {
82
+
dev_overrides {
83
+
"integrations/github" = "~/go/bin/"
84
+
}
85
+
86
+
direct {}
87
+
}
88
+
```
89
+
90
+
See https://www.terraform.io/docs/cli/config/config-file.html for more details.
91
+
92
+
When running examples, you should spot the following warning to confirm you are using a local build:
93
+
94
+
```console
95
+
Warning: Provider development overrides are in effect
96
+
97
+
The following provider development overrides are set in the CLI configuration:
98
+
- integrations/github in /Users/jcudit/go/bin
48
99
```
49
100
50
101
### Developing The Provider
51
102
52
-
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (version 1.11+ is *required*). You'll also need to correctly setup a [GOPATH](http://golang.org/doc/code.html#GOPATH), as well as adding `$GOPATH/bin` to your `$PATH`.
103
+
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (version 1.11+ is *required*).
104
+
105
+
You may also need to correctly setup a [GOPATH](http://golang.org/doc/code.html#GOPATH), as well as adding `$GOPATH/bin` to your `$PATH`. Recent Go releases may have removed the need for this step however.
53
106
54
107
To compile the provider, run `make build`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.
55
108
@@ -81,11 +134,23 @@ $ go test -v ./... -run TestAccProviderConfigure
81
134
82
135
Commonly required environment variables are listed below:
83
136
84
-
```console
137
+
```sh
138
+
# enable debug logging
85
139
export TF_LOG=DEBUG
140
+
141
+
# enable testing of organization scenarios instead of individual or anonymous
86
142
export GITHUB_ORGANIZATION=
87
-
export GITHUB_BASE_URL=
143
+
144
+
# enable testing of individual scenarios instead of organizaiton or anonymous
88
145
export GITHUB_OWNER=
146
+
147
+
# enable testing of enterprise appliances
148
+
export GITHUB_BASE_URL=
149
+
150
+
# leverage helper accounts for tests requiring them
151
+
# examples include:
152
+
# - https://github.com/github-terraform-test-user
153
+
# - https://github.com/terraformtesting
89
154
export GITHUB_TEST_OWNER=
90
155
export GITHUB_TEST_ORGANIZATION=
91
156
export GITHUB_TEST_USER_TOKEN=
@@ -110,38 +175,15 @@ Once the token has been created, it must be exported in your environment as `GIT
110
175
111
176
### GitHub Organization
112
177
113
-
If you do not have an organization already that you are comfortable running tests against, you will need to [create one](https://help.github.com/en/articles/creating-a-new-organization-from-scratch). The free "Team for Open Source" org type is fine for these tests. The name of the organization must then be exported in your environment as `GITHUB_OWNER`.
178
+
If you do not have an organization already that you are comfortable running tests against, you will need to [create one](https://help.github.com/en/articles/creating-a-new-organization-from-scratch). The free "Team for Open Source" org type is fine for these tests. The name of the organization must then be exported in your environment as `GITHUB_ORGANIZATION`.
114
179
115
180
If you are interested in using and/or testing Github's [Team synchronization](https://help.github.com/en/github/setting-up-and-managing-organizations-and-teams/synchronizing-teams-between-your-identity-provider-and-github) feature, please contact a maintainer as special arrangements can be made for your convenience.
116
181
117
-
### Test Repositories
118
-
119
-
In the pasts, tests required pre-existing repositories. The current test suite has been refreshed to have less dependencies like this. Developers would previously have had to set up the following fixtures manually:
120
-
121
-
In the organization you are using above, create the following test repositories:
122
-
123
-
*`test-repo`
124
-
* The description should be `Test description, used in GitHub Terraform provider acceptance test.`
125
-
* The website url should be `http://www.example.com`
126
-
* Create two topics within the repo named `test-topic` and `second-test-topic`
127
-
* In the repo settings, make sure all features and merge button options are enabled.
128
-
* Create a `test-branch` branch
129
-
*`test-repo-template`
130
-
* Configure the repository to be a [Template repository](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-template-repository)
131
-
* Create a release on the repository with `tag = v1.0`
132
-
133
-
Export an environment variable corresponding to `GITHUB_TEMPLATE_REPOSITORY=test-repo-template`.
134
-
135
-
### GitHub Users
136
-
137
-
Export your github username (the one you used to create the personal access token above) as `GITHUB_TEST_USER`. You may need to export a different github username as `GITHUB_TEST_COLLABORATOR`. Please note that these usernames cannot be the same as each other, and both of them must be real github usernames. The collaborator user does not need to be added as a collaborator to your test repo or organization, but as the acceptance tests do real things (and will trigger some notifications for this user), you should probably make sure the person you specify knows that you're doing this just to be nice. You can also export `GITHUB_TEST_COLLABORATOR_TOKEN` in order to test the invitation acceptance.
138
-
139
-
Additionally the user exported as `GITHUB_TEST_USER` should have a public email address configured in their profile; this should be exported as `GITHUB_TEST_USER_EMAIL` and the Github name exported as `GITHUB_TEST_USER_NAME` (this could be different to your GitHub login).
140
-
141
-
Finally, export the ID of the release created in the template repository as `GITHUB_TEMPLATE_REPOSITORY_RELEASE_ID`
142
-
143
182
## Resources
144
183
145
184
-[How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
0 commit comments