Skip to content

Commit

Permalink
Add github workflows.
Browse files Browse the repository at this point in the history
  • Loading branch information
steveworley committed Sep 25, 2024
1 parent 497b873 commit c3d9a72
Show file tree
Hide file tree
Showing 12 changed files with 188 additions and 388 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @hashicorp/terraform-devex
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# See GitHub's documentation for more information on this file:
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Terraform Provider release workflow.
name: Release

# This GitHub action creates a release when a tag that matches the pattern
# "v*" (e.g. v0.1.0) is created.
on:
push:
tags:
- 'v*'

# Releases need permissions to read and write the repository contents.
# GitHub considers creating releases and uploading assets as writing contents.
permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
with:
# Allow goreleaser to access older tag information.
fetch-depth: 0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: 'go.mod'
cache: true
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@82a020f1f7f605c65dd2449b392a52c3fcfef7ef # v6.0.0
id: import_gpg
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
with:
args: release --clean
env:
# GitHub sets the GITHUB_TOKEN secret automatically.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
77 changes: 77 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Terraform Provider testing workflow.
name: Tests

# This GitHub action runs your tests for each pull request and push.
# Optionally, you can turn it on using a schedule for regular testing.
on:
pull_request:
paths-ignore:
- 'README.md'
push:
paths-ignore:
- 'README.md'

# Testing only needs permissions to read the repository contents.
permissions:
contents: read

jobs:
# Ensure project builds before running testing matrix
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: 'go.mod'
cache: true
- run: go mod download
- run: go build -v .
- name: Run linters
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
with:
version: latest

generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: 'go.mod'
cache: true
- run: go generate ./...
- name: git diff
run: |
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'go generate ./...' command and commit."; exit 1)
# Run acceptance tests in a matrix with Terraform CLI versions
test:
name: Terraform Provider Acceptance Tests
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# list whatever Terraform versions here you would like to support
terraform:
- '1.9.*'
steps:
- uses: actions/checkout # v4.1.0
- uses: actions/setup-go # v4.1.0
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- run: go mod download
- env:
TF_ACC: "1"
run: go test -v -cover ./internal/provider/
timeout-minutes: 10
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.22.1
require (
github.com/hashicorp/terraform-plugin-framework v1.10.0
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0
github.com/quantcdn/quant-admin-go v0.0.0-20240531233223-66fb14a9f0d3
github.com/quantcdn/quant-admin-go v0.0.0-20240909055315-7af0c1f67581
github.com/stretchr/testify v1.7.2
)

Expand Down
2 changes: 1 addition & 1 deletion internal/provider/crawler_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func callCrawlerReadAPI(ctx context.Context, r *crawlerResource, crawler *resour

api, _, err := r.client.Instance.CrawlersAPI.CrawlersRead(ctx, org, crawler.Project.ValueString(), crawler.Uuid.ValueString()).Execute()
if err != nil {
diags.AddError("Unable to load crawler", fmt.Sprintf("Error: ", err.Error()))
diags.AddError("Unable to load crawler", fmt.Sprintf("Error: %s", err.Error()))
return
}

Expand Down
21 changes: 0 additions & 21 deletions internal/provider/project_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,3 @@ func TestReadProject(t *testing.T) {
assert.Equal(t, "api-test", project.GetName())
assert.Equal(t, res.StatusCode, 200)
}

// func TestCreateProject(t *testing.T) {
// bearer := os.Getenv("QUANT_BEARER")

// cfg := openapi.NewConfiguration()
// client := openapi.NewAPIClient(cfg)
// ctx := context.WithValue(context.Background(), openapi.ContextAccessToken, bearer)

// req := *openapi.NewProjectRequestWithDefaults()
// req.SetName("tf test 7")

// p, res, err := client.ProjectsAPI.ProjectsCreate(ctx, "quant").ProjectRequest(req).Execute()

// t.Logf("Response: %v", res)

// if err != nil {
// t.Fatalf("unexpected error, %v", err)
// }

// t.Logf("Project: %v", p)
// }
51 changes: 0 additions & 51 deletions internal/provider/rule_auth_resource_test.go

This file was deleted.

49 changes: 0 additions & 49 deletions internal/provider/rule_custom_response_resource_test.go

This file was deleted.

53 changes: 0 additions & 53 deletions internal/provider/rule_header_resource_test.go

This file was deleted.

Loading

0 comments on commit c3d9a72

Please sign in to comment.