Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
53 changes: 53 additions & 0 deletions .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Acceptance Tests

on:
pull_request:
types: [labeled]

jobs:
acceptance-tests:
runs-on: ubuntu-latest
steps:

- name: Parse Context From Environment
run: |
echo ::set-env name=HEAD_SHA::$(
jq -rc '.pull_request.head.sha' $GITHUB_EVENT_PATH
)
echo ::set-env name=LABEL_NAME::$(
jq -rc .label.name $GITHUB_EVENT_PATH
)

- name: Parse Arguments From Label Name
run: |
echo ::set-env name=RUN_FILTER::$(
echo $LABEL_NAME | cut -d/ -f 2
)

- name: Match expected prefix or exit
run: echo ${LABEL_NAME} | egrep -q "^acceptance-test/"

- name: Checkout
uses: actions/checkout@v2.0.0
with:
ref: ${{ env.HEAD_SHA }}

- name: Generate Test Fixtures
run: |
openssl req -x509 -newkey rsa:4096 -days 1 -nodes \
-subj "/C=US/ST=CA/L=San Francisco/O=HashiCorp, Inc./CN=localhost" \
-keyout github/test-fixtures/key.pem -out github/test-fixtures/cert.pem

- name: Acceptance Tests
uses: terraformtesting/acceptance-tests@v1.2.0
with:
RUN_FILTER: ${{ env.RUN_FILTER }}
GITHUB_ORGANIZATION: terraformtesting
GITHUB_TEST_USER: github-terraform-test-user
GITHUB_TEST_USER_NAME: "Test User"
GITHUB_TEST_USER_EMAIL: 60107403+github-terraform-test-user@users.noreply.github.com
GITHUB_TEST_USER_TOKEN: ${{ secrets.GITHUB_TEST_USER_TOKEN }}
GITHUB_TEST_COLLABORATOR: github-terraform-test-collaborator
GITHUB_TEST_COLLABORATOR_TOKEN: ${{ secrets.GITHUB_TEST_COLLABORATOR_TOKEN }}
GITHUB_TEMPLATE_REPOSITORY: terraform-template-module
GITHUB_TEMPLATE_REPOSITORY_RELEASE_ID: 23826477
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.11.5
1.13.8
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ linters:

linters-settings:
errcheck:
ignore: github.com/hashicorp/terraform/helper/schema:ForceNew|Set,fmt:.*,io:Close
ignore: github.com/hashicorp/terraform-plugin-sdk/helper/schema:ForceNew|Set,fmt:.*,io:Close

11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ services:
- docker
language: go
go:
- "1.11.x"
- "1.13.x"

env:
- GOFLAGS=-mod=vendor

branches:
only:
Expand All @@ -16,8 +19,8 @@ install:
# packages that live there.
# See: https://github.com/golang/go/issues/12933
- bash scripts/gogetcookie.sh
- make tools
- make tools

matrix:
fast_finish: true
allow_failures:
Expand All @@ -31,5 +34,3 @@ matrix:
script: make website-lint
- name: "make website-test"
script: make website-test
env:
- GOFLAGS=-mod=vendor GO111MODULE=on
18 changes: 12 additions & 6 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ tools:
build: fmtcheck
go install

errcheck:
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"

fmt:
@echo "==> Fixing source code with gofmt..."
gofmt -w $(GOFMT_FILES)
gofmt -s -w $(GOFMT_FILES)

fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"

lint:
@echo "==> Checking source code against linters..."
golangci-lint run ./...

test: fmtcheck
go test -i $(TEST) || exit 1
echo $(TEST) | \
Expand All @@ -42,6 +39,15 @@ test-compile:
fi
go test -c $(TEST) $(TESTARGS)

vet:
@echo "go vet ."
@go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \
echo ""; \
echo "Vet found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for review."; \
exit 1; \
fi

website:
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
Expand All @@ -60,5 +66,5 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)

.PHONY: build test testacc vet fmt fmtcheck errcheck lint tools test-compile website website-lint website-test
.PHONY: build test testacc vet fmt fmtcheck lint tools test-compile website website-lint website-test

7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Requirements
------------

- [Terraform](https://www.terraform.io/downloads.html) 0.10.x
- [Go](https://golang.org/doc/install) 1.11 (to build the provider plugin)
- [Go](https://golang.org/doc/install) 1.13 (to build the provider plugin)

Building The Provider
---------------------
Expand Down Expand Up @@ -106,9 +106,10 @@ Export an environment variable corresponding to `GITHUB_TEMPLATE_REPOSITORY=test
Export your github username (the one you used to create the personal access token above) as `GITHUB_TEST_USER`. You will 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.
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.

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).

Finally, export the ID of the release created in the template repository as `GITHUB_TEMPLATE_REPOSITORY_RELEASE_ID`
Finally, export the ID of the release created in the template repository as `GITHUB_TEMPLATE_REPOSITORY_RELEASE_ID`
2 changes: 1 addition & 1 deletion github/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net/url"

"github.com/google/go-github/v29/github"
"github.com/hashicorp/terraform/helper/logging"
"github.com/hashicorp/terraform-plugin-sdk/helper/logging"
"golang.org/x/oauth2"
)

Expand Down
4 changes: 2 additions & 2 deletions github/data_source_github_collaborators.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"

"github.com/google/go-github/v29/github"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)

func dataSourceGithubCollaborators() *schema.Resource {
Expand Down
4 changes: 2 additions & 2 deletions github/data_source_github_collaborators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccGithubCollaboratorsDataSource_basic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_ip_ranges.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package github

import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func dataSourceGithubIpRanges() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_ip_ranges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package github
import (
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccGithubIpRangesDataSource_existing(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions github/data_source_github_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package github
import (
"context"
"fmt"
"github.com/hashicorp/terraform/helper/validation"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"log"
"strconv"
"strings"

"github.com/google/go-github/v29/github"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func dataSourceGithubRelease() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccGithubReleaseDataSource_fetchByLatestNoReleaseReturnsError(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions github/data_source_github_repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"log"

"github.com/google/go-github/v29/github"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)

func dataSourceGithubRepositories() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_repositories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccGithubRepositoriesDataSource_basic(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"strings"

"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func dataSourceGithubRepository() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccGithubRepositoryDataSource_fullName_noMatchReturnsError(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"

"github.com/google/go-github/v29/github"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func dataSourceGithubTeam() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccGithubTeamDataSource_noMatchReturnsError(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"strconv"

"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func dataSourceGithubUser() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccGithubUserDataSource_noMatchReturnsError(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion github/migrate_github_repository_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"strings"

"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

func resourceGithubWebhookMigrateState(v int, is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) {
Expand Down
2 changes: 1 addition & 1 deletion github/migrate_github_repository_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

func TestMigrateGithubWebhookStateV0toV1(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions github/provider.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package github

import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

func Provider() terraform.ResourceProvider {
Expand Down
12 changes: 5 additions & 7 deletions github/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import (
"strconv"
"testing"

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
"github.com/terraform-providers/terraform-provider-tls/tls"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

var testUser string = os.Getenv("GITHUB_TEST_USER")
Expand All @@ -28,7 +27,6 @@ func init() {
testAccProvider = Provider().(*schema.Provider)
testAccProviders = map[string]terraform.ResourceProvider{
"github": testAccProvider,
"tls": tls.Provider(),
}
testAccProviderFactories = func(providers *[]*schema.Provider) map[string]terraform.ResourceProviderFactory {
return map[string]terraform.ResourceProviderFactory{
Expand Down Expand Up @@ -75,7 +73,7 @@ func testAccPreCheck(t *testing.T) {
func TestProvider_individual(t *testing.T) {

username := "hashibot"
resource.Test(t, resource.TestCase{
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
},
Expand Down Expand Up @@ -174,7 +172,7 @@ func TestProvider_insecure(t *testing.T) {
`

username := "hashibot"
resource.ParallelTest(t, resource.TestCase{
resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
},
Expand Down
4 changes: 2 additions & 2 deletions github/resource_github_branch_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"strings"

"github.com/google/go-github/v29/github"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)

func resourceGithubBranchProtection() *schema.Resource {
Expand Down
Loading