Skip to content

Commit

Permalink
update makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-swinkler committed Oct 25, 2023
1 parent 95eb2c7 commit f2a9518
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 42 deletions.
37 changes: 0 additions & 37 deletions .github/workflows/golanglint-ci.yml

This file was deleted.

File renamed without changes.
24 changes: 24 additions & 0 deletions .github/workflows/reviewdog-golanglint-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: golangci-lint
on:
push:
branches:
- main
pull_request:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: ./go.mod
cache: false
- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
18 changes: 18 additions & 0 deletions .github/workflows/reviewdog-staticcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: reviewdog
on: [pull_request]
jobs:
staticcheck:
name: runner / staticcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: ./go.mod
cache: false
- uses: reviewdog/action-staticcheck@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
filter_mode: nofilter
fail_on_error: true
8 changes: 8 additions & 0 deletions .reviewdog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
runner:
golangci:
cmd: golangci-lint run --out-format=line-number --timeout 5m
errorformat:
- '%E%f:%l:%c: %m'
- '%E%f:%l: %m'
- '%C%.%#'
level: warning
43 changes: 38 additions & 5 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@

default: build
default: install

help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-23s\033[0m %s\n", $$1, $$2}'

build:
go build -v ./...

install: build
go install -v ./...

mod: ## add missing and remove unused modules
go mod tidy -compat=1.20
.PHONY: mod

mod-check: mod ## check if there are any missing/unused modules
git diff --exit-code -- go.mod go.sum
.PHONY: mod-check

# See https://golangci-lint.run/
lint:
golangci-lint run
golangci-lint run ./... -v

lint-fix: ## Run static code analysis, check formatting and try to fix findings
golangci-lint run ./... -v --fix
.PHONY: lint-fix

pre-push: fmt lint mod docs ## Run a few checks before pushing a change (docs, fmt, mod, etc.)

pre-push-check: docs-check lint-check mod-check; ## Run a few checks before pushing a change (docs, fmt, mod, etc.)
.PHONY: pre-push

fmt: ## Run gofumpt
@echo "==> Fixing source code with gofumpt..."
Expand All @@ -18,14 +38,18 @@ fmt: ## Run gofumpt
fumpt: fmt

test:
go test -v -cover -timeout=120s -parallel=4 ./...
go test -v -cover -timeout=30m -parallel=4 ./...

testacc:
TF_ACC=1 go test -v -cover -timeout 120m ./...
TF_ACC=1 go test -v -cover -timeout 30m -parallel=4 ./...

docs:
go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate

docs-check: docs ## check that docs have been generated
git diff --exit-code -- docs
.PHONY: docs-check

# Generate docs, terraform fmt the examples folder, and create copywrite headers
generate:
cd tools && go generate ./...
Expand Down Expand Up @@ -58,4 +82,13 @@ clean-generator-%: ## Clean generated files for specified resource
rm -f ./internal/sdk/$**_gen.go
rm -f ./internal/sdk/$**_gen_*test.go

.PHONY: build install lint generate fmt test testacc tools docs
sweep: ## destroy the whole architecture; USE ONLY FOR DEVELOPMENT ACCOUNTS
@echo "WARNING: This will destroy infrastructure. Use only in development accounts."
@echo "Are you sure? [y/n]" >&2
@read -r REPLY; \
if echo "$$REPLY" | grep -qG "^[yY]$$"; then \
SNOWFLAKE_ENABLE_SWEEP=1 go test -timeout 300s -run ^TestSweepAll ./pkg/sdk -v; \
else echo "Aborting..."; \
fi;

.PHONY: build install lint generate fmt test testacc tools docs sweep

0 comments on commit f2a9518

Please sign in to comment.