Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
gregito committed Aug 4, 2023
1 parent a802b9f commit b55fdaf
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 30 deletions.
135 changes: 109 additions & 26 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
issue_comment:
types:
- created
- edited
pull_request_review_comment:
types:
- created
- edited


jobs:
build:
name: Build
runs-on: ubuntu-latest
if: github.event.issue.pull_request && contains(github.event.comment.body, 'retest please')
timeout-minutes: 5

strategy:
Expand Down Expand Up @@ -43,46 +53,119 @@ jobs:
- name: Build
run: make build
lint:
name: 'Terraform Provider quality gate :: Code analysis.'
needs: build
runs-on: ubuntu-latest
if: github.event.issue.pull_request && contains(github.event.comment.body, 'retest please')
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
- name: Run linters
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
version: latest
args: --timeout 3m

test:
name: 'Terraform Provider Acceptance Tests (OS: ${{ matrix.os }} / TF: ${{ matrix.terraform }})'
needs: build
needs: lint
runs-on: ${{ matrix.os }}
if: github.event.issue.pull_request && contains(github.event.comment.body, 'retest please')
timeout-minutes: 15

strategy:
fail-fast: false
matrix:
os:
- macos-latest
- windows-latest
- ubuntu-latest
#- windows-latest
#- ubuntu-latest
terraform:
- '1.0.*'
- '1.1.*'
- '1.2.*'
- '1.3.*'
- '1.4.*'
#- '1.1.*'
#- '1.2.*'
#- '1.3.*'
#- '1.4.*'

steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'

- name: Setup Terraform ${{ matrix.terraform }}
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- name: Setup Terraform ${{ matrix.terraform }}
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false

- name: Run acceptance test
run: make testacc
- name: Go Coverage
uses: gwatts/[email protected]
with:
coverage-threshold: 5.7 # current (2023.08.03) state, should be increased - ideally up to at least 50% - as soon as possible
cover-pkg: ./...
ignore-pattern: |
/cdp-sdk-go/
/main.go$
- name: Run acceptance test
run: make testacc
coverage:
name: 'Terraform Provider quality gate :: unit test coverage.'
needs: test
runs-on: ubuntu-latest
if: github.event.issue.pull_request && contains(github.event.comment.body, 'retest please')
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
- name: Go Coverage
uses: gwatts/[email protected]
with:
coverage-threshold: 6.7 # current (2023.08.03) state, should be increased - ideally up to at least 50% - as soon as possible
#cover-pkg: ./...
# -----------------------

# test:
# name: 'Terraform Provider Acceptance Tests (OS: ${{ matrix.os }} / TF: ${{ matrix.terraform }})'
# needs: lint
# runs-on: ${{ matrix.os }}
# timeout-minutes: 15
#
# strategy:
# fail-fast: false
# matrix:
# os:
# - macos-latest
# - windows-latest
# - ubuntu-latest
# terraform:
# - '1.0.*'
# - '1.1.*'
# - '1.2.*'
# - '1.3.*'
# - '1.4.*'
#
# steps:
# - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
# - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
# with:
# go-version-file: 'go.mod'
#
# - name: Setup Terraform ${{ matrix.terraform }}
# uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
# with:
# terraform_version: ${{ matrix.terraform }}
# terraform_wrapper: false
#
# - name: Run acceptance test
# run: make testacc
# coverage:
# name: 'Terraform Provider quality gate :: unit test coverage.'
# needs: test
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
# - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
# with:
# go-version-file: 'go.mod'
# - name: Go Coverage
# uses: gwatts/[email protected]
# with:
# coverage-threshold: 6.7 # current (2023.08.03) state, should be increased - ideally up to at least 50% - as soon as possible
# #cover-pkg: ./...
13 changes: 9 additions & 4 deletions resources/datalake/resource_azure_datalake.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ import (
"context"
"time"

"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/cdp"
"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/datalake/client/operations"
datalakemodels "github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/datalake/models"
"github.com/cloudera/terraform-provider-cdp/utils"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/cdp"
"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/datalake/client/operations"
datalakemodels "github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/datalake/models"
"github.com/cloudera/terraform-provider-cdp/utils"
)

var (
Expand Down Expand Up @@ -362,3 +363,7 @@ func (r *azureDatalakeResource) Delete(ctx context.Context, req resource.DeleteR
return
}
}

func SomethingToTest(a int, b int) int {
return a + b
}
22 changes: 22 additions & 0 deletions resources/datalake/resource_azure_datalake_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2023 Cloudera. All Rights Reserved.
//
// This file is licensed under the Apache License Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
//
// This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
// OF ANY KIND, either express or implied. Refer to the License for the specific
// permissions and limitations governing your use of the file.

package datalake

import (
"fmt"
"testing"
)

func TestDummy(t *testing.T) {
//t.Errorf("Not even a dummy works ¯\\_(ツ)_/¯")
a := SomethingToTest(1, 2)
fmt.Println(a)
}

0 comments on commit b55fdaf

Please sign in to comment.