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 for linter #62

Merged
merged 1 commit into from
May 10, 2024
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
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI
on:
merge_group:
pull_request:
jobs:
golangci:
name: pull-nauti-golang-ci
env:
GOPATH: ${{ github.workspace }}
GO111MODULE: on
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}
strategy:
max-parallel: 3
## this will contain a matrix of all of the combinations
## we wish to test again:
matrix:
go-version: [ 1.21.x, 1.22.x ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
path: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}
- name: Cache go modules and build cache
uses: actions/[email protected]
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
${{ env.GOPATH }}/pkg/mod
${{ env.GOPATH }}/pkg/sumdb
~/.cache/go-build
~/Library/Caches/go-build
# %LocalAppData%\go-build
key: ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ matrix.os }}-go-
- name: Golang Lint
run: make lint
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ else
GOBIN=$(shell go env GOBIN)
endif

lint:
lint: golangci-lint
golangci-lint run -c .golangci.yaml --timeout=10m

ovnmaster:
Expand Down Expand Up @@ -55,3 +55,21 @@ images:
docker build -f ./build/ep-controller.Dockerfile ./ -t docker.io/airren/ep-controller:latest
docker push docker.io/airren/dedinic:v1.13.0-debug
docker push docker.io/airren/ep-controller:latest

# find or download golangci-lint
# download golangci-lint if necessary
golangci-lint:
ifeq (, $(shell which golangci-lint))
@{ \
set -e ;\
export GO111MODULE=on; \
GOLANG_LINT_TMP_DIR=$$(mktemp -d) ;\
cd $$GOLANG_LINT_TMP_DIR ;\
go mod init tmp ;\
go install github.com/golangci/golangci-lint/cmd/[email protected] ;\
rm -rf $$GOLANG_LINT_TMP_DIR ;\
}
GOLANG_LINT=$(shell go env GOPATH)/bin/golangci-lint
else
GOLANG_LINT=$(shell which golangci-lint)
endif
Loading