Skip to content

Commit

Permalink
Go unstable=1.19, stable=1.18, oldstable=1.17
Browse files Browse the repository at this point in the history
CHANGES

- each image type (`stable`, `unstable`, `oldstable`) has their own
  copy of the golangci-lint config file with the `stable` variants
  being given a copy of the via the Makefile build recipe
- each image type (`stable`, `unstable`, `oldstable`) is given a copy
  of the markdownlint config file via Makefile build recipe
- Makefile clean recipe updated to remove temporary copies of linter
	config files
- Makefile build recipe updated to limit copying of linter config
  files to just the images which use them
- `oldstable` image
  - explicitly specifies the Go version limit for golangci-lint as Go
    1.17
  - updated Go from `1.16.15` to `1.17.11`
- `unstable` image
  - explicitly specifies the Go version limit for golangci-lint as Go
    1.18 (for now)
  - updated Go from `1.18.3` to `1.19beta1`
- `stable` image
  - variants providing the golangci-lint linter explicitly specify the
    Go version limit for golangci-lint as Go 1.18
  - updated Go from `1.17.11` to `1.18.3`
- update README to drop compatibility notes regarding the `oldstable`
  image and older `staticcheck` version used for Go 1.16 compatibility
- update go.mod file to reflect current stable version of Go (1.18)
  with a note to update the version going forward

refs GH-557
refs GH-656
  • Loading branch information
atc0005 committed Jun 19, 2022
1 parent 626e49e commit 21f3137
Show file tree
Hide file tree
Showing 14 changed files with 210 additions and 58 deletions.
20 changes: 13 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ clean:
@echo
@echo "Pruning all dangling images"
@sudo docker image prune --force
@echo
@ echo "Removing temporary copies of linter config files"
@rm -vf {oldstable,unstable,stable/linting,stable/combined,stable/build/debian}/.markdownlint.yml
@rm -vf {stable/linting,stable/combined,stable/build/debian}/.golangci.yml

.PHONY: linting
## linting: lint all Dockerfiles
Expand All @@ -106,12 +110,12 @@ build:
@echo "Building Docker container images"

@echo "Bundle linter config files to provide baseline default settings"
@for version in {oldstable,unstable}; do cp -vf .markdownlint.yml $$version/; done
@for version in {stable/linting,stable/combined,stable/build/alpine-x64,stable/build/alpine-x86,stable/build/debian}; do cp -vf .markdownlint.yml $$version/; done
@for version in {oldstable,unstable,stable/linting,stable/combined,stable/build/debian}; do cp -vf .markdownlint.yml $$version/; done

# unstable container image has its own copy of this file
@cp -vf .golangci.yml oldstable/
@for version in {stable/linting,stable/combined,stable/build/alpine-x64,stable/build/alpine-x86,stable/build/debian}; do cp -vf .golangci.yml $$version/; done
# unstable container image has its own copy of the .golangci.yml file
# oldstable container image has its own copy of the .golangci.yml file
# stable container images share a copy of the .golangci.yml file
@for version in {stable/linting,stable/combined,stable/build/debian}; do cp -vf stable/.golangci.yml $$version/; done

@echo "List Docker version"
@docker version
Expand Down Expand Up @@ -223,10 +227,12 @@ build:
--label=$(DOCKER_IMAGE_CREATED_LABEL)

@echo "Remove temporary copies of bundled files"
@rm -vf {stable,oldstable,unstable}/.markdownlint.yml
@rm -vf {oldstable,unstable,stable/linting,stable/combined,stable/build/debian}/.markdownlint.yml

# unstable container image has its own copy of this file
@rm -vf {stable,oldstable}/.golangci.yml
# oldstable container image has its own copy of this file
# stable variants share a copy of this file
@rm -vf {stable/linting,stable/combined,stable/build/debian}/.golangci.yml

@echo "Finished building Docker container images"

Expand Down
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@ others.

## Linting tools included

| Linter | Version |
| --------------------------------------------------------------------- | -------------------------------------------------------- |
| [`staticcheck`](https://github.com/dominikh/go-tools) | `2022.1.2` (`v0.3.2`) for `unstable` and `stable` images |
| [`staticcheck`](https://github.com/dominikh/go-tools) | `2021.1.2` (`v0.2.2`) for `oldstable` image |
| [`golangci-lint`](https://github.com/golangci/golangci-lint) | `v1.46.2` |
| [`orijtech/httperroryzer`](https://github.com/orijtech/httperroryzer) | `v0.0.1` |
| [`orijtech/structslop`](https://github.com/orijtech/structslop) | `v0.0.6` |
| [`pelletier/go-toml`](https://github.com/pelletier/go-toml) | `v2.0.1` |
| [`fatih/errwrap`](https://github.com/fatih/errwrap) | `v1.4.0` |
| Linter | Version |
| --------------------------------------------------------------------- | --------------------- |
| [`staticcheck`](https://github.com/dominikh/go-tools) | `2022.1.2` (`v0.3.2`) |
| [`golangci-lint`](https://github.com/golangci/golangci-lint) | `v1.46.2` |
| [`orijtech/httperroryzer`](https://github.com/orijtech/httperroryzer) | `v0.0.1` |
| [`orijtech/structslop`](https://github.com/orijtech/structslop) | `v0.0.6` |
| [`pelletier/go-toml`](https://github.com/pelletier/go-toml) | `v2.0.1` |
| [`fatih/errwrap`](https://github.com/fatih/errwrap) | `v1.4.0` |

## Docker images

Expand Down
7 changes: 7 additions & 0 deletions .golangci.yml → oldstable/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ issues:
# golangci-lint/golangci-lint#413
exclude-use-default: false

run:
# Define the Go version limit.
# Mainly related to generics support in go1.18.
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.17
# https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml
go: "1.17"

# Reminder: Sort this after every change
linters:
enable:
Expand Down
7 changes: 1 addition & 6 deletions oldstable/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# https://hub.docker.com/_/golang

FROM golang:1.16.15
FROM golang:1.17.11

# https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package
LABEL org.opencontainers.image.source="https://github.com/atc0005/go-ci"
Expand Down Expand Up @@ -58,10 +58,5 @@ RUN apt-get update \
# default. Projects bringing their own config files (e.g., via GitHub Actions)
# can easily override these files, while projects choosing to use these config
# files exclusively can omit their copy.
#
# These files are copied from the root of this repo alongside this Dockerfile
# via Makefile `build` recipe. This allows for maintaining a single copy of
# either file in this repo vs each Dockerfile build "context" having their own
# separate copy.
COPY .markdownlint.yml /
COPY .golangci.yml /
125 changes: 125 additions & 0 deletions stable/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Copyright 2020 Adam Chalkley
#
# https://github.com/atc0005/go-ci
#
# Licensed under the MIT License. See LICENSE file in the project root for
# full license information.

###############################################################################
# NOTE: This is the golangci-lint configuration file *specific* to the
# "unstable" variant of the container images provided by this project. This
# configuration (potentially) enables additional linters not used by the other
# container image variants.
###############################################################################

issues:
# equivalent CLI flag: --exclude-use-default
#
# see:
# atc0005/todo#22
# atc0005/todo#29
# golangci-lint/golangci-lint#1249
# golangci-lint/golangci-lint#413
exclude-use-default: false

run:
# Define the Go version limit.
# Mainly related to generics support in go1.18.
# Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.17
# https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml
go: "1.18"

# Reminder: Sort this after every change
linters:
enable:
- depguard
- dogsled
- dupl
- exportloopref
- errcheck
- gochecknoglobals
- gocognit
- goconst
- gocritic
- gocyclo
- goerr113
- gofmt
- goimports
- gosec
- govet

# Deprecated linter, but still functional as of golangci-lint v1.39.0.
# See https://github.com/atc0005/go-ci/issues/302 for more information.
- maligned

- misspell
- prealloc
- revive
- staticcheck

# Incompatible with Go 1.18 (GH-568)
# https://github.com/golangci/golangci-lint/issues/2649
# - stylecheck
- unconvert

disable:
# Incompatible with Go 1.18 (GH-568)
# https://github.com/golangci/golangci-lint/issues/2649
- bodyclose
- contextcheck
- gosimple
- nilerr
- noctx
- rowserrcheck
- sqlclosecheck
- structcheck
- stylecheck
- tparallel
- unparam
- unused
- wastedassign

#
# Disable govet:fieldalignment, re-enable deprecated maligned linter until the
# Go team offers more control over the types of checks provided by the
# fieldalignment linter or golangci-lint does so.
#
# See https://github.com/atc0005/go-ci/issues/302 for more information.
#
# disable:
# - maligned

linters-settings:
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10

gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 15

govet:
enable-all: true
disable:
#
# Disable fieldalignment settings until the Go team offers more control over
# the types of checks provided by the fieldalignment linter or golangci-lint
# does so.
#
# See https://github.com/atc0005/go-ci/issues/302 for more information.
#
- fieldalignment

# Incompatible with Go 1.18 (GH-568)
# https://github.com/golangci/golangci-lint/issues/2649
- nilness
- unusedwrite

gocritic:
disable:
# Incompatible with Go 1.18 (GH-568)
# https://github.com/golangci/golangci-lint/issues/2649
- hugeParam
- rangeValCopy
- typeDefFirst
- paramTypeCombine
2 changes: 1 addition & 1 deletion stable/build/alpine-x64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# https://hub.docker.com/_/golang

FROM golang:1.17.11-alpine3.16
FROM golang:1.18.3-alpine3.16

# https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package
LABEL org.opencontainers.image.source="https://github.com/atc0005/go-ci"
Expand Down
2 changes: 1 addition & 1 deletion stable/build/alpine-x86/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# https://hub.docker.com/_/golang

FROM i386/golang:1.17.11-alpine3.16
FROM i386/golang:1.18.3-alpine3.16

# https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package
LABEL org.opencontainers.image.source="https://github.com/atc0005/go-ci"
Expand Down
18 changes: 11 additions & 7 deletions stable/build/debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# https://hub.docker.com/_/golang

FROM golang:1.17.11
FROM golang:1.18.3

# https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package
LABEL org.opencontainers.image.source="https://github.com/atc0005/go-ci"
Expand Down Expand Up @@ -59,14 +59,18 @@ RUN apt-get update \
&& go install github.com/fatih/errwrap@${ERRWRAP_VERSION} \
&& go clean -cache -modcache

# Copy over linting config files to root of container to serve as a default.
# Copy over linting config files to root of container image to serve as a
# default. The Makefile copies in these files as Docker requires that the
# source path for the files be inside the context of the build.
#
# From the official documentation:
#
# "you cannot COPY ../something /something, because the first step of a docker
# build is to send the context directory (and subdirectories) to the docker
# daemon.""
#
# Projects bringing their own config files (e.g., via GitHub Actions) can
# easily override these files, while projects choosing to use these config
# files exclusively can omit their copy.
#
# These files are copied from the root of this repo alongside this Dockerfile
# via Makefile `build` recipe. This allows for maintaining a single copy of
# either file in this repo vs each Dockerfile build "context" having their own
# separate copy.
COPY .markdownlint.yml /
COPY .golangci.yml /
2 changes: 1 addition & 1 deletion stable/build/mirror/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# https://hub.docker.com/_/golang

FROM golang:1.17.11
FROM golang:1.18.3

# https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package
LABEL org.opencontainers.image.source="https://github.com/atc0005/go-ci"
Expand Down
20 changes: 12 additions & 8 deletions stable/combined/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# https://hub.docker.com/_/golang

FROM golang:1.17.11
FROM golang:1.18.3

# https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package
LABEL org.opencontainers.image.source="https://github.com/atc0005/go-ci"
Expand Down Expand Up @@ -55,13 +55,17 @@ RUN apt-get update \
&& go clean -cache -modcache

# Copy over linting config files to root of container image to serve as a
# default. Projects bringing their own config files (e.g., via GitHub Actions)
# can easily override these files, while projects choosing to use these config
# files exclusively can omit their copy.
# default. The Makefile copies in these files as Docker requires that the
# source path for the files be inside the context of the build.
#
# From the official documentation:
#
# These files are copied from the root of this repo alongside this Dockerfile
# via Makefile `build` recipe. This allows for maintaining a single copy of
# either file in this repo vs each Dockerfile build "context" having their own
# separate copy.
# "you cannot COPY ../something /something, because the first step of a docker
# build is to send the context directory (and subdirectories) to the docker
# daemon.""
#
# Projects bringing their own config files (e.g., via GitHub Actions) can
# easily override these files, while projects choosing to use these config
# files exclusively can omit their copy.
COPY .markdownlint.yml /
COPY .golangci.yml /
22 changes: 13 additions & 9 deletions stable/linting/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# builder image
# use the same environment as our final image for binary compatibility
# FROM golangci/golangci-lint:v1.45.0-alpine as builder
FROM golang:1.17.11 as builder
FROM golang:1.18.3 as builder

ENV GOLANGCI_LINT_VERSION="v1.46.2"
ENV STATICCHECK_VERSION="v0.3.2"
Expand All @@ -30,7 +30,7 @@ RUN echo "Installing staticcheck@${STATICCHECK_VERSION}" \

# For CI "linting only" use
# FROM golangci/golangci-lint:v1.45.0-alpine
FROM golang:1.17.11 as final
FROM golang:1.18.3 as final

# https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package
LABEL org.opencontainers.image.source="https://github.com/atc0005/go-ci"
Expand All @@ -52,13 +52,17 @@ COPY --from=builder /go/bin/golangci-lint /usr/bin/golangci-lint
COPY --from=builder /go/bin/staticcheck /usr/bin/staticcheck

# Copy over linting config files to root of container image to serve as a
# default. Projects bringing their own config files (e.g., via GitHub Actions)
# can easily override these files, while projects choosing to use these config
# files exclusively can omit their copy.
# default. The Makefile copies in these files as Docker requires that the
# source path for the files be inside the context of the build.
#
# From the official documentation:
#
# These files are copied from the root of this repo alongside this Dockerfile
# via Makefile `build` recipe. This allows for maintaining a single copy of
# either file in this repo vs each Dockerfile build "context" having their own
# separate copy.
# "you cannot COPY ../something /something, because the first step of a docker
# build is to send the context directory (and subdirectories) to the docker
# daemon.""
#
# Projects bringing their own config files (e.g., via GitHub Actions) can
# easily override these files, while projects choosing to use these config
# files exclusively can omit their copy.
COPY .markdownlint.yml /
COPY .golangci.yml /
3 changes: 2 additions & 1 deletion tools/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module github.com/atc0005/go-ci/tools

go 1.15
// Use the current stable Go version
go 1.18

require (
// errwrap - provided as an optional linter
Expand Down

0 comments on commit 21f3137

Please sign in to comment.