-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Creates mock generation infrastructure (#1763)
* use mockery * don't include test utilities in build * Revert "don't include test utilities in build" This reverts commit b41ba5e. * TEMPORARY: testing mock change detection * Revert "TEMPORARY: testing mock change detection" This reverts commit 0cbacbc. * centralize lint version in make file * fix call to mockery * timeout in linter * TEMPORARY - delete mock file * Revert "TEMPORARY - delete mock file" This reverts commit d171e9b. * use assert * TEMPORARY - failing unit test * Revert "TEMPORARY - failing unit test" This reverts commit 05ed39b. * use testify mock * change service name * use state * disable version mockery generated files * refactor response * responses in one line each * rename err * clarify file detection message * add info in contributing file * move timeout to config file * TEMPORARY - linter fail * Revert "TEMPORARY - linter fail" This reverts commit 5ef6390. * remove asdf comment * revert lint changes
- Loading branch information
Showing
7 changed files
with
181 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,22 +16,30 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: 'go.mod' | ||
- name: Mock generation | ||
run: make tools && mockery | ||
- name: Check for uncommited files | ||
run: | | ||
export FILES=$(git ls-files -o -m --directory --exclude-standard --no-empty-directory) | ||
export LINES=$(echo "$FILES" | awk 'NF' | wc -l) | ||
if [ $LINES -ne 0 ]; then | ||
echo "Detected files that need to be committed:" | ||
echo "$FILES" | sed -e "s/^/ /" | ||
echo "" | ||
echo "Mock skeletons are not up-to-date, you may have forgotten to run mockery before committing your changes." | ||
exit 1 | ||
fi | ||
- name: Build | ||
run: make build | ||
unit-test: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: 'go.mod' | ||
- name: Unit Test | ||
|
@@ -70,14 +78,11 @@ jobs: | |
uses: golangci/[email protected] | ||
with: | ||
version: v1.55.0 | ||
args: --timeout 10m | ||
website-lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: 'go.mod' | ||
- name: website lint | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
with-expecter: false | ||
disable-version-string: true | ||
dir: internal/testutil/mocksvc | ||
outpkg: mocksvc | ||
filename: "{{ .InterfaceName | snakecase }}.go" | ||
mockname: "{{.InterfaceName}}" | ||
|
||
packages: | ||
? github.com/mongodb/terraform-provider-mongodbatlas/internal/service/searchdeployment | ||
: interfaces: | ||
DeploymentService: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ VERSION=$(GITTAG:v%=%) | |
LINKER_FLAGS=-s -w -X 'github.com/mongodb/terraform-provider-mongodbatlas/version.ProviderVersion=${VERSION}' | ||
|
||
GOLANGCI_VERSION=v1.55.0 | ||
MOCKERY_VERSION=v2.38.0 | ||
|
||
export PATH := $(shell go env GOPATH)/bin:$(PATH) | ||
export SHELL := env PATH=$(PATH) /bin/bash | ||
|
@@ -74,6 +75,7 @@ tools: ## Install dev tools | |
go install github.com/terraform-linters/[email protected] | ||
go install github.com/rhysd/actionlint/cmd/actionlint@latest | ||
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest | ||
go install github.com/vektra/mockery/v2@$(MOCKERY_VERSION) | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin $(GOLANGCI_VERSION) | ||
|
||
.PHONY: check | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.