Skip to content

Commit

Permalink
Added changie, taskfile and test flow
Browse files Browse the repository at this point in the history
  • Loading branch information
demeyerthom committed May 7, 2024
1 parent 4ef5ae2 commit e9e34f3
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 60 deletions.
6 changes: 6 additions & 0 deletions .changes/header.tpl.md
Original file line number Diff line number Diff line change
@@ -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).
Empty file added .changes/unreleased/.gitkeep
Empty file.
93 changes: 41 additions & 52 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Terraform Provider testing workflow.
# 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

# 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:
Expand All @@ -11,34 +10,12 @@ on:
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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
cache: true
- run: go mod download
- run: go build -v .
- name: Run linters
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
version: latest

generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
cache: true
Expand All @@ -48,34 +25,46 @@ jobs:
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.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
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3

- 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/[email protected]
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
github-token: ${{ secrets.GITHUB_TOKEN }}
release-workflow: 'release.yaml'
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.1.0 (Unreleased)
# Changelog
All notable changes to this project will be documented in this file.

FEATURES:
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).


No releases yet, this file will be updated when generating your first release.
6 changes: 0 additions & 6 deletions GNUmakefile

This file was deleted.

24 changes: 24 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3'

tasks:
format:
cmds:
- go fmt ./...

test:
cmds:
- go test -v ./...

docs:
cmds:
- go generate

coverage-html:
cmds:
- go test -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=./... ./...
- go tool cover -html=coverage.txt

coverage:
cmds:
- go test -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=./... ./...
- go tool cover -func=coverage.txt

0 comments on commit e9e34f3

Please sign in to comment.