Skip to content

Commit

Permalink
Merge pull request #47 from frauniki/add-test-ci
Browse files Browse the repository at this point in the history
Add test ci
  • Loading branch information
frauniki authored Jan 9, 2024
2 parents 369d631 + e822751 commit c831df4
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/image-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
PLATFORMS: linux/amd64,linux/arm64

jobs:
server-image-build:
build:
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Go test

on:
push:
branches: [main]
tags:
- v*
pull_request_target:
types: [opened, reopened, synchronize]

jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
go-version: "1.21"

- name: Run tests
run: go test ./...

golangci-lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
go-version: "1.21"

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.55
args: --timeout=5m
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/*
examples/samples
cover.out
bin/
5 changes: 5 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
linters:
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- goimports
21 changes: 15 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ GO_FILES:=$(shell find . -type f -name '*.go' -print)

.PHONY: build build_all clean

fmt:
go fmt ./...
lint: golangci-lint
$(GOLANGCI_LINT) run

vet:
go vet ./...

test: fmt vet
test: lint
go test ./... -coverprofile cover.out

build_all: $(BUILD_TARGETS)
Expand All @@ -56,3 +53,15 @@ $(BINARIES): $(GO_FILES)

clean:
rm $(BINARIES)*

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

## Tool Binaries
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint

golangci-lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

0 comments on commit c831df4

Please sign in to comment.