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.
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
Contributing.md local development and environment setup tweaks #752
Contributing.md local development and environment setup tweaks #752
Changes from all commits
31f9ac5
ea8517a
7b4b744
4eef0c4
02fbd4b
7067510
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Contributing
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
Contributions to this project are released to the public under the project's open source license.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Submitting a pull request
git checkout -b my-branch-name
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
Quick End-To-End Example
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.
Local Development Setup
Once you have the repository cloned, there's a couple of additional steps you'll need to take. Since most of the testing is acceptance or integration testing, we need to manipulate GitHub resources in order to run it. Useful setup steps are listed below:
terraform-module-template
. The terraformtesting/terraform-template-module repo is a good, re-usable example.make build
master
) branch, likeTF_LOG=DEBUG TF_ACC=1 go test -v ./... -run ^TestAccGithubRepositories
. All those tests should pass.Local Development Iteration
github_label
for an example format.STATE:
) generated during the acceptance test run.TF_LOG=DEBUG TF_ACC=1 go test -v ./... -run ^TestAccGithubIssueLabel
TF_ACC=1 go test -v ./... -run ^TestAccGithubIssueLabel
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.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, theexamples/
directory is used to approach the problem, which is detailed in the next section.Automated And Manual Testing
Overview
When raising a pull request against this project, automated tests will be launched to run a subset of our test suite.
Full acceptance testing is run 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 asghes
), 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.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.Building The Provider
Clone the provider
Enter the provider directory and build the provider while specifying an output directory:
$ go build -o ~/go/bin/
This enables verifying your locally built provider using examples available in the
examples/
directory. Note that you will first need to configure your shell to map our provider to the local build:export TF_CLI_CONFIG_FILE=path/to/project/examples/dev.tfrc
An example file is available in our
examples
directory and resembles:See https://www.terraform.io/docs/cli/config/config-file.html for more details.
When running examples, you should spot the following warning to confirm you are using a local build:
Developing The Provider
If you wish to work on the provider, you'll first need Go installed on your machine (version
1.111.13+ is required).You may also need to correctly setup a GOPATH, as well as adding
$GOPATH/bin
to your$PATH
. Recent Go releases may have removed the need for this step however.To compile the provider, run
make build
. This will build the provider and put the provider binary in the$GOPATH/bin
directory.$ make build ... $ $GOPATH/bin/terraform-provider-github ...
In order to test the provider, you can simply run
make test
.$ make test
In order to run the full suite of Acceptance tests, run
make testacc
.Note: Acceptance tests create real resources, and often cost money to run.
Commonly required environment variables are listed below:
See this project for more information on how tests are run automatically.
GitHub Personal Access Token
You will need to create a personal access token for testing. It will need to have the following scopes selected:
Once the token has been created, it must be exported in your environment as
GITHUB_TOKEN
.GitHub Organization
If you do not have an organization already that you are comfortable running tests against, you will need to create one. 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
.Make sure that your organization has a
terraform-module-template
repository (terraformtesting/terraform-template-module is an example you can clone) and that its "Template repository" item in Settings is checked.If you are interested in using and/or testing Github's Team synchronization feature, please contact a maintainer as special arrangements can be made for your convenience.
Resources