diff --git a/.github/workflows/build-test-deploy.yaml b/.github/workflows/build-test-deploy.yaml index aaa83179f..0849d49a8 100644 --- a/.github/workflows/build-test-deploy.yaml +++ b/.github/workflows/build-test-deploy.yaml @@ -22,30 +22,32 @@ concurrency: jobs: fail_if_pull_request_is_draft: if: github.event.pull_request.draft == true - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Fails in order to indicate that pull request needs to be marked as ready to review and unit tests workflow needs to pass. run: exit 1 test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: actions/setup-go@v5 with: go-version: "1.22" - - name: setup env run: | echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV echo "$(go env GOPATH)/bin" >> $GITHUB_PATH shell: bash - - - uses: actions/checkout@v4 - - - run: make test + - name: Run linters + run: make install-golangci-lint lint + - name: Run tests + run: make test test-integration: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/setup-go@v5 with: diff --git a/.github/workflows/license.yaml b/.github/workflows/license.yaml index 92a8048ff..9d61c6957 100644 --- a/.github/workflows/license.yaml +++ b/.github/workflows/license.yaml @@ -14,15 +14,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: 1.21 - - - name: Install Go deps - run: go mod download - - name: Install trivy run: | wget https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.deb diff --git a/.golangci.yaml b/.golangci.yaml index d2a992443..a80b6564c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -2,7 +2,7 @@ run: allow-parallel-runners: true - timeout: 30s + timeout: 10m linters: enable: diff --git a/Makefile b/Makefile index e85f845f6..02593d246 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ VERSION_PACKAGE = github.com/replicatedhq/troubleshoot/pkg/version VERSION ?=`git describe --tags --dirty` DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` RUN?="" +GOLANGCI_LINT_VERSION ?= "v1.61.0" GIT_TREE = $(shell git rev-parse --is-inside-work-tree 2>/dev/null) ifneq "$(GIT_TREE)" "" @@ -34,7 +35,8 @@ define LDFLAGS " endef -BUILDFLAGS = -tags "netgo containers_image_ostree_stub exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp" -installsuffix netgo +BUILDTAGS = "netgo containers_image_ostree_stub exclude_graphdriver_devicemapper exclude_graphdriver_btrfs containers_image_openpgp" +BUILDFLAGS = -tags ${BUILDTAGS} -installsuffix netgo BUILDPATHS = ./pkg/... ./cmd/... ./internal/... E2EPATHS = ./test/e2e/... TESTFLAGS ?= -v -coverprofile cover.out @@ -152,7 +154,7 @@ check-schemas: generate schemas fi .PHONY: schemas -schemas: fmt vet openapischema bin/schemagen +schemas: openapischema bin/schemagen ./bin/schemagen --output-dir ./schemas bin/schemagen: @@ -236,12 +238,16 @@ scan: ./ .PHONY: lint -lint: - golangci-lint run --new -c .golangci.yaml ${BUILDPATHS} +lint: vet + golangci-lint run --new -c .golangci.yaml --build-tags ${BUILDTAGS} ${BUILDPATHS} -.PHONY: fmt lint-and-fix -lint-and-fix: - golangci-lint run --new --fix -c .golangci.yaml ${BUILDPATHS} +.PHONY: lint-and-fix +lint-and-fix: fmt vet + golangci-lint run --new --fix -c .golangci.yaml --build-tags ${BUILDTAGS} ${BUILDPATHS} + +.PHONY: install-golangci-lint +install-golangci-lint: + go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} .PHONY: watch watch: npm-install