From 5173bd6fddf35e5b7ca2bd2ebc3eaff624c4fbc6 Mon Sep 17 00:00:00 2001 From: Marques Johansson Date: Wed, 4 Aug 2021 18:51:54 -0400 Subject: [PATCH 1/3] add --debug mode to the provider plugin Enable debugging per https://www.terraform.io/docs/extend/debugging.html Signed-off-by: Marques Johansson --- main.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index a4ce96ba..ad02b67b 100644 --- a/main.go +++ b/main.go @@ -1,11 +1,28 @@ package main import ( + "context" + "flag" + "log" + "github.com/equinix/terraform-provider-metal/metal" "github.com/hashicorp/terraform-plugin-sdk/v2/plugin" ) func main() { - plugin.Serve(&plugin.ServeOpts{ - ProviderFunc: metal.Provider}) + var debugMode bool + + flag.BoolVar(&debugMode, "debug", false, "set to true to run the provider with support for debuggers like delve") + flag.Parse() + opts := &plugin.ServeOpts{ProviderFunc: metal.Provider} + + if debugMode { + err := plugin.Debug(context.Background(), "registry.terraform.io/equinix/metal", opts) + if err != nil { + log.Fatal(err.Error()) + } + return + } + + plugin.Serve(opts) } From 134c3cffe23104885ce99f08d773a7ca36356eeb Mon Sep 17 00:00:00 2001 From: Marques Johansson Date: Wed, 4 Aug 2021 19:16:29 -0400 Subject: [PATCH 2/3] add codecov and GH action annotation of test failures Signed-off-by: Marques Johansson --- .github/workflows/acctest.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/acctest.yml b/.github/workflows/acctest.yml index 52c0cdd0..b5385e23 100644 --- a/.github/workflows/acctest.yml +++ b/.github/workflows/acctest.yml @@ -58,7 +58,7 @@ jobs: go mod download - name: TF acceptance tests - timeout-minutes: 120 + timeout-minutes: 180 env: TF_ACC: "1" TF_ACC_TERRAFORM_VERSION: ${{ matrix.terraform }} @@ -68,10 +68,25 @@ jobs: METAL_AUTH_TOKEN: ${{ secrets.PACKET_AUTH_TOKEN }} run: | - go test -v -cover -parallel 4 -timeout 120m ./metal + go test -v -json -coverprofile coverage.txt -covermode=atomic -parallel 4 -timeout 180m ./metal > test.json + - name: Annotate tests + if: always() + uses: guyarb/golang-test-annotations@v0.4.0 + with: + test-results: test.json - name: Sweeper if: ${{ always() }} env: METAL_AUTH_TOKEN: ${{ secrets.PACKET_AUTH_TOKEN }} run: | - go test ./metal -v -sweep="tf_test" + go test ./metal -v -json -sweep="tf_test" > sweep.json + - name: Annotate sweep + if: always() + uses: guyarb/golang-test-annotations@v0.4.0 + with: + test-results: sweep.json + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.txt From 3216e48623a55aecff5cfe8c201a112581586811 Mon Sep 17 00:00:00 2001 From: Marques Johansson Date: Wed, 22 Sep 2021 08:35:05 -0400 Subject: [PATCH 3/3] undo WIP changes to add GH test annotations Signed-off-by: Marques Johansson --- .github/workflows/acctest.yml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/acctest.yml b/.github/workflows/acctest.yml index b5385e23..ef787650 100644 --- a/.github/workflows/acctest.yml +++ b/.github/workflows/acctest.yml @@ -40,7 +40,7 @@ jobs: version: - stable terraform: - - '1.0.2' + - '1.0.7' - '0.13.6' steps: @@ -68,24 +68,15 @@ jobs: METAL_AUTH_TOKEN: ${{ secrets.PACKET_AUTH_TOKEN }} run: | - go test -v -json -coverprofile coverage.txt -covermode=atomic -parallel 4 -timeout 180m ./metal > test.json - - name: Annotate tests - if: always() - uses: guyarb/golang-test-annotations@v0.4.0 - with: - test-results: test.json + go test -v -coverprofile coverage.txt -covermode=atomic -parallel 8 -timeout 180m ./metal - name: Sweeper if: ${{ always() }} env: METAL_AUTH_TOKEN: ${{ secrets.PACKET_AUTH_TOKEN }} run: | - go test ./metal -v -json -sweep="tf_test" > sweep.json - - name: Annotate sweep - if: always() - uses: guyarb/golang-test-annotations@v0.4.0 - with: - test-results: sweep.json + go test ./metal -v -sweep="tf_test" - name: Upload coverage to Codecov + if: ${{ always() }} uses: codecov/codecov-action@v2 with: token: ${{ secrets.CODECOV_TOKEN }}