Skip to content

Commit

Permalink
Merge pull request #12 from invidian/updates
Browse files Browse the repository at this point in the history
Add CI and fix existing issues
  • Loading branch information
invidian committed Jan 31, 2022
2 parents bc43b7f + f19baed commit 7efaa45
Show file tree
Hide file tree
Showing 12 changed files with 323 additions and 128 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: CI
on:
pull_request:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
container: golangci/golangci-lint:v1.44.0
steps:
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/checkout@v2
with:
# Required for Codecov report uploading.
fetch-depth: 0
- run: make install-cc-test-reporter install-changelog BIN_PATH=/usr/local/bin
- run: make test-update-linters test-tidy test-changelog test-cover-upload lint
build-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/build-push-action@v2
codespell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: codespell-project/actions-codespell@master
with:
skip: .git,go.sum
ignore_words_list: decorder
check_filenames: true
check_hidden: true
semgrep:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Use dedicated action for nice integration with GitHub.
- uses: returntocorp/semgrep-action@v1
build-release:
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Generate GPG key
run: echo "GPG_FINGERPRINT=$(gpg --batch --passphrase '' --quick-gen-key USER_ID default default 2>&1 | grep 'marked as ultimately trusted' | cut -d' ' -f3)" >> $GITHUB_ENV
- uses: goreleaser/goreleaser-action@v2
with:
args: release --snapshot
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
terraform-provider-gpg*
/c.out
121 changes: 121 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
outpur:
sort-results: true

issues:
exclude-use-default: false
max-same-issues: 0
max-issues-per-linter: 0

linters-settings:
errcheck:
check-type-assertions: true
check-blank: true
gci:
local-prefixes: github.com/invidian/terraform-provider-gpg
godot:
capital: true
gofumpt:
extra-rules: true
govet:
enable-all: true
disable:
- fieldalignment
- shadow
makezero:
always: true
nolintlint:
allow-leading-space: false
require-explanation: true
require-specific: true
wsl:
force-err-cuddling: true

linters:
disable:
# Allow returning interface as a convention.
- ireturn
# Allow making use of zero-value of struct fields.
- exhaustivestruct
# Don't require API-compatible errors.
- goerr113
# This linter has been deprecated.
- golint
- interfacer
- maligned
enable:
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- cyclop
- deadcode
- decorder
- depguard
- dogsled
- dupl
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
- forbidigo
- forcetypeassert
- funlen
- gci
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- godox
- gofmt
- gofumpt
- goheader
- goimports
- gomnd
- gomoddirectives
- gomodguard
- goprintffuncname
- grouper
- ifshort
- importas
- ineffassign
- lll
- maintidx
- makezero
- misspell
- nakedret
- nestif
- nilerr
- nilnil
- nlreturn
- noctx
- nolintlint
- paralleltest
- prealloc
- predeclared
- promlinter
- revive
- rowserrcheck
- sqlclosecheck
- structcheck
- stylecheck
- tagliatelle
- tenv
- testpackage
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- varcheck
- varnamelen
- wastedassign
- whitespace
- wrapcheck
- wsl
25 changes: 25 additions & 0 deletions .semgrep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
rules:
- id: bad-error-wrap-wording
patterns:
- pattern-regex: fmt\.Errorf\(".?([Ff]ailed|[]Uu]nable|[Cc]ould|([Ee]rror))
message: Word "fail", "failed", "unable", "could not" should not be used when wrapping errors. Use verb in continuous form instead!
languages: [go]
severity: ERROR
- id: printed-messages-must-be-captialized
patterns:
- pattern-regex: (fmt.Print(ln|f)|\bt\.(Error|Fatal|Log)(|f))\("[a-z]
message: Printed messages must be capitalized.
languages: [go]
severity: ERROR
- id: strings-must-be-quoted-using-q
patterns:
- pattern-regex: "'%s'"
message: When formatting, strings must be quoted using %q instead of e.g. '%s'.
languages: [go]
severity: ERROR
- id: error-wrapping-must-be-preceded-by-space
patterns:
- pattern-regex: '[^ ]%w'
message: When wrapping errors, %w must be preceded by space.
languages: [go]
severity: ERROR
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

27 changes: 7 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,41 @@ 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/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.0] - 2020-08-19

## 0.3.0 - 2020-08-19
### Added

- This provider is now available via [Terraform Registry](https://registry.terraform.io/providers/invidian/gpg/latest).
- Added basic unit tests.

### Fixed

- Fixed `gpg_encrypted_message` resource destroying.
- Fixed found linter warnings.

### Changed

- Migrated to use Terraform Plugin SDK.
- Changelog is now published in [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format.
- Updated all dependencies to latest versions.

## [0.2.1] - 2019-06-20

### Fixed
- Fixed `gpg_encrypted_message` resource destroying.
- Fixed found linter warnings.

- Fixed `gpg_encrypted_message` resource update issues with Terraform 0.12.x.

## [0.2.1] - 2019-06-20
### Changed

- Sensitive fields now use `sensitive: true`, so they do not leak into Terraform plan.
- Resource `gpg_encrypted_message` now use SHA256 of message content as resource ID.

### Removed
### Fixed
- Fixed `gpg_encrypted_message` resource update issues with Terraform 0.12.x.

### Removed
- Removed use of `SchemaStateFunc` for result, as it has no effect with Terraform 0.12.x.

## [0.2.0] - 2019-06-15

### Added

- Added Terraform 0.12 compatibility.

### Changed

- Changed code to standard Terraform provider layout.
- Added `Makefile` to document common tasks.

## [0.1.0] - 2019-04-12

### Added

- Initial release

[0.2.1]: https://github.com/invidian/terraform-provider-gpg/compare/v0.2.0...v0.2.1
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.11-alpine
FROM golang:1.15-alpine

# Enable go modules
ENV GO111MODULE=on
Expand All @@ -7,12 +7,12 @@ ENV GO111MODULE=on
RUN apk add curl git build-base

# Install linter
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $HOME/bin v1.16.0
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $HOME/bin v1.44.0

# Copy go mod files first and install dependencies to cache this layer
ADD ./go.mod ./go.sum /go/src/terraform-provider-gpg/
WORKDIR /go/src/terraform-provider-gpg
RUN go get
RUN go mod download

# Add source code
ADD . /go/src/terraform-provider-gpg
Expand Down
Loading

0 comments on commit 7efaa45

Please sign in to comment.