Skip to content

Commit

Permalink
Megacommit: move to Go 1.16 and replace chezmoi with v2
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Feb 21, 2021
1 parent f9c7045 commit 27016cf
Show file tree
Hide file tree
Showing 452 changed files with 5,876 additions and 34,345 deletions.
9 changes: 6 additions & 3 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ env:
freebsd_12_task:
freebsd_instance:
image: freebsd-12-1-release-amd64
install_script: pkg install -y git go
build_script: go build -v ./...
test_script: go test -race ./...
install_script: |
pkg install -y git go
GOBIN=$PWD/bin go get golang.org/dl/go1.16
bin/go1.16 download
build_script: bin/go1.16 build -v ./...
test_script: bin/go1.16 test -race ./...
7 changes: 4 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# [Choice] Go version: 1, 1.15, 1.14
ARG VARIANT=1.14
FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT}
# FIXME remove dev- when 1.16 container is published
ARG VARIANT=dev-1.16
FROM mcr.microsoft.com/vscode/devcontainers/go:${VARIANT}

# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends acl musl-tools snapcraft
&& apt-get -y install --no-install-recommends acl musl-tools

# [Optional] Uncomment the next line to use go get to install anything else you need
RUN go get -x mvdan.cc/gofumpt
Expand Down
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

# Make GitHub language breakdown more accurate, see https://github.com/github/linguist
*.gen.go linguist-generated
chezmoi2/completions/* linguist-generated
completions/* linguist-generated
75 changes: 29 additions & 46 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15.x
go-version: 1.16.0
- name: Cache Go modules
if: runner.os != 'macos' # FIXME re-enable
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
Expand All @@ -42,7 +41,6 @@ jobs:
- name: Run
run: |
go run . --version
go run ./chezmoi2 --version
- name: Test
run: go test -race ./...
test-release:
Expand All @@ -55,7 +53,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15.x
go-version: 1.16.0
- name: Cache Go modules
uses: actions/cache@v2
with:
Expand All @@ -78,11 +76,6 @@ jobs:
./dist/chezmoi-cgo-glibc_linux_amd64/chezmoi --version | tee /dev/stderr | grep -q "chezmoi version v"
./dist/chezmoi-cgo-musl_linux_amd64/chezmoi --version | tee /dev/stderr | grep -q "chezmoi version v"
./dist/chezmoi-nocgo_linux_386/chezmoi --version | tee /dev/stderr | grep -q "chezmoi version v"
file ./dist/chezmoi2-cgo-glibc_linux_amd64/chezmoi2 | tee /dev/stderr | grep -q "dynamically linked"
file ./dist/chezmoi2-cgo-musl_linux_amd64/chezmoi2 | tee /dev/stderr | grep -q "statically linked"
./dist/chezmoi2-cgo-glibc_linux_amd64/chezmoi2 --version | tee /dev/stderr | grep -q "chezmoi2 version v"
./dist/chezmoi2-cgo-musl_linux_amd64/chezmoi2 --version | tee /dev/stderr | grep -q "chezmoi2 version v"
./dist/chezmoi2-nocgo_linux_386/chezmoi2 --version | tee /dev/stderr | grep -q "chezmoi2 version v"
- name: Artifact chezmoi-linux-amd64
uses: actions/upload-artifact@v2
with:
Expand All @@ -103,33 +96,13 @@ jobs:
with:
name: chezmoi-windows-amd64
path: dist/chezmoi-nocgo_windows_amd64/chezmoi.exe
- name: Artifact chezmoi2-linux-amd64
uses: actions/upload-artifact@v2
with:
name: chezmoi2-linux-amd64
path: dist/chezmoi2-cgo-glibc_linux_amd64/chezmoi2
- name: Artifact chezmoi2-linux-musl-amd64
uses: actions/upload-artifact@v2
with:
name: chezmoi2-linux-musl-amd64
path: dist/chezmoi2-cgo-musl_linux_amd64/chezmoi2
- name: Artifact chezmoi2-macos-amd64
uses: actions/upload-artifact@v2
with:
name: chezmoi2-macos-amd64
path: dist/chezmoi2-nocgo_darwin_amd64/chezmoi2
- name: Artifact chezmoi2-windows-amd64
uses: actions/upload-artifact@v2
with:
name: chezmoi2-windows-amd64
path: dist/chezmoi2-nocgo_windows_amd64/chezmoi2.exe
generate:
runs-on: ubuntu-18.04
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15.x
go-version: 1.16.0
- name: Cache Go modules
uses: actions/cache@v2
with:
Expand All @@ -141,25 +114,35 @@ jobs:
uses: actions/checkout@v2
- name: Generate
run: |
go generate
go generate ./chezmoi2
make completions
git diff --exit-code
lint:
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.36.0
- name: ShellCheck
uses: ludeeus/action-shellcheck@1.0.0
with:
scandir: ./assets/scripts
- name: Whitespace
run:
go run ./internal/cmd/lint-whitespace
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16.0
- name: Cache Go modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Checkout
uses: actions/checkout@v2
- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.37.0
- name: ShellCheck
uses: ludeeus/action-shellcheck@1.0.0
with:
scandir: ./assets/scripts
- name: Whitespace
run:
go run ./internal/cmd/lint-whitespace
release:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs:
Expand All @@ -176,7 +159,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15.x
go-version: 1.16.0
- name: Cache Go modules
uses: actions/cache@v2
with:
Expand Down
18 changes: 9 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ linters:
- depguard
- dogsled
- dupl
- durationcheck
- errcheck
- errorlint
- exhaustive
Expand All @@ -24,13 +25,15 @@ linters:
- gosec
- gosimple
- govet
- ifshort
- ineffassign
- interfacer
- makezero
- misspell
- noctx
- nolintlint
- prealloc
- predeclared
- revive
- rowserrcheck
- scopelint
- sqlclosecheck
Expand All @@ -47,6 +50,7 @@ linters:
disable:
- exhaustivestruct
- funlen
- ifshort # FIXME re-enable when bugs in ifshort are fixed
- gochecknoglobals
- gochecknoinits
- gocognit
Expand All @@ -60,15 +64,17 @@ linters:
- nakedret
- nestif
- nlreturn
- noctx
- nolintlint # FIXME re-enable
- paralleltest
- testpackage
- tparallel
- wrapcheck
- wsl

linters-settings:
forbidigo:
forbid:
- ^fmt\.Print.*$
- ^ioutil\.
gofumpt:
extra-rules: true
goimports:
Expand All @@ -81,12 +87,6 @@ issues:
- linters:
- goerr113
text: "do not define dynamic errors, use wrapped static errors instead"
- linters:
- dupl
path: "^cmd/secret(go)?pass\\.go$"
- linters:
- forbidigo
path: ^cmd/
- linters:
- forbidigo
- gosec
Expand Down
53 changes: 0 additions & 53 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,59 +52,6 @@ builds:
goarch: 386
- goos: linux
goarch: amd64
- id: chezmoi2-cgo-glibc
binary: chezmoi2
main: ./chezmoi2/main.go
env:
- CGO_ENABLED=1
goos:
- linux
goarch:
- amd64
- id: chezmoi2-cgo-musl
binary: chezmoi2
main: ./chezmoi2/main.go
env:
- CC=/usr/bin/musl-gcc
- CGO_ENABLED=1
goos:
- linux
goarch:
- amd64
ldflags:
- '-s'
- '-w'
- '-X main.version={{.Version}}'
- '-X main.commit={{.Commit}}'
- '-X main.date={{.Date}}'
- '-X main.builtBy=goreleaser'
- '-linkmode external'
- '--extldflags "-static"'
- id: chezmoi2-nocgo
binary: chezmoi2
main: ./chezmoi2/main.go
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- freebsd
- openbsd
- windows
goarch:
- 386
- amd64
- arm
- arm64
- ppc64
- ppc64le
goarm:
- ""
ignore:
- goos: darwin
goarch: 386
- goos: linux
goarch: amd64

archives:
- builds:
Expand Down
52 changes: 26 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
GOLANGCI_LINT_VERSION=1.36.0
GO?=go
GOLANGCI_LINT_VERSION=1.37.0

.PHONY: default
default: generate build run test lint format
default: build run test lint format

.PHONY: build
build: build-darwin build-linux build-windows

.PHONY: build-darwin
build-darwin: generate
GOOS=darwin GOARCH=amd64 go build -o /dev/null .
GOOS=darwin GOARCH=amd64 go build -o /dev/null ./chezmoi2
build-darwin:
GOOS=darwin GOARCH=amd64 $(GO) build -o /dev/null .
GOOS=darwin GOARCH=arm64 $(GO) build -o /dev/null .

.PHONY: build-linux
build-linux: generate
GOOS=linux GOARCH=amd64 go build -o /dev/null .
GOOS=linux GOARCH=amd64 go build -o /dev/null ./chezmoi2
build-linux:
GOOS=linux GOARCH=amd64 $(GO) build -o /dev/null .

.PHONY: build-windows
build-windows: generate
GOOS=windows GOARCH=amd64 go build -o /dev/null .
GOOS=windows GOARCH=amd64 go build -o /dev/null ./chezmoi2
build-windows:
GOOS=windows GOARCH=amd64 $(GO) build -o /dev/null .

.PHONY: run
run: generate
go run . --version
go run ./chezmoi2 --version

.PHONY: generate
generate:
go generate
go generate ./chezmoi2
run:
$(GO) run . --version

.PHONY: test
test: generate
go test ./...
test:
$(GO) test ./...

.PHONY: completions
completions:
$(GO) run . completion bash -o completions/chezmoi-completion.bash
$(GO) run . completion fish -o completions/chezmoi.fish
$(GO) run . completion powershell -o completions/chezmoi.ps1
$(GO) run . completion zsh -o completions/chezmoi.zsh

.PHONY: generate-install.sh
generate-install.sh:
go run ./internal/cmd/generate-install.sh > assets/scripts/install.sh
$(GO) run ./internal/cmd/generate-install.sh > assets/scripts/install.sh

.PHONY: lint
lint: ensure-golangci-lint generate
lint: ensure-golangci-lint
./bin/golangci-lint run
go run ./internal/cmd/lint-whitespace
$(GO) run ./internal/cmd/lint-whitespace

.PHONY: format
format: ensure-gofumports generate
format: ensure-gofumports
find . -name \*.go | xargs ./bin/gofumports -local github.com/twpayne/chezmoi -w

.PHONY: ensure-tools
Expand All @@ -55,7 +55,7 @@ ensure-tools: ensure-gofumports ensure-golangci-lint
ensure-gofumports:
if [ ! -x bin/gofumports ] ; then \
mkdir -p bin ; \
( cd $$(mktemp -d) && go mod init tmp && GOBIN=$(shell pwd)/bin go get mvdan.cc/gofumpt/gofumports ) ; \
GOBIN=$(shell pwd)/bin $(GO) install mvdan.cc/gofumpt/gofumports@latest ; \
fi

.PHONY: ensure-golangci-lint
Expand Down
Loading

0 comments on commit 27016cf

Please sign in to comment.