Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vmyroslav authored May 1, 2024
0 parents commit 899172d
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Lint and Test
on:
push:
branches:
- main
pull_request:

env:
GO_VERSION: "1.22.x"

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: lint
uses: golangci/golangci-lint-action@v3

test:
name: test
needs: lint
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: Checkout code
uses: actions/checkout@v3

- name: Go cache
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}-cache
- name: Install Task
uses: arduino/setup-task@v1
with:
version: 3.x

- name: Test
run: task test
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/.DS_Store
/.idea/

/bin/*
/.env

/.serverless
/terraform/.terraform.lock.hcl
/terraform/.terraform/
/unit.coverprofile
/credentials.json
101 changes: 101 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
run:
go: '1.22'
timeout: 5m

linters-settings:
errcheck:
check-type-assertions: true
govet:
enable:
- fieldalignment
goconst:
min-len: 2
min-occurrences: 2
misspell:
locale: US
lll:
line-length: 140
gocritic:
enabled-tags:
- performance
- style
- experimental
- opinionated

linters:
disable-all: true
enable:
- bodyclose
- containedctx
- copyloopvar
- cyclop
- dogsled
- dupl
- errcheck
- errchkjson
- errname
- exhaustive
- exportloopref
- gas
- gci
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- gosec
- gosimple
- govet
- importas
- ineffassign
- interfacebloat
- loggercheck
- megacheck
- mirror
- misspell
- nakedret
- nestif
- noctx
- prealloc
- reassign
- revive
- sloglint
- staticcheck
- stylecheck
- tagliatelle
- tenv
- testifylint
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- whitespace
- wrapcheck
- wsl
fast: false

issues:
exclude-rules:
- text: "at least one file in a package should have a package comment"
linters:
- stylecheck
- text: "should have a package comment"
linters:
- revive
- text: "should have comment or be unexported"
linters:
- revive
- text: "whyNoLint"
linters:
- gocritic
- path: _test\.go
linters:
- gosec
- dupl
- cyclop
- govet
exclude-files:
- "mock_.+\\.go"
exclude-use-default: false
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
BUILD_DIR ?= out
VENDOR_DIR = vendor

GOLANGCI_LINT_VERSION ?= 1.55.1

GO ?= go
GOLANGCI_LINT ?= golangci-lint

all: clean
.PHONY: all

clean:
@rm -f ./bin/*

.PHONY: test
test: test-unit

## Run unit tests
.PHONY: test-unit
test-unit:
@echo ">> Unit test"
@$(GO) test -gcflags=-l -coverprofile=unit.coverprofile -covermode=atomic -race ./...

lint:
@echo ">> Linting"
@$(GOLANGCI_LINT) run
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[![Action Status](https://github.com/vmyroslav/go-template/actions/workflows/ci.yaml/badge.svg)](https://github.com/vmyroslav/go-template/actions/workflows/ci.yaml)

# Project

## List of useful commands:

* `task help` - shows the list of all available commands

### Prerequisites

- Go version 1.22 or later
- Taskfile for task running

### Installing

A step by step series of examples that tell you how to get a development environment running.
26 changes: 26 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3'

dotenv: ['.env'] # take variables from .env file

env:
OK_COLOR: '\033[32;01m'
NO_COLOR: '\033[0m'

tasks:
default:
cmds:
- task --list-all
lint:
cmds:
- golangci-lint run -c .golangci.yml
test:
cmds:
- go test -gcflags=-l -covermode=atomic -race ./...
update-deps:
desc: Update dependencies
cmds:
- go get -u -d ./...
fumpt:
desc: Gofumpt project files
cmds:
- find . -name '*.go' -type f -exec gofumpt -w {} +
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module home-bartender-back

go 1.22

require github.com/vmyroslav/home-lib v0.1.0 // indirect
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/vmyroslav/home-lib v0.0.0-20231113100224-567b61697473 h1:k26CnMh1z7duzbKO8Pvw/jXHmJ2+R5w4G5kmRfXC86c=
github.com/vmyroslav/home-lib v0.0.0-20231113100224-567b61697473/go.mod h1:+8aMxDeF9QZCA+r3lCnAd0o3V3oq7b5rTs5WhzNGTjE=
github.com/vmyroslav/home-lib v0.1.0 h1:rd7AHHcbH5eWveW3XDfLh+6gDY/604dmJl7CNGQHzgM=
github.com/vmyroslav/home-lib v0.1.0/go.mod h1:YqjLu07ymd+i53pztQXD43T8nrROg5CTe1eQyGTYbd8=
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("Hello, playground")
}

0 comments on commit 899172d

Please sign in to comment.