Skip to content

Commit

Permalink
Incorporate terraform-provider-scaffolding (#107)
Browse files Browse the repository at this point in the history
* Test workflow

* Add registry manifest

* Remove CircleCI

* Pass secrets to workflow

* Update README.md

* Fix sentry_rule test

* Add goreleaser

* Upgrade Go packages

* Release workflow
  • Loading branch information
jianyuan authored Jan 2, 2022
1 parent 01c889a commit 17cb959
Show file tree
Hide file tree
Showing 10 changed files with 263 additions and 127 deletions.
38 changes: 0 additions & 38 deletions .circleci/config.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
#
# You will need to pass the `--batch` flag to `gpg` in your signing step
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
name: release
on:
push:
tags:
- "v*"
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Unshallow
run: git fetch --prune --unshallow

- uses: actions/setup-go@v2
with:
go-version: "1.17"

- name: Import GPG key
id: import_gpg
uses: hashicorp/[email protected]
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.PASSPHRASE }}

- name: Run GoReleaser
uses: goreleaser/[email protected]
with:
version: latest
args: release --rm-dist
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76 changes: 76 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# This GitHub action runs your tests for each commit push and/or PR. Optionally
# you can turn it on using a cron schedule for regular testing.
#
name: Tests
on:
pull_request:
paths-ignore:
- "README.md"
push:
paths-ignore:
- "README.md"
# We test at a regular interval to ensure we are alerted to something breaking due
# to an API change, even if the code did not change.
schedule:
- cron: "0 0 * * *"
jobs:
# ensure the code builds...
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/setup-go@v2
with:
go-version: "1.17"

- uses: actions/checkout@v2

- name: Get dependencies
run: |
go mod download
- name: Build
run: |
go build -v .
# run acceptance tests in a matrix with Terraform core versions
test:
name: Matrix Test
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:
- "0.12.*"
- "0.13.*"
- "0.14.*"
- "0.15.*"
- "1.0.*"
- "1.1.*"
steps:
- uses: actions/setup-go@v2
with:
go-version: "1.17"

- uses: hashicorp/setup-terraform@v1
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false

- uses: actions/checkout@v2

- name: Get dependencies
run: |
go mod download
- name: TF acceptance tests
timeout-minutes: 10
env:
SENTRY_TEST_ORGANIZATION: ${{ secrets.SENTRY_TEST_ORGANIZATION }}
SENTRY_TOKEN: ${{ secrets.SENTRY_TOKEN }}
run: |
make testacc
27 changes: 19 additions & 8 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ before:
- 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 main.version={{.Version}} -X main.commit={{.Commit}}"
goos:
- freebsd
- openbsd
- solaris
- windows
- linux
- darwin
Expand All @@ -22,28 +28,33 @@ builds:
ignore:
- goos: darwin
goarch: "386"
- goos: openbsd
goarch: arm
- goos: openbsd
goarch: arm64
binary: "{{ .ProjectName }}_v{{ .Version }}"
archives:
- format: zip
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
checksum:
extra_files:
- glob: "terraform-registry-manifest.json"
name_template: "{{ .ProjectName }}_{{ .Version }}_manifest.json"
name_template: "{{ .ProjectName }}_{{ .Version }}_SHA256SUMS"
algorithm: sha256
signs:
- artifacts: checksum
args:
# if you are using this in a GitHub action or some other automated pipeline, you
# need to pass the batch flag to indicate its not interactive.
- "--batch"
- "--local-user"
- "28C93998EF68D65A"
- "{{ .Env.GPG_FINGERPRINT }}"
- "--output"
- "${signature}"
- "--detach-sign"
- "${artifact}"
release:
# Visit your project's GitHub Releases page to publish this release.
extra_files:
- glob: "terraform-registry-manifest.json"
name_template: "{{ .ProjectName }}_{{ .Version }}_manifest.json"
# Manually examine the release before it goes live:
draft: true
changelog:
skip: true
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# terraform-provider-sentry

[![CircleCI](https://circleci.com/gh/jianyuan/terraform-provider-sentry/tree/master.svg?style=svg)](https://circleci.com/gh/jianyuan/terraform-provider-sentry/tree/master)
[![Go Report Card](https://goreportcard.com/badge/github.com/jianyuan/terraform-provider-sentry)](https://goreportcard.com/report/github.com/jianyuan/terraform-provider-sentry)

Terraform provider for [Sentry](https://sentry.io).
Expand All @@ -19,15 +18,15 @@ Pre-compiled binaries are available from the [Releases](https://github.com/jiany

## Development

If you wish to work on the provider, you will need to install [Go](https://go.dev/doc/install) (We use >= 1.17) on your machine.

### Test

Test the provider by running `make test`.
In order to run the full suite of acceptance tests, run `make testacc`.

Make sure to set the following environment variables:
Make sure to set the following environment variables beforehand:

- `SENTRY_TEST_ORGANIZATION`
- `SENTRY_TOKEN`

### Build

See the [Writing Custom Providers page of the Terraform documentation](https://www.terraform.io/docs/extend/writing-custom-providers.html#building-the-plugin) for instructions.
*Note:* Acceptance tests create real resources, and often cost money to run.
60 changes: 44 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,64 @@ module github.com/jianyuan/terraform-provider-sentry

replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999 // indirect

go 1.14
go 1.17

require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1
github.com/jianyuan/go-sentry v1.2.1-0.20201022193837-4bc7bd117d9d
github.com/mitchellh/mapstructure v1.4.3
)

require (
cloud.google.com/go v0.70.0 // indirect
cloud.google.com/go/storage v1.12.0 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-cidr v1.1.0 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/aws/aws-sdk-go v1.35.13 // indirect
github.com/dghubble/sling v1.3.0 // indirect
github.com/fatih/color v1.12.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dghubble/sling v1.4.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-hclog v0.16.2 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.4.2 // indirect
github.com/hashicorp/go-plugin v1.4.3 // indirect
github.com/hashicorp/go-uuid v1.0.2 // indirect
github.com/hashicorp/hcl/v2 v2.10.1 // indirect
github.com/hashicorp/terraform-plugin-go v0.3.1 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.0
github.com/hashicorp/yamux v0.0.0-20210826001029-26ff87cf9493 // indirect
github.com/jianyuan/go-sentry v1.2.1-0.20201022193837-4bc7bd117d9d
github.com/mattn/go-isatty v0.0.13 // indirect
github.com/hashicorp/go-version v1.3.0 // indirect
github.com/hashicorp/hc-install v0.3.1 // indirect
github.com/hashicorp/hcl/v2 v2.11.1 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.15.0 // indirect
github.com/hashicorp/terraform-json v0.13.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.5.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.2.1 // indirect
github.com/hashicorp/terraform-registry-address v0.0.0-20210816115301-cb2034eba045 // indirect
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.4.1
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/zclconf/go-cty v1.9.1 // indirect
golang.org/x/net v0.0.0-20210825183410-e898025ed96a // indirect
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/zclconf/go-cty v1.10.0 // indirect
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.5 // indirect
google.golang.org/api v0.33.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210830153122-0bac4d21c8ea // indirect
google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb // indirect
google.golang.org/grpc v1.43.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
)
Loading

0 comments on commit 17cb959

Please sign in to comment.