From b32890f67dfc6d9c801164c32ed886ae4729461a Mon Sep 17 00:00:00 2001 From: Thomas De Meyer Date: Tue, 7 May 2024 15:49:21 +0200 Subject: [PATCH] Added changie and workflows --- .changes/header.tpl.md | 6 + .changes/unreleased/.gitkeep | 0 .../unreleased/Added-20230915-152449.yaml | 3 + .changes/v0.2.0.md | 15 +++ .github/workflows/release.yaml | 33 +++++ .github/workflows/release.yml | 50 -------- .github/workflows/test.yml | 113 ------------------ .github/workflows/tests.yaml | 74 ++++++++++++ .gitignore | 3 + .vscode/launch.json | 33 ----- CHANGELOG.md | 8 ++ docs/resources/content_type.md | 2 +- 12 files changed, 143 insertions(+), 197 deletions(-) create mode 100644 .changes/header.tpl.md create mode 100644 .changes/unreleased/.gitkeep create mode 100644 .changes/unreleased/Added-20230915-152449.yaml create mode 100644 .changes/v0.2.0.md create mode 100644 .github/workflows/release.yaml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/test.yml create mode 100644 .github/workflows/tests.yaml delete mode 100644 .vscode/launch.json diff --git a/.changes/header.tpl.md b/.changes/header.tpl.md new file mode 100644 index 0000000..df8faa7 --- /dev/null +++ b/.changes/header.tpl.md @@ -0,0 +1,6 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), +and is generated by [Changie](https://github.com/miniscruff/changie). diff --git a/.changes/unreleased/.gitkeep b/.changes/unreleased/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.changes/unreleased/Added-20230915-152449.yaml b/.changes/unreleased/Added-20230915-152449.yaml new file mode 100644 index 0000000..76d2a6c --- /dev/null +++ b/.changes/unreleased/Added-20230915-152449.yaml @@ -0,0 +1,3 @@ +kind: Added +body: Updated to go 1.21 +time: 2023-09-15T15:24:49.507015744+02:00 diff --git a/.changes/v0.2.0.md b/.changes/v0.2.0.md new file mode 100644 index 0000000..7b62a97 --- /dev/null +++ b/.changes/v0.2.0.md @@ -0,0 +1,15 @@ +## 0.2.0 (2022-06-07) + + - Add the `contentstack_content_type` resource. + - Add the `contentstack_locale` resource. + + +## 0.1.1 (2022-06-03) + + - Add the `contentstack_global_field` resource. + + +## 0.1.0 (2022-06-03) + +Initial release of the contentstack terraform provider. It currently only +supports managing webhooks via the `contentstack_webhook` resource. diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..612af53 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,33 @@ +name: release +on: + workflow_dispatch: + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.21" + + - name: Import GPG key + id: import_gpg + uses: paultyng/ghaction-import-gpg@v2.1.0 + env: + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 40e0081..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,50 +0,0 @@ -# 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). -# -# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your -# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE` -# secret. If you would rather own your own GPG handling, please fork this action -# or use an alternative one for key handling. -# -# 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@v3 - - - name: Unshallow - run: git fetch --prune --unshallow - - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version-file: 'go.mod' - cache: true - - - name: Import GPG key - id: import_gpg - uses: hashicorp/ghaction-import-gpg@v2.1.0 - env: - # These secrets will need to be configured for the repository: - GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v3.0.0 - with: - version: latest - args: release --rm-dist - env: - GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} - # GitHub sets this automatically - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 2c45528..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,113 +0,0 @@ -# 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' - # For systems with an upstream API that could drift unexpectedly (like most SaaS systems, etc.), - # we recommend testing at a regular interval not necessarily tied to code changes. This will - # ensure you are alerted to something breaking due to an API change, even if the code did not - # change. - # schedule: - # - cron: '0 13 * * *' -jobs: - # ensure the code builds... - build: - name: Build - runs-on: ubuntu-latest - timeout-minutes: 5 - steps: - - - name: Check out code into the Go module directory - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version-file: 'go.mod' - cache: true - id: go - - - name: Get dependencies - run: | - go mod download - - - name: Run staticcheck - uses: dominikh/staticcheck-action@v1.0.0 - with: - version: "2022.1" - install-go: false - - - name: Build - run: | - go build -v . - - generate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - 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 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: - - - name: Check out code into the Go module directory - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version-file: 'go.mod' - cache: true - id: go - - - uses: hashicorp/setup-terraform@v2 - with: - terraform_version: ${{ matrix.terraform }} - terraform_wrapper: false - - - name: Get dependencies - run: | - go mod download - - - name: TF acceptance tests - timeout-minutes: 10 - env: - TF_ACC: "1" - - # Set whatever additional acceptance test env vars here. You can - # optionally use data from your repository secrets using the - # following syntax: - # SOME_VAR: ${{ secrets.SOME_VAR }} - - run: | - go test -v -cover ./internal/provider/ diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..2c78a41 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,74 @@ +# 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' + +jobs: + generate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + 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) + + test: + runs-on: ubuntu-latest + strategy: + matrix: + go: [ '1.18' ] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Go ${{ matrix.go }} + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go }} + + - name: golangci-lint + continue-on-error: true + uses: golangci/golangci-lint-action@v3 + with: + args: --issues-exit-code=0 --timeout=5m + + - name: Run tests + run: go test -race -coverprofile=coverage.out -covermode=atomic -coverpkg=./... -v ./... + + - name: Upload to codecov + uses: codecov/codecov-action@v3 + with: + verbose: true + + changie: + runs-on: ubuntu-latest + needs: test + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + permissions: + contents: write + pull-requests: write + actions: write + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Prepare release + uses: labd/changie-release-action@v0.2.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + release-workflow: 'release.yaml' + diff --git a/.gitignore b/.gitignore index 6d93fd6..bd70de6 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ /main.tf /terraform-provider-contentstack_* /terraform-provider-contentstack + +/.idea +/.vscode diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 9f07c45..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Acceptance Tests", - "type": "go", - "request": "launch", - "mode": "test", - // this assumes your workspace is the root of the repo - "program": "${fileDirname}", - "env": { - "TF_ACC": "1", - }, - "args": [], - }, - { - "name": "Debug - Attach External CLI", - "type": "go", - "request": "launch", - "mode": "debug", - // this assumes your workspace is the root of the repo - "program": "${workspaceFolder}", - "env": {}, - "args": [ - // pass the debug flag for reattaching - "-debug", - ], - } - ] -} diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b62a97..737b802 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), +and is generated by [Changie](https://github.com/miniscruff/changie). + + ## 0.2.0 (2022-06-07) - Add the `contentstack_content_type` resource. diff --git a/docs/resources/content_type.md b/docs/resources/content_type.md index e97211b..f7f18c2 100644 --- a/docs/resources/content_type.md +++ b/docs/resources/content_type.md @@ -85,11 +85,11 @@ JSON ### Required - `title` (String) -- `uid` (String) ### Optional - `description` (String) - `schema` (String) The schema as JSON. Use jsonencode(jsonecode()) to work around wrong changes. +- `uid` (String)