Skip to content

Commit

Permalink
Merge branch 'main' into bendbennett/issues-16
Browse files Browse the repository at this point in the history
  • Loading branch information
bendbennett authored Jan 31, 2023
2 parents bba2711 + fe17744 commit d96eb7c
Show file tree
Hide file tree
Showing 61 changed files with 1,300 additions and 64 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/FEATURES-20230118-100343.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: FEATURES
body: 'helper/resource: Added `TF_ACC_PERSIST_WORKING_DIR` environment variable to
allow persisting of Terraform files generated during each test step'
time: 2023-01-18T10:03:43.12743Z
custom:
Issue: "18"
6 changes: 6 additions & 0 deletions .changes/unreleased/FEATURES-20230123-174450.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: FEATURES
body: 'helper/resource: Added `TestCase` type `WorkingDir` field to allow specifying
the base directory where testing files used by the testing module are generated'
time: 2023-01-23T17:44:50.681427Z
custom:
Issue: "18"
5 changes: 4 additions & 1 deletion .changie.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

changesDir: .changes
unreleasedDir: unreleased
changelogPath: CHANGELOG.md
Expand All @@ -14,7 +17,7 @@ kinds:
- label: BREAKING CHANGES
- label: NOTES
- label: FEATURES
- label: IMPROVEMENTS
- label: ENHANCEMENTS
- label: BUG FIXES
newlines:
afterKind: 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
go-version-file: 'go.mod'
- run: go mod download
- uses: golangci/golangci-lint-action@0ad9a0988b3973e851ab0a07adf248ec2e100376 # v3.3.1
- uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5 # v3.4.0
test:
name: test (Go v${{ matrix.go-version }})
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
with:
go-version-file: 'go.mod'
- uses: goreleaser/goreleaser-action@8f67e590f2d095516493f017008adc464e63adb1 # v4.1.0
- uses: goreleaser/goreleaser-action@9754a253a8673b0ea869c2e863b4e975497efd0c # v4.1.1
with:
args: check
39 changes: 39 additions & 0 deletions .github/workflows/jira-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
on:
issues:
types: [closed, deleted, reopened]
pull_request_target:
types: [closed, reopened]

name: Jira Sync

jobs:
sync:
runs-on: ubuntu-latest
name: Jira sync
steps:

- name: Login
uses: atlassian/gajira-login@45fd029b9f1d6d8926c6f04175aa80c0e42c9026 # v3.0.1
if: contains(github.event.pull_request.labels.*.name, 'tf-devex-triage') || contains(github.event.issue.labels.*.name, 'tf-devex-triage')
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
- name: Search for existing issue
id: search
if: contains(github.event.pull_request.labels.*.name, 'tf-devex-triage') || contains(github.event.issue.labels.*.name, 'tf-devex-triage')
uses: tomhjp/gh-action-jira-search@04700b457f317c3e341ce90da5a3ff4ce058f2fa # v0.2.2
with:
jql: 'project="TFECO" and "Team (R&D)[Labels]"="TF-DevEx" and description ~ "${{ github.event.issue.html_url || github.event.pull_request.html_url }}" and labels in (Github)'
- name: Close task
if: ( github.event.action == 'closed' || github.event.action == 'deleted' ) && steps.search.outputs.issue
uses: atlassian/gajira-transition@38fc9cd61b03d6a53dd35fcccda172fe04b36de3 # v3.0.1
with:
issue: ${{ steps.search.outputs.issue }}
transition: "Closed"
- name: Reopen task
if: github.event.action == 'reopened' && steps.search.outputs.issue
uses: atlassian/gajira-transition@38fc9cd61b03d6a53dd35fcccda172fe04b36de3 # v3.0.1
with:
issue: ${{ steps.search.outputs.issue }}
transition: "To Do"
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ jobs:
with:
fetch-depth: 0
- name: Batch changes
uses: miniscruff/changie-action@v0
uses: miniscruff/changie-action@7d8e4c245da691d57ca34019a0504321fa7b7e07 # v1.0.0
with:
version: latest
args: batch ${{ needs.changelog-version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Merge changes
uses: miniscruff/changie-action@v0
uses: miniscruff/changie-action@7d8e4c245da691d57ca34019a0504321fa7b7e07 # v1.0.0
with:
version: latest
args: merge
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
run: |
cd .changes
sed -e "1{/# /d;}" -e "2{/^$/d;}" ${{ needs.changelog-version.outputs.version }}.md > /tmp/release-notes.txt
- uses: goreleaser/goreleaser-action@8f67e590f2d095516493f017008adc464e63adb1 # v4.1.0
- uses: goreleaser/goreleaser-action@9754a253a8673b0ea869c2e863b4e975497efd0c # v4.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/send-to-jira.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
on:
issues:
types: [labeled]

name: Jira Sync

jobs:
sync:
runs-on: ubuntu-latest
name: Jira sync
steps:

- name: Login
uses: atlassian/gajira-login@45fd029b9f1d6d8926c6f04175aa80c0e42c9026 # v3.0.1
if: github.event.label.name == 'tf-devex-triage'
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
- name: Search for existing issue
id: search
if: github.event.label.name == 'tf-devex-triage'
uses: tomhjp/gh-action-jira-search@04700b457f317c3e341ce90da5a3ff4ce058f2fa # v0.2.2
with:
jql: 'project="TFECO" and "Team (R&D)[Labels]"="TF-DevEx" and description ~ "${{ github.event.issue.html_url || github.event.pull_request.html_url }}" and labels in (Github)'

- name: Create task in DevEx board
if: github.event.label.name == 'tf-devex-triage' && !steps.search.outputs.issue
uses: atlassian/gajira-create@59e177c4f6451399df5b4911c2211104f171e669 #v3.0.1
with:
project: TFECO
issuetype: "Task"
summary: "[GH] ${{ github.event.issue.title || github.event.pull_request.title }}"
description: "${{ github.event.issue.html_url || github.event.pull_request.html_url }} \n Synced by Github Actions, tagged by ${{ github.actor }}"
# customfield_10091 is Team (R&D)
fields: '{"customfield_10091": ["TF-DevEx"], "labels": ["Github"]}'

6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
.idea
node_modules
website-preview

.idea
.vscode/settings.json
25 changes: 25 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
issues:
max-per-linter: 0
max-same-issues: 0

linters:
disable-all: true
enable:
- durationcheck
- errcheck
- exportloopref
- forcetypeassert
- gofmt
- gosimple
- ineffassign
- makezero
- misspell
- nilerr
- paralleltest
- predeclared
- staticcheck
- tenv
- unconvert
- unparam
- unused
- vet
3 changes: 3 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

project_name: terraform-plugin-testing
build:
skip: true
Expand Down
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Run this if working on the website locally to run in watch mode.
.PHONY: website
website:
$(MAKE) -C website website

# Use this if you have run `website/build-local` to use the locally built image.
.PHONY: website/local
website/local:
$(MAKE) -C website website/local

# Run this to generate a new local Docker image.
.PHONY: website/build-local
website/build-local:
$(MAKE) -C website website/build-local
4 changes: 4 additions & 0 deletions helper/acctest/random_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ import (
)

func TestRandIntRange(t *testing.T) {
t.Parallel()

v := RandInt()
if vv := RandIntRange(v, v+1); vv != v {
t.Errorf("expected RandIntRange(%d, %d) to return %d, got %d", v, v+1, v, vv)
}
}

func TestRandIpAddress(t *testing.T) {
t.Parallel()

testCases := []struct {
s string
expected *regexp.Regexp
Expand Down
2 changes: 2 additions & 0 deletions helper/resource/id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ var allDigits = regexp.MustCompile(`^\d+$`)
var allHex = regexp.MustCompile(`^[a-f0-9]+$`)

func TestUniqueId(t *testing.T) {
t.Parallel()

split := func(rest string) (timestamp, increment string) {
return rest[:18], rest[18:]
}
Expand Down
4 changes: 3 additions & 1 deletion helper/resource/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ func TestSdkProviderFactoriesMerge(t *testing.T) {
}

func TestRunProviderCommand(t *testing.T) {
t.Parallel()

currentDir, err := os.Getwd()

if err != nil {
Expand All @@ -261,7 +263,7 @@ func TestRunProviderCommand(t *testing.T) {
funcCalled = true
return nil
},
helper.RequireNewWorkingDir(ctx, t),
helper.RequireNewWorkingDir(ctx, t, ""),
&providerFactories{
legacy: map[string]func() (*schema.Provider, error){
"examplecloud": func() (*schema.Provider, error) { //nolint:unparam // required signature
Expand Down
3 changes: 3 additions & 0 deletions helper/resource/state_shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,22 @@ func shimOutputState(so *tfjson.StateOutput) (*terraform.OutputState, error) {
case string:
elements := make([]interface{}, len(v))
for i, el := range v {
//nolint:forcetypeassert // Guaranteed by type switch
elements[i] = el.(string)
}
os.Value = elements
case bool:
elements := make([]interface{}, len(v))
for i, el := range v {
//nolint:forcetypeassert // Guaranteed by type switch
elements[i] = el.(bool)
}
os.Value = elements
// unmarshalled number from JSON will always be json.Number
case json.Number:
elements := make([]interface{}, len(v))
for i, el := range v {
//nolint:forcetypeassert // Guaranteed by type switch
elements[i] = el.(json.Number)
}
os.Value = elements
Expand Down
21 changes: 21 additions & 0 deletions helper/resource/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ func UnknownPendingStateRefreshFunc() StateRefreshFunc {
}

func TestWaitForState_inconsistent_positive(t *testing.T) {
t.Parallel()

conf := &StateChangeConf{
Pending: []string{"replicating"},
Target: []string{"done"},
Expand All @@ -110,11 +112,14 @@ func TestWaitForState_inconsistent_positive(t *testing.T) {
}

if idx != 4 {
//nolint:forcetypeassert // Internal test
t.Fatalf("Expected index 4, given %d", idx.(int))
}
}

func TestWaitForState_inconsistent_negative(t *testing.T) {
t.Parallel()

refreshCount := int64(0)
f := InconsistentStateRefreshFunc()
refresh := func() (interface{}, string, error) {
Expand Down Expand Up @@ -151,6 +156,8 @@ func TestWaitForState_inconsistent_negative(t *testing.T) {
}

func TestWaitForState_timeout(t *testing.T) {
t.Parallel()

old := refreshGracePeriod
refreshGracePeriod = 5 * time.Millisecond
defer func() {
Expand Down Expand Up @@ -183,6 +190,8 @@ func TestWaitForState_timeout(t *testing.T) {
// Make sure a timeout actually cancels the refresh goroutine and waits for its
// return.
func TestWaitForState_cancel(t *testing.T) {
t.Parallel()

// make this refresh func block until we cancel it
cancel := make(chan struct{})
refresh := func() (interface{}, string, error) {
Expand Down Expand Up @@ -238,6 +247,8 @@ func TestWaitForState_cancel(t *testing.T) {
}

func TestWaitForState_success(t *testing.T) {
t.Parallel()

conf := &StateChangeConf{
Pending: []string{"pending", "incomplete"},
Target: []string{"running"},
Expand All @@ -255,6 +266,8 @@ func TestWaitForState_success(t *testing.T) {
}

func TestWaitForState_successUnknownPending(t *testing.T) {
t.Parallel()

conf := &StateChangeConf{
Target: []string{"done"},
Refresh: UnknownPendingStateRefreshFunc(),
Expand All @@ -271,6 +284,8 @@ func TestWaitForState_successUnknownPending(t *testing.T) {
}

func TestWaitForState_successEmpty(t *testing.T) {
t.Parallel()

conf := &StateChangeConf{
Pending: []string{"pending", "incomplete"},
Target: []string{},
Expand All @@ -290,6 +305,8 @@ func TestWaitForState_successEmpty(t *testing.T) {
}

func TestWaitForState_failureEmpty(t *testing.T) {
t.Parallel()

conf := &StateChangeConf{
Pending: []string{"pending", "incomplete"},
Target: []string{},
Expand All @@ -312,6 +329,8 @@ func TestWaitForState_failureEmpty(t *testing.T) {
}

func TestWaitForState_failure(t *testing.T) {
t.Parallel()

conf := &StateChangeConf{
Pending: []string{"pending", "incomplete"},
Target: []string{"running"},
Expand All @@ -333,6 +352,8 @@ func TestWaitForState_failure(t *testing.T) {
}

func TestWaitForStateContext_cancel(t *testing.T) {
t.Parallel()

// make this refresh func block until we cancel it
ctx, cancel := context.WithCancel(context.Background())
refresh := func() (interface{}, string, error) {
Expand Down
Loading

0 comments on commit d96eb7c

Please sign in to comment.