diff --git a/.github/workflows/lint-and-build-code.yml b/.github/workflows/lint-and-build-code.yml index bd890841..adbdaa67 100644 --- a/.github/workflows/lint-and-build-code.yml +++ b/.github/workflows/lint-and-build-code.yml @@ -20,79 +20,67 @@ name: Validate Codebase # `synchronized` seems to equate to pushing new commits to a linked branch # (whether force-pushed or not) on: + #push: pull_request: types: [opened, synchronize] jobs: - lint_and_build_code: - name: Lint and Build codebase - runs-on: ${{ matrix.os }} - # Default: 360 minutes + lint_code: + name: Lint codebase + runs-on: ubuntu-latest timeout-minutes: 10 - strategy: - matrix: - # Supported versions of Go - go-version: [1.13.x, 1.14.x] + container: + image: index.docker.io/atc0005/go-ci:go-ci-lint-only - # Supported LTS and latest version of Ubuntu Linux - #os: [ubuntu-16.04, ubuntu-18.04, ubuntu-latest] + steps: + - name: Check out code + uses: actions/checkout@v2.3.1 - # This should be good enough until we learn otherwise - os: [ubuntu-latest] + - name: Run golangci-lint using repo-provided config file settings + run: golangci-lint run -v - steps: - - name: Set up Go - # https://github.com/actions/setup-go - uses: actions/setup-go@v2.1.1 - with: - go-version: ${{ matrix.go-version }} - id: go + # This is the very latest stable version of staticcheck provided by the + # atc0005/go-ci container. The version included with golangci-lint often + # lags behind the official stable releases. + - name: Run staticcheck + run: staticcheck $(go list -mod=vendor ./... | grep -v /vendor/) - # This could prove useful if we need to troubleshoot odd results and - # tie them back to a specific version of Go - - name: Print go version - run: | - go version + test_code: + name: Run tests + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + matrix: + container-image: ["go-ci-oldstable", "go-ci-stable", "go-ci-unstable"] - - name: Check out code into the Go module directory - uses: actions/checkout@v2.3.1 + container: + image: "index.docker.io/atc0005/go-ci:${{ matrix.container-image}}" - # NOTE: Disabled in favor of top-level `vendor` folder - # - # - name: Get dependencies - # run: | - # go get -v -t -d ./... + steps: + - name: Check out code + uses: actions/checkout@v2.3.1 - # Force tests to run early as it isn't worth doing much else if the - # tests fail to run properly. - # Note: The `vendor` top-level folder appears to be skipped by default. - name: Run all tests run: go test -mod=vendor -v ./... - - name: Install Go linting tools - run: | - # add executables installed with go get to PATH - # TODO: this will hopefully be fixed by - # https://github.com/actions/setup-go/issues/14 - export PATH=${PATH}:$(go env GOPATH)/bin - make lintinstall + build_code: + name: Build codebase + runs-on: ubuntu-latest + # Default: 360 minutes + timeout-minutes: 10 + strategy: + matrix: + container-image: ["go-ci-oldstable", "go-ci-stable", "go-ci-unstable"] - - name: Install Ubuntu packages - if: contains(matrix.os, 'ubuntu') - run: sudo apt update && sudo apt install -y --no-install-recommends make gcc + container: + image: "index.docker.io/atc0005/go-ci:${{ matrix.container-image}}" - - name: Run Go linting tools using project Makefile - run: | - # add executables installed with go get to PATH - # TODO: this will hopefully be fixed by - # https://github.com/actions/setup-go/issues/14 - export PATH=${PATH}:$(go env GOPATH)/bin - make linting + steps: + - name: Print go version + run: go version - - name: Build with (mostly) default options - # Note: We use the `-mod=vendor` flag to explicitly request that our - # top-level vendor folder be used instead of fetching remote packages - run: go build -v -mod=vendor ./cmd/elbow + - name: Check out code + uses: actions/checkout@v2.3.1 - - name: Build using project Makefile - run: make all + - name: Build using vendored dependencies + run: go build -v -mod=vendor ./cmd/elbow diff --git a/Makefile b/Makefile index 3c80eeca..9356f04b 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,8 @@ # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html # https://www.gnu.org/software/make/manual/html_node/Recipe-Syntax.html#Recipe-Syntax # https://www.gnu.org/software/make/manual/html_node/Special-Variables.html#Special-Variables +# https://github.com/golangci/golangci-lint#install +# https://github.com/golangci/golangci-lint/releases/latest SHELL = /bin/bash @@ -45,10 +47,6 @@ TESTENVDIR2 = $(TESTENVBASEDIR)/path2 # https://github.com/atc0005/elbow/issues/54 VERSION = $(shell git describe --always --long --dirty) -# https://github.com/golangci/golangci-lint#install -# https://github.com/golangci/golangci-lint/releases/latest -GOLANGCI_LINT_VERSION = v1.25.1 - # The default `go build` process embeds debugging information. Building # without that debugging information reduces the binary size by around 28%. BUILDCMD = go build -mod=vendor -a -ldflags="-s -w -X $(VERSION_VAR_PKG).version=$(VERSION)" @@ -100,8 +98,8 @@ lintinstall: @echo "Explicitly enabling Go modules mode per command" (cd; GO111MODULE="on" go get honnef.co/go/tools/cmd/staticcheck) - @echo Installing golangci-lint ${GOLANGCI_LINT_VERSION} per official binary installation docs ... - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin ${GOLANGCI_LINT_VERSION} + @echo Installing latest stable golangci-lint version per official installation script ... + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin golangci-lint --version @echo "Finished updating linting tools" diff --git a/README.md b/README.md index 11d04909..730f948e 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ Elbow, Elbow grease. [![GoDoc](https://godoc.org/github.com/atc0005/elbow?status.svg)](https://godoc.org/github.com/atc0005/elbow) ![Validate Codebase](https://github.com/atc0005/elbow/workflows/Validate%20Codebase/badge.svg) ![Validate Docs](https://github.com/atc0005/elbow/workflows/Validate%20Docs/badge.svg) +![Lint and Build using Makefile](https://github.com/atc0005/elbow/workflows/Lint%20and%20Build%20using%20Makefile/badge.svg) +![Quick Validation](https://github.com/atc0005/elbow/workflows/Quick%20Validation/badge.svg) - [elbow](#elbow) - [Project home](#project-home)