Skip to content

Commit

Permalink
chore: Bump Go version and add Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
kinbiko committed Jun 28, 2024
1 parent 1685620 commit 2bbdced
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 24 deletions.
52 changes: 29 additions & 23 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,46 @@
name: Go
on: [push]

jobs:
build:
name: Build
building:
name: Build and cache dependencies
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v1
uses: actions/setup-go@v3
with:
go-version: 1.21
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1

go-version: 1.22
cache: true
cache-dependency-path: go.sum
- name: Get dependencies
run: go get -v -t -d ./...

- name: Build
run: go build -v .

# Running tests with and without the race checker, as certain tests are
# only run when the race checker is not enabled
- name: Test
run: go test -v -coverprofile=profile.cov ./...

- name: Coverage
testing:
name: Run tests
needs: [building]
runs-on: ubuntu-latest
steps:
- name: Run tests and generate coverage
run: make coverage
- name: Report coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: profile.cov

testing-race:
name: Run tests with race checker
needs: [building]
runs-on: ubuntu-latest
steps:
- name: Test (race)
run: go test -race -v ./...

- name: Install Linter
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.53.2

- name: Lint
run: ./bin/golangci-lint run .
linting:
name:
runs-on: ubuntu-latest
needs: [building]
steps:
- name: Run linter
run: make lint
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@
*.out

tags

bin/

profile.cov
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
LINTER_VERSION := v1.59.1

.PHONY: all
all: clean bin/bugsnag lint test-race

.PHONY: test
test:
go test -count=1 -coverprofile=profile.cov ./...

.PHONY: test-race
test-race:
go test -count=1 -race ./...

.PHONY: clean
clean:
-rm -r ./bin

.PHONY: lint
lint: bin/linter
./bin/linter run ./...

.PHONY: dependencies
dependencies: go.mod go.sum
go get -v -t -d ./...

# Note: These next targets should not be PHONY

bin/bugsnag:
go build -o bin/bugsnag ./cmd/bugsnag

bin/linter: Makefile .golangci.yml
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin $(LINTER_VERSION)
mv ./bin/golangci-lint ./bin/linter
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/kinbiko/bugsnag

go 1.21
go 1.22

require github.com/kinbiko/jsonassert v1.1.1

0 comments on commit 2bbdced

Please sign in to comment.