Skip to content

Commit fbbc3be

Browse files
authoredNov 23, 2022
Reduce number of places where go version is set (#17762) (#18099)
Reduce go version references to two: .go_version and @executors.yml.
·
1 parent 4d96205 commit fbbc3be

File tree

13 files changed

+77
-45
lines changed

13 files changed

+77
-45
lines changed
 

‎.circleci/config.yml

+28-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.circleci/config/commands/go_test.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ parameters:
1212
save_cache:
1313
type: boolean
1414
default: false
15-
go_image:
16-
type: string
17-
default: "docker.mirror.hashicorp.services/cimg/go:1.19.2"
1815
use_docker:
1916
type: boolean
2017
default: false
@@ -137,7 +134,7 @@ steps:
137134
-e NO_PROXY \
138135
-e VAULT_TEST_LOG_DIR=<< parameters.log_dir >> \
139136
--network ${TEST_DOCKER_NETWORK_NAME} \
140-
<< parameters.go_image >> \
137+
$GO_IMAGE \
141138
tail -f /dev/null)"
142139
mkdir workspace
143140
echo ${CONTAINER_ID} > workspace/container_id

‎.circleci/config/commands/setup-go.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ parameters:
1313
default: github.com/hashicorp/*
1414
steps:
1515
- run:
16-
working_directory: ~/
1716
name: Setup Go
1817
command: |
18+
GO_VERSION=$(cat .go-version)
1919
[ -n "$GO_VERSION" ] || { echo "You must set GO_VERSION"; exit 1; }
2020
# Install Go
21+
cd ~
2122
curl -sSLO "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz"
2223
sudo rm -rf /usr/local/go
2324
sudo tar -C /usr/local -xzf "go${GO_VERSION}.linux-amd64.tar.gz"
+15-18
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
go-machine:
2-
machine:
3-
image: ubuntu-2004:202201-02
4-
shell: /usr/bin/env bash -euo pipefail -c
5-
environment:
1+
references:
2+
environment: &ENVIRONMENT
63
CIRCLECI_CLI_VERSION: 0.1.5546 # Pin CircleCI CLI to patch version (ex: 1.2.3)
7-
GO_VERSION: 1.19.2 # Pin Go to patch version (ex: 1.2.3)
84
GOTESTSUM_VERSION: 0.5.2 # Pin gotestsum to patch version (ex: 1.2.3)
95
GOFUMPT_VERSION: 0.3.1 # Pin gofumpt to patch version (ex: 1.2.3)
106
GO_TAGS: ""
7+
GO_IMAGE: &GO_IMAGE "docker.mirror.hashicorp.services/cimg/go:1.19.2"
8+
9+
go-machine:
10+
machine:
11+
image: ubuntu-2004:202201-02
12+
environment: *ENVIRONMENT
13+
shell: /usr/bin/env bash -euo pipefail -c
1114
working_directory: /home/circleci/go/src/github.com/hashicorp/vault
1215
node:
1316
docker:
@@ -30,24 +33,18 @@ semgrep:
3033
docker-env-go-test-remote-docker:
3134
resource_class: medium
3235
docker:
33-
- image: "docker.mirror.hashicorp.services/cimg/go:1.19.2"
34-
environment:
35-
CIRCLECI_CLI_VERSION: 0.1.5546 # Pin CircleCI CLI to patch version (ex: 1.2.3)
36-
GO_TAGS: ""
36+
- image: *GO_IMAGE
37+
environment: *ENVIRONMENT
3738
working_directory: /home/circleci/go/src/github.com/hashicorp/vault
3839
docker-env-go-test:
3940
resource_class: large
4041
docker:
41-
- image: "docker.mirror.hashicorp.services/cimg/go:1.19.2"
42-
environment:
43-
CIRCLECI_CLI_VERSION: 0.1.5546 # Pin CircleCI CLI to patch version (ex: 1.2.3)
44-
GO_TAGS: ""
42+
- image: *GO_IMAGE
43+
environment: *ENVIRONMENT
4544
working_directory: /home/circleci/go/src/github.com/hashicorp/vault
4645
docker-env-go-test-race:
4746
resource_class: xlarge
4847
docker:
49-
- image: "docker.mirror.hashicorp.services/cimg/go:1.19.2"
50-
environment:
51-
CIRCLECI_CLI_VERSION: 0.1.5546 # Pin CircleCI CLI to patch version (ex: 1.2.3)
52-
GO_TAGS: ""
48+
- image: *GO_IMAGE
49+
environment: *ENVIRONMENT
5350
working_directory: /home/circleci/go/src/github.com/hashicorp/vault

‎.circleci/config/jobs/build-go-dev.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
executor: go-machine
22
steps:
3-
- setup-go
43
- checkout
4+
- setup-go
55
- restore_go_mod_cache
66
- attach_workspace:
77
at: .

‎.circleci/config/jobs/fmt.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
description: Ensure go formatting is correct.
22
executor: go-machine
33
steps:
4+
- checkout
45
# Setup Go enabling the proxy for downloading modules.
56
- setup-go:
67
GOPROXY: https://proxy.golang.org,direct
7-
- checkout
88
- run:
99
name: make fmt
1010
command: |

‎.circleci/config/jobs/pre-flight-checks.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
description: Ensure nothing obvious is broken, and pre-cache Go modules.
22
executor: go-machine
33
steps:
4+
- checkout
45
# Setup Go enabling the proxy for downloading modules.
56
- setup-go:
67
GOPROXY: https://proxy.golang.org,direct
7-
- checkout
88
- run:
99
name: Install CircleCI CLI
1010
environment:

‎.circleci/config/jobs/test-go-nightly.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
executor: go-machine
22
steps:
3-
- setup-go
43
- checkout
4+
- setup-go
55
- restore_go_mod_cache
66
- go_test:
77
log_dir: "/tmp/testlogs"
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Check Go version
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
jobs:
8+
go-version-check:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
with:
13+
ref: ${{ github.event.pull_request.head.sha }}
14+
fetch-depth: 0
15+
- name: Verify go versions in tree are consistent with one another
16+
run: |
17+
GOVER=$(cat .go-version)
18+
EXPECTED="docker.mirror.hashicorp.services/cimg/go:$GOVER"
19+
GOT=$(yq .references.environment.GO_IMAGE .circleci/config/executors/@executors.yml)
20+
if [ "$EXPECTED" != "$GOT" ]; then
21+
echo "version mismatch, .go-version has '$GOVER' and circleci config uses '$GOT'"
22+
exit 1
23+
fi

‎Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ GOFMT_FILES?=$$(find . -name '*.go' | grep -v pb.go | grep -v vendor)
1515
SED?=$(shell command -v gsed || command -v sed)
1616

1717

18-
GO_VERSION_MIN=1.19.2
18+
GO_VERSION_MIN=$$(cat $(CURDIR)/.go_version)
1919
PROTOC_VERSION_MIN=3.21.5
2020
GO_CMD?=go
2121
CGO_ENABLED?=0

‎README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ Developing Vault
7070
--------------------
7171

7272
If you wish to work on Vault itself or any of its built-in systems, you'll
73-
first need [Go](https://www.golang.org) installed on your machine. Go version
74-
1.19.2+ is *required*.
73+
first need [Go](https://www.golang.org) installed on your machine.
7574

7675
For local dev first make sure Go is properly installed, including setting up a
7776
[GOPATH](https://golang.org/doc/code.html#GOPATH). Ensure that `$GOPATH/bin` is in

‎scripts/docker/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Multi-stage builder to avoid polluting users environment with wrong
22
# architecture binaries.
3-
ARG VERSION=1.19.2
3+
ARG VERSION
44

55
FROM golang:${VERSION} AS builder
66

‎scripts/docker/Dockerfile.ui

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# architecture binaries. This file only currently works for linux/amd64.
33
FROM debian:buster AS builder
44

5-
ARG VERSION=1.19.2
5+
ARG VERSION
66
ARG CGO_ENABLED=0
77
ARG BUILD_TAGS
88
ENV JOBS=2

0 commit comments

Comments
 (0)
Please sign in to comment.