-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dependencies, tooling and workflows (#20)
Add GitHub actions and get testing and linting running correctly.
- Loading branch information
Showing
15 changed files
with
183 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# Recursively finds all directories with a go.mod file and creates | ||
# a GitHub Actions JSON output option. This is used by the linter action. | ||
|
||
echo "Resolving modules in $(pwd)" | ||
|
||
PATHS=$( | ||
find . -type f -name go.mod -print0 \ | ||
| xargs -0 dirname \ | ||
| awk '{ printf "\"%s\",", $1; }' | ||
) | ||
echo "::set-output name=matrix::[${PATHS%?}]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: golangci-lint | ||
|
||
on: [pull_request] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
resolve-modules: | ||
name: resolve modules | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- id: set-matrix | ||
run: ./.github/tools/resolve-modules.sh | ||
lint: | ||
name: lint | ||
needs: resolve-modules | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
module: ${{ fromJson(needs.resolve-modules.outputs.matrix) }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.16 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v1.42 | ||
working-directory: ${{ matrix.module }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: run-tests | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
resolve-modules: | ||
name: resolve modules | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- id: set-matrix | ||
run: ./.github/tools/resolve-modules.sh | ||
test: | ||
name: test | ||
needs: resolve-modules | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
go: [ '1.16', '1.17', '1.18', '1.19' ] | ||
module: ${{ fromJson(needs.resolve-modules.outputs.matrix) }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ matrix.go }} | ||
- name: run-tests | ||
run: go test ./... -v -race -failfast -count 100 | ||
working-directory: ${{ matrix.module }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
PACKAGES = $(shell go list ./...) | ||
|
||
MODULES := $(shell find . -type f -name go.mod -print0 | xargs -0 dirname) | ||
|
||
.DEFAULT_GOAL := help | ||
.PHONY: help lint test | ||
|
||
help: | ||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-10s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | ||
|
||
lint: ## Run go vet and golangci-lint. | ||
go vet ./... || go clean ./...; go vet ./... && golangci-lint run ./... | ||
lint: $(patsubst %,%.lint,$(MODULES)) ## Runs go vet and golangci-lint. | ||
test: $(patsubst %,%.test,$(MODULES)) ## Run tests. | ||
|
||
%.lint: | ||
cd $* && go vet ./... && golangci-lint run ; | ||
|
||
test: ## Run tests. | ||
go test -short -v ./... -race; | ||
cd middleware && go test -short -v ./... -race; | ||
cd logrus && go test -short -v ./... -race; | ||
cd zerolog && go test -short -v ./... -race; | ||
%.test: | ||
cd $* && go test -short -v ./... -race; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.