Commit cede2fe9 authored by Addshore's avatar Addshore 🏄
Browse files

Update to go 1.16

parent 44d74c2d
# Ignore everything
*
# But not these files:
!.gitignore
!*.mod
!README.md
!Variables.mk
!variables.env
*tmp.mod
# Project Development Dependencies.
This is directory which stores Go modules with pinned buildable package that is used within this repository, managed by https://github.com/bwplotka/bingo.
* Run `bingo get` to install all tools having each own module file in this directory.
* Run `bingo get <tool>` to install <tool> that have own module file in this directory.
* For Makefile: Make sure to put `include .bingo/Variables.mk` in your Makefile, then use $(<upper case tool name>) variable where <tool> is the .bingo/<tool>.mod.
* For shell: Run `source .bingo/variables.env` to source all environment variable for each tool.
* For go: Import `.bingo/variables.go` to for variable names.
* See https://github.com/bwplotka/bingo or -h on how to add, remove or change binaries dependencies.
## Requirements
* Go 1.14+
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.5.1. DO NOT EDIT.
# All tools are designed to be build inside $GOBIN.
BINGO_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
GOPATH ?= $(shell go env GOPATH)
GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin
GO ?= $(shell which go)
# Below generated variables ensure that every time a tool under each variable is invoked, the correct version
# will be used; reinstalling only if needed.
# For example for bingo variable:
#
# In your main Makefile (for non array binaries):
#
#include .bingo/Variables.mk # Assuming -dir was set to .bingo .
#
#command: $(BINGO)
# @echo "Running bingo"
# @$(BINGO) <flags/args..>
#
BINGO := $(GOBIN)/bingo-v0.5.1
$(BINGO): $(BINGO_DIR)/bingo.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/bingo-v0.5.1"
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=bingo.mod -o=$(GOBIN)/bingo-v0.5.1 "github.com/bwplotka/bingo"
GOLINT := $(GOBIN)/golint-v0.0.0-20210508222113-6edffad5e616
$(GOLINT): $(BINGO_DIR)/golint.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/golint-v0.0.0-20210508222113-6edffad5e616"
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=golint.mod -o=$(GOBIN)/golint-v0.0.0-20210508222113-6edffad5e616 "golang.org/x/lint/golint"
GOVVV := $(GOBIN)/govvv-v0.3.0
$(GOVVV): $(BINGO_DIR)/govvv.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/govvv-v0.3.0"
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=govvv.mod -o=$(GOBIN)/govvv-v0.3.0 "github.com/ahmetb/govvv"
GOX := $(GOBIN)/gox-v1.0.1
$(GOX): $(BINGO_DIR)/gox.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/gox-v1.0.1"
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=gox.mod -o=$(GOBIN)/gox-v1.0.1 "github.com/mitchellh/gox"
STATICCHECK := $(GOBIN)/staticcheck-v0.2.1
$(STATICCHECK): $(BINGO_DIR)/staticcheck.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/staticcheck-v0.2.1"
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=staticcheck.mod -o=$(GOBIN)/staticcheck-v0.2.1 "honnef.co/go/tools/cmd/staticcheck"
STATICFILES := $(GOBIN)/staticfiles-v0.0.0-20210106104248-dd04075d4104
$(STATICFILES): $(BINGO_DIR)/staticfiles.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/staticfiles-v0.0.0-20210106104248-dd04075d4104"
@cd $(BINGO_DIR) && $(GO) build -mod=mod -modfile=staticfiles.mod -o=$(GOBIN)/staticfiles-v0.0.0-20210106104248-dd04075d4104 "bou.ke/staticfiles"
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
go 1.16
require github.com/bwplotka/bingo v0.5.1
module _ // Fake go.mod auto-created by 'bingo' for go -moddir compatibility with non-Go projects. Commit this file, together with other .mod files.
\ No newline at end of file
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
go 1.16
require golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // golint
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
go 1.16
require github.com/ahmetb/govvv v0.3.0
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
go 1.16
require github.com/mitchellh/gox v1.0.1
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
go 1.16
require honnef.co/go/tools v0.2.1 // cmd/staticcheck
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
go 1.16
require bou.ke/staticfiles v0.0.0-20210106104248-dd04075d4104
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.5.1. DO NOT EDIT.
# All tools are designed to be build inside $GOBIN.
# Those variables will work only until 'bingo get' was invoked, or if tools were installed via Makefile's Variables.mk.
GOBIN=${GOBIN:=$(go env GOBIN)}
if [ -z "$GOBIN" ]; then
GOBIN="$(go env GOPATH)/bin"
fi
BINGO="${GOBIN}/bingo-v0.5.1"
GOLINT="${GOBIN}/golint-v0.0.0-20210508222113-6edffad5e616"
GOVVV="${GOBIN}/govvv-v0.3.0"
GOX="${GOBIN}/gox-v1.0.1"
STATICCHECK="${GOBIN}/staticcheck-v0.2.1"
STATICFILES="${GOBIN}/staticfiles-v0.0.0-20210106104248-dd04075d4104"
......@@ -40,10 +40,13 @@ test:
stage: test
needs: []
cache: {}
image: docker-registry.wikimedia.org/golang:1.13-3
image: golang:1.16.9
artifacts:
reports:
cobertura: coverage.xml
before_script:
- go get github.com/bwplotka/bingo
- bingo get
script:
- make test
- go get github.com/boumenot/gocover-cobertura
......@@ -53,12 +56,15 @@ checks:
stage: test
needs: []
cache: {}
image: docker-registry.wikimedia.org/golang:1.13-3
image: golang:1.16.9
parallel:
matrix:
- CHECK: lint
- CHECK: vet
- CHECK: staticcheck
before_script:
- go get github.com/bwplotka/bingo
- bingo get
script:
# XDG_CACHE_HOME is needed by staticcheck
- export XDG_CACHE_HOME=/tmp/mwcli-cache
......@@ -68,12 +74,15 @@ build:
stage: build
needs: []
cache: {}
image: docker-registry.wikimedia.org/golang:1.13-3
image: golang:1.16.9
artifacts:
paths:
- bin/
before_script:
- go get github.com/bwplotka/bingo
- bingo get
script:
- make
- make build
integration-general:
......@@ -114,10 +123,11 @@ build-release:
stage: release
needs: [build,integration-general,integration-docker]
cache: {}
image: docker-registry.wikimedia.org/golang:1.13-3
image: golang:1.16.9
before_script:
- go get github.com/bwplotka/bingo
- bingo get
script:
# Ideally make would not be needed, only release? But it is needed to install deps currently?
- make
- make release VERSION=${CI_COMMIT_TAG:-$CI_COMMIT_BRANCH}
release-build:
......@@ -126,13 +136,14 @@ release-build:
stage: release
needs: [build,integration-general,integration-docker]
cache: {}
image: docker-registry.wikimedia.org/golang:1.13-3
image: golang:1.16.9
artifacts:
paths:
- _release/
before_script:
- go get github.com/bwplotka/bingo
- bingo get
script:
# Ideally make would not be needed, only release? But it is needed to install deps currently?
- make
- make release VERSION=${CI_COMMIT_TAG:-$CI_COMMIT_BRANCH}
release-upload:
......
GOPATH=$(shell pwd)/vendor:$(shell pwd)
GOBIN=$(shell pwd)/bin
GONAME=mw
SHELL := /bin/bash
......@@ -13,71 +11,57 @@ SEMVER := $(subst v,,$(VERSION))
GO_LIST_GOFILES := '{{range .GoFiles}}{{printf "%s/%s\n" $$.Dir .}}{{end}}{{range .XTestGoFiles}}{{printf "%s/%s\n" $$.Dir .}}{{end}}'
GO_PACKAGES := $(shell go list ./...)
all: get-dev generate get build
include .bingo/Variables.mk
get:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get .
# Go 1.16 onwards includes a change that makes it possible to install a binary without affecting go.mod.
# https://stackoverflow.com/a/65734439/4746236
# TODO use this when we are running on Go 1.16 or later
get-dev: get-dev-govvv get-dev-gox get-dev-staticfiles get-dev-lint get-dev-staticcheck
get-dev-govvv:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get github.com/ahmetb/govvv@v0.3.0
get-dev-gox:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get github.com/mitchellh/gox@v1.0.1
get-dev-staticfiles:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get bou.ke/staticfiles@v0.0.0-20210106104248-dd04075d4104
get-dev-lint:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get golang.org/x/lint/golint
get-dev-staticcheck:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get honnef.co/go/tools/cmd/staticcheck
build: get-dev-govvv
.PHONY: build
build: $(GOVVV) generate
@echo "Building $(GOFILES) to ./bin"
GOPATH=$(GOPATH) GOBIN=$(GOBIN) go build -v -ldflags "$(shell ./bin/govvv -flags -version $(SEMVER))" -o bin/mw ./
go build -v -ldflags "$(shell $(GOVVV) -flags -version $(SEMVER))" -o bin/mw ./
release: get-dev-govvv
GOPATH=$(GOPATH) GOBIN=$(GOBIN) ./bin/gox -output="$(RELEASE_DIR)/$(SEMVER)/mw_$(VERSION)_{{.OS}}_{{.Arch}}" -osarch='$(TARGETS)' -ldflags '$(shell ./bin/govvv -flags -version $(SEMVER))' $(GO_PACKAGES)
.PHONY: release
release: $(GOX) $(GOVVV) generate
$(GOX) -output="$(RELEASE_DIR)/$(SEMVER)/mw_$(VERSION)_{{.OS}}_{{.Arch}}" -osarch='$(TARGETS)' -ldflags '$(shell $(GOVVV) -flags -version $(SEMVER))' $(GO_PACKAGES)
cp LICENSE "$(RELEASE_DIR)"
rm -f ./_release/latest/*.sha256
for f in "$(RELEASE_DIR)"/$(SEMVER)/mw_*; do \
shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256"; \
done
install: all
GOPATH=$(GOPATH) GOBIN=$(GOBIN) go install -v $(GO_PACKAGES)
.PHONY: generate
generate: generate-staticfiles
GOPATH=$(GOPATH) GOBIN=$(GOBIN) go generate $(GO_PACKAGES)
go generate $(GO_PACKAGES)
generate-staticfiles: get-dev-staticfiles
.PHONY: generate-staticfiles
generate-staticfiles: $(STATICFILES)
rm -f internal/mwdd/files/files.go || true
./bin/staticfiles -o internal/mwdd/files/files.go static/mwdd/
$(STATICFILES) -o internal/mwdd/files/files.go static/mwdd/
echo "//lint:file-ignore ST1005 It's generated code"|cat - internal/mwdd/files/files.go > internal/mwdd/files/files.go.tmp && mv internal/mwdd/files/files.go.tmp internal/mwdd/files/files.go
echo "//Package files ..."|cat - internal/mwdd/files/files.go > internal/mwdd/files/files.go.tmp && mv internal/mwdd/files/files.go.tmp internal/mwdd/files/files.go
.PHONY: clean
clean:
GOPATH=$(GOPATH) GOBIN=$(GOBIN) go clean $(GO_PACKAGES)
go clean $(GO_PACKAGES)
rm -rf bin || true
rm -rf _release || true
rm internal/mwdd/files/files.go || true
test: get-dev-govvv generate
GOPATH=$(GOPATH) GOBIN=$(GOBIN) go test -covermode=count -coverprofile "coverage.txt" -ldflags "$(shell ./bin/govvv -flags)" $(GO_PACKAGES)
.PHONY: test
test: $(GOVVV) generate
go test -covermode=count -coverprofile "coverage.txt" -ldflags "$(shell $(GOVVV) -flags)" $(GO_PACKAGES)
lint: get-dev-lint generate
.PHONY: lint
lint: $(GOLINT) generate
@echo > .lint-gofmt.diff
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go list -f $(GO_LIST_GOFILES) $(GO_PACKAGES) | while read f; do \
go list -f $(GO_LIST_GOFILES) $(GO_PACKAGES) | while read f; do \
gofmt -e -d "$${f}" >> .lint-gofmt.diff; \
done
@test -z "$(grep '[^[:blank:]]' .lint-gofmt.diff)" || (echo "gofmt found errors:"; cat .lint-gofmt.diff; exit 1)
GOPATH=$(GOPATH) GOBIN=$(GOBIN) ./bin/golint -set_exit_status $(GO_PACKAGES)
@$(GOLINT) -set_exit_status $(GO_PACKAGES)
.PHONY: generate
vet: generate
GOPATH=$(GOPATH) GOBIN=$(GOBIN) go vet -composites=false $(GO_PACKAGES)
staticcheck: get-dev-staticcheck generate
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) ./bin/staticcheck -version
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) ./bin/staticcheck -- ./...
go vet -composites=false $(GO_PACKAGES)
.PHONY: all get build release install generate generate-staticfiles clean test lint vet staticcheck
.PHONY: staticcheck
staticcheck: $(STATICCHECK) generate
$(STATICCHECK) -version
$(STATICCHECK) -- ./...
......@@ -15,12 +15,33 @@ Take a look at the user facing docs https://www.mediawiki.org/wiki/Cli
### Repo / Code setup
You need go 1.16+ installed.
This repository uses the `bingo` tool.
You can install it with:
```sh
go get github.com/bwplotka/bingo
```
Clone this repository to your `$GOPATH` (probably `~/go`), so it would be at
`~/go/src/gitlab.wikimedia.org/releng/cli`.
Within the `~/go/src/gitlab.wikimedia.org/releng/cli` directory:
Run `make` to build a binary to `~/go/src/gitlab.wikimedia.org/releng/cli/bin/mw`.
You can install allo tools used by this repository using bingo.
```sh
bingo get
```
You can then build a binary
```sh
make build
```
Which you will find at `~/go/src/gitlab.wikimedia.org/releng/cli/bin/mw`.
We recommend that you create a development alias for this binary, and run `make` after you make changes to the codebase.
......
module gitlab.wikimedia.org/releng/cli
require (
bou.ke/staticfiles v0.0.0-20210106104248-dd04075d4104
github.com/Microsoft/go-winio v0.5.0 // indirect
github.com/ahmetb/govvv v0.3.0
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38
github.com/alecthomas/chroma v0.9.2 // indirect
github.com/alecthomas/colour v0.1.0 // indirect
github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142 // indirect
github.com/blang/semver v3.5.1+incompatible
github.com/briandowns/spinner v1.16.0
github.com/containerd/containerd v1.5.5 // indirect
github.com/docker/docker v20.10.8+incompatible
github.com/containerd/containerd v1.5.7 // indirect
github.com/docker/docker v20.10.9+incompatible
github.com/docker/go-connections v0.4.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
......@@ -19,15 +17,16 @@ require (
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.0 // indirect
github.com/joho/godotenv v1.4.0
github.com/juju/ansiterm v0.0.0-20210706145210-9283cdf370b5 // indirect
github.com/juju/ansiterm v0.0.0-20210929141451-8b71cc96ebdc // indirect
github.com/manifoldco/promptui v0.8.0
github.com/mattn/go-colorable v0.1.11 // indirect
github.com/microcosm-cc/bluemonday v1.0.15 // indirect
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/profclems/glab v1.21.1
github.com/rhysd/go-github-selfupdate v1.2.3
github.com/rivo/tview v0.0.0-20210923051754-2cb20002bc4c // indirect
github.com/rivo/tview v0.0.0-20211001102648-5508f4b00266 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/spf13/cobra v1.2.1
github.com/txn2/txeh v1.3.0
......@@ -35,14 +34,15 @@ require (
github.com/xanzy/go-gitlab v0.51.1
github.com/yuin/goldmark v1.4.1 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/net v0.0.0-20210924151903-3ad01bbaa167 // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7 // indirect
golang.org/x/term v0.0.0-20210916214954-140adaaadfaf
golang.org/x/net v0.0.0-20211014222326-fd004c51d1d6 // indirect
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 // indirect
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0 // indirect
gopkg.in/ini.v1 v1.62.0
google.golang.org/genproto v0.0.0-20211015135405-485ec31e706e // indirect
google.golang.org/grpc v1.41.0 // indirect
gopkg.in/ini.v1 v1.63.2
)
go 1.13
go 1.15
This diff is collapsed.
// +build tools
package tools
import (
_ "bou.ke/staticfiles"
_ "github.com/ahmetb/govvv"
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment