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
33 changes: 33 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Tests and linters

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Get go version
run: echo "GO_VERSION=$(make desired_go_version)" >> "${GITHUB_ENV}"
- uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
- run: make lint

unit-test:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v6
- name: Get go version
run: echo "GO_VERSION=$(make desired_go_version)" >> "${GITHUB_ENV}"
- uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
- run: make test
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@

# Goland
/.idea/
*.iml
*.iml

bin
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
SRC = $(shell find . -type f -name '*.go')
GOLANGCI_LINT_VERSION ?= v2.3.1
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

run: $(SRC)
@go run cmd/main.go

test: $(SRC)
@go test ./...

lint: $(SRC)
fmt: $(SRC)
@gofmt -s -l -w $^
@goimports -w $^
@golint ./...
@golangci-lint run --enable-all -D gomnd -D funlen ./...

lint: ## lint go code
echo "desired golangci-lint version is ${GOLANGCI_LINT_VERSION}"
@go mod download
test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
$(LOCALBIN)/golangci-lint --version
$(LOCALBIN)/golangci-lint run ./... --timeout 240s

clean:
@go clean -testcache

.PHONY: run test lint clean
.PHONY: run test lint clean

desired_go_version: ## get a desired go version from the Containerfile
@grep -o -P '(?<=go ).*' go.mod
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/db-operator/can-haz-password

go 1.17
go 1.25.0

require (
github.com/geozelot/intree v1.0.1
Expand Down
1 change: 1 addition & 0 deletions rand/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func TestCryptoRandomSource(t *testing.T) {

// If the point falls within the bounds of a circle (eg. a radius from a origin point).
// Then count that point as falling inside of the circle, as well as inside of the bounding box.
//nolint:all
if math.Pow(x, 2)+math.Pow(y, 2) <= 1.0 {
circle++
}
Expand Down