Skip to content

Commit

Permalink
Add tic-testing directory for build/testing process
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhung committed May 21, 2024
1 parent 060145e commit 422ef50
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
terraform-provider-*
dist/
vendor/
bin/
.idea/
.github/
.modules/
Expand All @@ -13,5 +14,7 @@ lib/
/resources/
coverage.txt
.scannerwork

tfc-testing/.terraform
tfc-testing/terraform.d
tfc-testing/.terraform.lock.hcl
.DS_Store
22 changes: 21 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,21 @@ install: clean build
sed -i.bak '0,/version = ".*"/s//version = "${NEXT_VERSION}"/' sample.tf && rm sample.tf.bak && \
terraform init

install_tfc: clean build_tfc
mkdir -p tfc-testing/${BUILD_PATH} && \
mkdir -p tfc-testing/terraform.d/plugins/registry.terraform.io/jfrog/${PRODUCT}/${NEXT_VERSION}/linux_amd64 && \
mv -v dist/terraform-provider-${PRODUCT}_${GORELEASER_ARCH}/terraform-provider-${PRODUCT}_v${NEXT_VERSION}* tfc-testing/${BUILD_PATH} && \
mv -v dist/terraform-provider-${PRODUCT}_linux_amd64_v1/terraform-provider-${PRODUCT}_v${NEXT_VERSION}* tfc-testing/terraform.d/plugins/registry.terraform.io/jfrog/${PRODUCT}/${NEXT_VERSION}/linux_amd64 && \
sed -i.bak '0,/version = ".*"/s//version = "${NEXT_VERSION}"/' tfc-testing/sample.tf && rm tfc-testing/sample.tf.bak && \
cd tfc-testing && \
terraform providers lock -platform=linux_amd64 -platform=darwin_amd64 -fs-mirror=terraform.d/plugins && \
terraform init

clean:
rm -fR dist terraform.d/ .terraform terraform.tfstate* terraform.d/ .terraform.lock.hcl
rm -fR dist terraform.d/ .terraform terraform.tfstate* .terraform.lock.hcl

clean_tfc:
rm -fR dist tfc-testing/terraform.d/ tfc-testing/.terraform tfc-testing/terraform.tfstate* tfc-testing/.terraform.lock.hcl

release:
@git tag ${NEXT_VERSION} && git push --mirror
Expand All @@ -41,10 +54,17 @@ update_pkg_cache:
build: fmt
GORELEASER_CURRENT_TAG=${NEXT_VERSION} goreleaser build --single-target --clean --snapshot

build_tfc: fmt
GORELEASER_CURRENT_TAG=${NEXT_VERSION} goreleaser build --clean --snapshot --config tfc-testing/.goreleaser.yml

test:
@echo "==> Starting unit tests"
go test $(TEST) -timeout=30s -parallel=4

test_tfc: install_tfc
cd tfc-testing && \
terraform plan

attach:
dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient attach $$(pgrep terraform-provider-${PRODUCT})

Expand Down
27 changes: 27 additions & 0 deletions tfc-testing/.goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
before:
hooks:
# this is just an example and not a requirement for provider building/publishing
- go mod tidy
builds:
- env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
- CGO_ENABLED=0
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- '-s -w -X github.com/jfrog/terraform-provider-project/pkg/project/provider.Version={{.Version}}'
goos:
- linux
- darwin
goarch:
- amd64
ignore:
- goos: darwin
goarch: '386'
binary: '{{ .ProjectName }}_v{{ .Version }}'

34 changes: 34 additions & 0 deletions tfc-testing/sample.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
terraform {
cloud {
organization = "jfrog-partnership-engineering"
workspaces {
name = "alexh"
}
}

required_providers {
project = {
source = "jfrog/project"
version = "1.5.3"
}
}
}

provider "project" {
url = "https://partnership.jfrog.io"
oidc_provider_name = "terraform-cloud"
}

resource "project" "myproject" {
key = "myproj"
display_name = "My Project"
description = "My Project"
admin_privileges {
manage_members = true
manage_resources = true
index_resources = true
}
max_storage_in_gibibytes = 10
block_deployments_on_limit = false
email_notification = true
}

0 comments on commit 422ef50

Please sign in to comment.