Skip to content

Commit

Permalink
Re-run go-makefile-maker
Browse files Browse the repository at this point in the history
  • Loading branch information
talal committed Sep 29, 2021
1 parent ae3cd40 commit 4eb7f2e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 33 deletions.
29 changes: 7 additions & 22 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CI
on:
"on":
pull_request:
branches:
- '*'
Expand All @@ -19,38 +19,27 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v2
with:
# Only a single commit is fetched by default, for the ref/SHA that
# triggered the workflow. We need `fetch-depth: 0` to fetch all
# history for all branches and tags.
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.16"
go-version: "1.17"
- name: Make build
run: GO_BUILDFLAGS='-mod vendor' make build-all

lint:
name: Lint
runs-on: ubuntu-latest
if: '!contains(github.event.head_commit.message, ''[ci skip]'')'
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.16"

go-version: "1.17"
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2
with:
skip-go-installation: true
version: latest

test:
name: Test
needs:
Expand All @@ -59,25 +48,21 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.16"

- name: Cache kubebuilder control plane binaries
go-version: "1.17"
- name: Cache envtest control plane binaries
uses: actions/cache@v2
with:
path: test/bin
key: ${{ runner.os }}-kubebuilder-${{ hashFiles('test/.kubebuilder-version') }}

key: ${{ runner.os }}-kubebuilder-${{ hashFiles('test/.envtest-version') }}
- name: Run tests and generate coverage report
run: GO_BUILDFLAGS='-mod vendor' make build/cover.out

- name: Upload coverage report to Coveralls
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_BRANCH: ${{ github.head_ref }}
run: |
GO111MODULE=off go get -u github.com/mattn/goveralls
go install github.com/mattn/goveralls@latest
goveralls -service=github -coverprofile=build/cover.out
4 changes: 2 additions & 2 deletions .github/workflows/license.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.16"
go-version: "1.17"
- name: Check if source code files have license header
run: |
GO111MODULE=off go get -u github.com/google/addlicense
go install github.com/google/addlicense@latest
find * \( -name vendor -type d -prune \) -o \( -name \*.go -exec addlicense --check -- {} + \)
23 changes: 14 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@
# Edit Makefile.maker.yaml instead. #
################################################################################

MAKEFLAGS=--warn-undefined-variables
# /bin/sh is dash on Debian which does not support all features of ash/bash
# to fix that we use /bin/bash only on Debian to not break Alpine
ifneq ($(shell grep -c debian /etc/os-release),0)
SHELL := /bin/bash
endif

default: build-all

VERSION := $(shell git describe --abbrev=7)
COMMIT_HASH := $(shell git rev-parse --verify HEAD)
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%S%Z")

GOOS = $(shell go env GOOS)
GOARCH = $(shell go env GOARCH)
KUBEBUILDER_RELEASE_VERSION = $(shell cat test/.kubebuilder-version)
ENVTEST_VERSION = $(shell cat test/.envtest-version)

test/bin:
@mkdir $@
# Download kubebuilder and extract it to tmp
curl -L https://go.kubebuilder.io/dl/$(KUBEBUILDER_RELEASE_VERSION)/$(GOOS)/$(GOARCH) | tar -xz -C /tmp/
# Move to test/bin
mv /tmp/kubebuilder*/bin/* test/bin/
# Download setup-envtest tool
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
# Download envtest
setup-envtest --bin-dir test/bin use $(ENVTEST_VERSION)

# attach `make test/bin` as a dependency to the autogenerated `make build/cover.out`
build/cover.out: test/bin
Expand Down Expand Up @@ -46,7 +51,7 @@ install: FORCE build/absent-metrics-operator
install -D -m 0755 build/absent-metrics-operator "$(DESTDIR)$(PREFIX)/bin/absent-metrics-operator"

# which packages to test with "go test"
GO_TESTPKGS := $(shell go list -f '{{if .TestGoFiles}}{{.ImportPath}}{{end}}' ./...)
GO_TESTPKGS := $(shell go list -f '{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPath}}{{end}}' ./...)
# which packages to measure coverage for
GO_COVERPKGS := $(shell go list ./...)
# to get around weird Makefile syntax restrictions, we need variables containing a space and comma
Expand Down Expand Up @@ -78,7 +83,7 @@ vendor: FORCE
go mod verify

license-headers: FORCE
@if ! hash addlicense 2>/dev/null; then printf "\e[1;36m>> Installing addlicense...\e[0m\n"; GO111MODULE=off go get -u github.com/google/addlicense; fi
@if ! hash addlicense 2>/dev/null; then printf "\e[1;36m>> Installing addlicense...\e[0m\n"; go install github.com/google/addlicense@latest; fi
find * \( -name vendor -type d -prune \) -o \( -name \*.go -exec addlicense -c "SAP SE" -- {} + \)

clean: FORCE
Expand Down

0 comments on commit 4eb7f2e

Please sign in to comment.