Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add github action workflow files and linter settings #11

Merged
merged 1 commit into from
Dec 15, 2022
Merged
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
34 changes: 34 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 🔨 Build And Test

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:

build:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can rename it to ci, and also rename this file

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

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Install dependencies
run: go get .

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50
args: -c .golangci.yml -v

- name: Build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need it

run: go build -v ./...

- name: Test
run: go test -v ./...
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 🎉 Release

on:
pull_request:
push:
tags:
- 'v*.*.*'

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40 changes: 40 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
linters-settings:
lll:
line-length: 140
funlen:
lines: 70

linters:
disable-all: true
enable:
- bodyclose
- depguard
- errcheck
- dupl
- exhaustive
- funlen
- goconst
- gocritic
- gocyclo
- revive
- gosimple
- govet
- gosec
- ineffassign
- lll
- misspell
- nakedret
- gofumpt
- nolintlint
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- whitespace
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add these:

    - staticcheck
    - typecheck
    - varcheck
    - structcheck
    - vet
    - vetshadow


service:
golangci-lint-version: 1.50.x # use the fixed version to not introduce new linters unexpectedly
prepare:
- echo "here I can run custom commands, but no preparation needed for this repo"
49 changes: 49 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
env:
- CGO_ENABLED=0
- GOFLAGS=-mod=vendor
- GO111MODULE=auto

before:
hooks:
- go mod download
- go mod vendor

builds:
- id: binary
main: ./example/main.go
goos:
- linux
- darwin
- windows
goarch:
- amd64
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=GoReleaser

archives:
- builds:
- binary
replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: x86
amd64: x86_64
format_overrides:
- goos: windows
format: zip
files: ["README.md"]

checksum:
name_template: 'checksums.txt'
algorithm: sha256

snapshot:
name_template: "{{ .Tag }}-next"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package godcpclient
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This project will be used as a package, so we don't need to main.go


import "fmt"

func main() {
fmt.Print("Hello world")
}