Skip to content
Open
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
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.14
go-version-file: 'go.mod'
- 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.PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --rm-dist
args: release --clean
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76 changes: 76 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Tests

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

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

lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- name: Run gofmt
run: |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "Please run 'gofmt -s -w .' to format your code"
gofmt -s -l .
exit 1
fi
- name: Run go vet
run: go vet ./...

test:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- run: go mod download
- run: go test -v -short -timeout 120s ./...

acceptance:
name: Acceptance Tests
runs-on: ubuntu-latest
timeout-minutes: 60
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
env:
VO_API_ID: ${{ secrets.VO_API_ID }}
VO_API_KEY: ${{ secrets.VO_API_KEY }}
VO_BASE_URL: ${{ secrets.VO_BASE_URL }}
VO_REPLACEMENT_USERNAME: ${{ secrets.VO_REPLACEMENT_USERNAME }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- run: go mod download
- name: Run acceptance tests
if: env.VO_API_ID != ''
run: go test -v -timeout 120m ./victorops/...

70 changes: 32 additions & 38 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ TEST_COUNT?=1
default: build

build: fmtcheck
go build -o terraform-provider-victorops

install: build
go install

sweep:
Expand All @@ -19,60 +22,49 @@ test: fmtcheck
go test $(TEST) $(TESTARGS) -short -timeout=120s -parallel=4

testacc: fmtcheck
@echo "==> Running acceptance tests..."
@echo "Note: Set VO_API_ID, VO_API_KEY, VO_BASE_URL, and VO_REPLACEMENT_USERNAME for acceptance tests"
go test $(TEST) -v -count $(TEST_COUNT) -parallel 20 $(TESTARGS) -timeout 120m

fmt:
@echo "==> Fixing source code with gofmt..."
gofmt -s -w ./$(PKG_NAME)

# Currently required by tf-deploy compile
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
@echo "==> Checking source code formatting..."
@test -z "$$(gofmt -s -l ./$(PKG_NAME) | tee /dev/stderr)" || \
(echo; echo "Please run 'make fmt' to fix formatting"; exit 1)

vet:
@echo "==> Running go vet..."
@go vet ./...

depscheck:
@echo "==> Checking source code with go mod tidy..."
@go mod tidy
@git diff --exit-code -- go.mod go.sum || \
(echo; echo "Unexpected difference in go.mod/go.sum files. Run 'go mod tidy' command or revert any go.mod/go.sum changes and commit."; exit 1)
@echo "==> Checking source code with go mod vendor..."
@go mod vendor
@git diff --compact-summary --exit-code -- vendor || \
(echo; echo "Unexpected difference in vendor/ directory. Run 'go mod vendor' command or revert any go.mod/go.sum/vendor changes and commit."; exit 1)

docscheck:
@tfproviderdocs check
@misspell -error -source text CHANGELOG.md

lint:
lint: fmtcheck vet
@echo "==> Checking source code against linters..."
@golangci-lint run ./$(PKG_NAME)/...
@tfproviderlint \
-c 1 \
-S001 \
-S002 \
-S003 \
-S004 \
-S005 \
-S007 \
-S008 \
-S009 \
-S010 \
-S011 \
-S012 \
-S013 \
-S014 \
-S015 \
-S016 \
-S017 \
-S019 \
./$(PKG_NAME)
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run ./$(PKG_NAME)/...; \
else \
echo "golangci-lint not installed, skipping..."; \
fi

docs:
@echo "==> Generating documentation..."
@if command -v tfplugindocs >/dev/null 2>&1; then \
tfplugindocs generate; \
else \
echo "tfplugindocs not installed. Install with: go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest"; \
fi

tools:
GO111MODULE=on go install github.com/bflad/tfproviderlint/cmd/tfproviderlint
GO111MODULE=on go install github.com/bflad/tfproviderdocs
GO111MODULE=on go install github.com/client9/misspell/cmd/misspell
GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint
GO111MODULE=on go install github.com/katbyte/terrafmt
@echo "==> Installing development tools..."
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

test-compile:
@if [ "$(TEST)" = "./..." ]; then \
Expand All @@ -82,5 +74,7 @@ test-compile:
fi
go test -c $(TEST) $(TESTARGS)

.PHONY: build sweep test testacc fmt fmtcheck lint tools test-compile depscheck docscheck
clean:
rm -f terraform-provider-victorops

.PHONY: build install sweep test testacc fmt fmtcheck vet lint tools test-compile depscheck docs clean
Loading