Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
root = true

# Unix-style newlines with a newline ending every file
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

# Set tabs at 4 spaces, primarily for GitHub
[*.go]
indent_style = tab
indent_size = 4

107 changes: 107 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# 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:
- "main.go"
- "forwardemail/**.go"
- "go.mod"
- "go.sum"
- ".github/workflows/test.yml"
push:
branches:
- main

permissions:
contents: read

jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: 'go.mod'
cache: true
- run: go mod tidy
- run: go mod download
- run: go build -v .

docs:
name: Docs Test
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
id: go
- name: Install Task
uses: arduino/setup-task@v2
with:
version: "3.x"
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_wrapper: false
- name: Check if docs are up-to-date
run: |
task docs
git diff
BADDOCS=$(git status --porcelain)
test -z "$BADDOCS" || (echo -e "documentation needs regenerating using task docs: $BADDOCS"; exit 1)

# Run acceptance tests in a matrix with Terraform CLI versions
test:
name: Terraform Provider Acceptance Tests
needs: build
runs-on: ubuntu-latest
concurrency:
group: test-${{ github.run_id }}
cancel-in-progress: false
timeout-minutes: 15
strategy:
fail-fast: false
max-parallel: 1
matrix:
terraform:
- '1.5.6'
- '1.6.0'
- '1.7.5'
- '1.8.2'
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
with:
go-version-file: 'go.mod'
cache: true
- name: Install Task
uses: arduino/setup-task@v2
with:
version: "3.x"
- name: Install Terraform
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false
- run: go mod download
- name: Run Acceptance Tests
env:
TF_ACC: "1"
FORWARDEMAIL_API_KEY: ${{ secrets.FORWARDEMAIL_API_KEY }}
run: go test -v ./forwardemail/...
timeout-minutes: 10
- name: Cleanup Dangling Resources
env:
TF_ACC: "1"
FORWARDEMAIL_API_KEY: ${{ secrets.FORWARDEMAIL_API_KEY }}
run: task sweep
timeout-minutes: 5
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ website/node_modules
*.winfile eol=crlf

terraform-provider-forwardemail

.task
168 changes: 132 additions & 36 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,139 @@
version: "2"
run:
deadline: 5m

tests: true
output:
formats:
text:
path: stderr
linters:
disable-all: true
enable:
#- bodyclose
# - deadcode ! deprecated since v1.49.0; replaced by 'unused'
#- depguard
#- dogsled
#- dupl
- errcheck
#- exhaustive
#- funlen
#- gochecknoinits
- goconst
- bodyclose
- err113
- forbidigo
- gocognit
- gocritic
#- gocyclo
- gofmt
- goimports
#- gomnd
#- goprintffuncname
- godot
- gosec
- gosimple
- govet
- ineffassign
#- lll
- importas
- loggercheck
- misspell
#- nakedret
#- noctx
- nolintlint
#- rowserrcheck
#- scopelint
- staticcheck
#- structcheck ! deprecated since v1.49.0; replaced by 'unused'
- stylecheck
#- typecheck
- nestif
- nilerr
- rowserrcheck
- tparallel
- unconvert
#- unparam
- unused
# - varcheck ! deprecated since v1.49.0; replaced by 'unused'
#- whitespace
fast: false
- unparam
- whitespace
settings:
gocognit:
min-complexity: 20
gocritic:
enabled-checks:
- commentedOutCode
- emptyDecl
- filepathJoin
- commentedOutImport
- initClause
- nestingReduce
- preferFilepathJoin
godot:
capital: true
period: true
gosec:
excludes:
- G101
importas:
alias:
- pkg: github.com/charmbracelet/log
alias: log
no-unaliased: true
no-extra-aliases: false
lll:
line-length: 120
tab-width: 4
loggercheck:
kitlog: false
klog: false
logr: false
slog: false
zap: false
require-string-key: true
no-printf-like: true
nestif:
min-complexity: 7
revive:
rules:
- name: banned-characters
arguments:
- goto
- name: error-strings
arguments:
- disallow-newlines: true
- name: file-length-limit
arguments:
- max: 500
skipBlankLines: true
skipComments: true
- name: function-length
arguments:
- 50
- 60
- name: cognitive-complexity
arguments:
- 25
- name: add-constant
arguments:
- allowFloats: 0.0,0.,1.0,1.,2.0,2.
allowInts: 0,1,2,3,4
allowStrs: '""'
maxLitCount: "3"
- name: argument-limit
arguments:
- 5
- name: deep-exit
- name: early-return
- name: comment-spacings
arguments:
- mypragma
- otherpragma
severity: warning
disabled: false
exclude:
- ""
- name: var-declaration
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- funlen
- revive
path: _test\.go$
paths:
- third_party$
- builtin$
- examples$
issues:
max-issues-per-linter: 0
max-same-issues: 0
formatters:
enable:
- gofumpt
- goimports
settings:
gofmt:
simplify: true
rewrite-rules:
- pattern: interface{}
replacement: any
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
- _test\.go$
16 changes: 4 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
repos:
- repo: local
hooks:
- id: gofumpt
name: gofumpt
entry: bash -c 'make fmt'
- id: prep
name: prepare terraform provider
entry: bash -c 'task prep -f'
language: system
types: ["go"]
files: main.go|cmd\/.*|internal\/.*
pass_filenames: false
- repo: local
hooks:
- id: rebuild-docs
name: rebuild-docs
entry: bash -c 'make docs'
language: system
files: cmd\/.*
files: main.go|forwardemail\/.*
pass_filenames: false
2 changes: 2 additions & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
brew "go"
brew "gofumpt"
brew "go-task"
brew "golangci-lint"
53 changes: 0 additions & 53 deletions Makefile

This file was deleted.

Loading