diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 87fc1b5..56da56c 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -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 diff --git a/.gitignore b/.gitignore index 8e647e8..a4ff1c6 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,7 @@ *.out tags + +bin/ + +profile.cov diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b376e70 --- /dev/null +++ b/Makefile @@ -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 diff --git a/go.mod b/go.mod index 5c78431..cbd58cf 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ module github.com/kinbiko/bugsnag -go 1.21 +go 1.22 require github.com/kinbiko/jsonassert v1.1.1