Skip to content

Commit

Permalink
Setup GitHub actions, Go 1.21, minor tweaks
Browse files Browse the repository at this point in the history
* Use Go 1.21 for go.work and generator
* Tidy modules
* Ignore compiled generate command
* Ignore license on .yml files
* Add Go action and checks
* Add golangci-lint action
* Add badges to README.md
  • Loading branch information
codingllama committed Aug 12, 2023
1 parent 3bbe702 commit 1dd4948
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 26 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

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

jobs:

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

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.work
- run: go version

- name: Build
run: make build

- name: Test
run: make test

- name: Generate
run: make gen git/diff

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: ./... ./internal/cmd/generate/...

- run: go install github.com/google/addlicense@latest
- name: License
run: make lint/license

- name: go.mod
run: make fix/mod git/diff
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@

# Go workspace file
# go.work

/generate
19 changes: 0 additions & 19 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
# Copyright (c) 2023 Alan Parra
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

linters:
# Defaults, plus:
enable:
Expand Down
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ GOLANGCI-LINT ?= golangci-lint

# go install github.com/google/addlicense@latest
ADDLICENSE ?= addlicense
ADDLICENSE_FLAGS ?= -c 'Alan Parra' -l mit
ADDLICENSE_FLAGS ?= -c 'Alan Parra' -l mit -ignore '**/*.yml'

.PHONY: all
all: build

.PHONY: clean
clean:
rm -f cover.out
rm -f cover.out generate

.PHONY: check
check: test
Expand All @@ -50,8 +50,7 @@ lint: lint/go lint/license

.PHONY: lint/go
lint/go:
$(GOLANGCI-LINT) run ./...
cd ./internal/cmd/generate && $(GOLANGCI-LINT) run ./...
$(GOLANGCI-LINT) run ./... ./internal/cmd/generate/...

.PHONY: lint/license
lint/license:
Expand All @@ -73,6 +72,15 @@ fix/mod:
$(GO) mod tidy
cd ./internal/cmd/generate && $(GO) mod tidy

.PHONY: git/diff
git/diff:
@if [ -n "$$(git status --porcelain)" ]; then \
printf 'Local workspace has changes:\n\n' >&2; \
git status --porcelain >&2; echo; \
git diff >&2; \
exit 1; \
fi

.PHONY: cover
cover: cover/html

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# semerr
# semerr [![Go Reference][godoc-img]][godoc] ![Go][ci-img]

[godoc-img]: https://pkg.go.dev/badge/github.com/codingllama/semerr.svg
[godoc]: https://pkg.go.dev/github.com/codingllama/semerr
[ci-img]: https://github.com/codingllama/semerr/actions/workflows/go.yml/badge.svg

Semantic error wrappers for Go

Expand Down
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.20
go 1.21

use (
.
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/generate/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/codingllama/semerr/internal/cmd/generate

go 1.20
go 1.21

require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.2
Expand Down
3 changes: 3 additions & 0 deletions internal/cmd/generate/go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE=
github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.2 h1:dygLcbEBA+t/P7ck6a8AkXv6juQ4cK0RHBoh32jxhHM=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.2/go.mod h1:Ap9RLCIJVtgQg1/BBgVEfypOAySvvlcpcVQkSzJCH4Y=
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI=
Expand All @@ -16,6 +18,7 @@ golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 h1:Au6te5hbKUV8pIYWHqOUZ1pva5qK/rwbIhoXEUB9Lu8=
google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:O9kGHb51iE/nOGvQaDUuadVYqovW56s5emA88lQnj6Y=
google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e h1:z3vDksarJxsAKM5dmEGv0GHwE2hKJ096wZra71Vs4sw=
google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230726155614-23370e0ffb3e h1:S83+ibolgyZ0bqz7KEsUOPErxcv4VzlszxY+31OfB/E=
Expand Down

0 comments on commit 1dd4948

Please sign in to comment.