From 83cf380596881f77ab0fe35f3d8305973475f3e2 Mon Sep 17 00:00:00 2001 From: Casey Waldren Date: Thu, 11 Jul 2024 11:11:26 -0700 Subject: [PATCH] fix(deps): use consistent Go version in builds and CI (#377) * fix(deps): use consistent Go version in builds and CI * change go version in go.mod to go 1.21 --- .github/variables/go-versions.env | 4 +-- .github/workflows/go-versions.yml | 49 ++++++++++++++++++++++++++++ .github/workflows/go.yml | 10 +++++- .github/workflows/manual-publish.yml | 9 +++++ .github/workflows/release-please.yml | 10 +++++- go.mod | 2 +- go.sum | 9 +++++ 7 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/go-versions.yml diff --git a/.github/variables/go-versions.env b/.github/variables/go-versions.env index fb1f664f..ad4de46b 100644 --- a/.github/variables/go-versions.env +++ b/.github/variables/go-versions.env @@ -1,2 +1,2 @@ -latest=1.22.1 -penultimate=1.21.8 \ No newline at end of file +latest=1.22.5 +penultimate=1.21.12 diff --git a/.github/workflows/go-versions.yml b/.github/workflows/go-versions.yml new file mode 100644 index 00000000..7bb5c99f --- /dev/null +++ b/.github/workflows/go-versions.yml @@ -0,0 +1,49 @@ +# The following chunk of yml boils down to pulling two Go version numbers out of a file and +# making them available to the other workflows in a convenient fashion. +# +# It's a reusable workflow instead of an action so that its output can be used in a matrix strategy +# of another job. +# +# The idea is to define the most recent, and penultimate, Go versions that should be used to test Relay. +# Ideally we'd define these in a single place - otherwise we'd need to update many different places in +# each workflow. This single place is .github/variables/go-versions.env. +# +# This reusable workflow grabs them out of the file, then sets them as outputs. As a convenience, it +# also wraps each version in an array, so it can be directly used in a matrix strategy. Single-item matrices +# are nice because you can tell instantly in the Github UI which version is being tested without needing +# to inspect logs. +# +# To use a matrix output, e.g. latest version, do: +# strategy: +# matrix: ${{ fromJSON(this-job.outputs.latest-matrix) }} +# +name: Go Versions +on: + workflow_call: + outputs: + latest: + description: 'The most recent Go version to test' + value: ${{ jobs.go-versions.outputs.latest }} + penultimate: + description: 'The second most recent Go version to test' + value: ${{ jobs.go-versions.outputs.penultimate }} + matrix: + description: 'All Go versions to test as a matrix' + value: ${{ jobs.go-versions.outputs.all }} + +jobs: + go-versions: + runs-on: ubuntu-latest + outputs: + latest: ${{ steps.set-env.outputs.latest }} + penultimate: ${{ steps.set-env.outputs.penultimate }} + all: ${{ steps.set-matrix.outputs.all }} + steps: + - uses: actions/checkout@v4 + - name: Set Go Versions + id: set-env + run: cat ./.github/variables/go-versions.env > $GITHUB_OUTPUT + - name: Set Go Version Matrices + id: set-matrix + run: | + echo "all=[\"${{ steps.set-env.outputs.latest }}\",\"${{ steps.set-env.outputs.penultimate }}\"]" >> $GITHUB_OUTPUT diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 609e4ab5..653cd824 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -10,16 +10,24 @@ on: branches: [ "main" ] jobs: + go-versions: + uses: ./.github/workflows/go-versions.yml build: + needs: go-versions runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + go-version: ${{ fromJSON(needs.go-versions.outputs.matrix )}} + steps: - uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: ${{ matrix.go-version }} - name: Enforce formatting / go mod tidy run: | diff --git a/.github/workflows/manual-publish.yml b/.github/workflows/manual-publish.yml index 1e370cc2..823c067a 100644 --- a/.github/workflows/manual-publish.yml +++ b/.github/workflows/manual-publish.yml @@ -18,7 +18,11 @@ on: type: string jobs: + go-versions: + uses: ./.github/workflows/go-versions.yml + release-ldcli: + needs: go-versions permissions: id-token: write # Needed to obtain Docker tokens contents: write # Needed to upload release artifacts @@ -31,6 +35,11 @@ jobs: with: fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ needs.go-versions.outputs.latest }} + - uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.0.1 name: 'Get Docker token' with: diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 7c3ffd2f..8d72933b 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -6,6 +6,9 @@ on: - main jobs: + go-versions: + uses: ./.github/workflows/go-versions.yml + release-please: runs-on: ubuntu-latest outputs: @@ -21,7 +24,7 @@ jobs: permissions: id-token: write # Needed to obtain Docker tokens contents: write # Needed to upload release artifacts - needs: [ release-please ] + needs: [ release-please, go-versions ] if: ${{ needs.release-please.outputs.release_created == 'true' }} runs-on: ubuntu-latest outputs: @@ -32,6 +35,11 @@ jobs: with: fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ needs.go-versions.outputs.latest }} + - uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.0.1 name: 'Get Docker token' with: diff --git a/go.mod b/go.mod index efd0b03e..91148ca1 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/launchdarkly/ldcli -go 1.20 +go 1.21 require ( github.com/charmbracelet/bubbles v0.18.0 diff --git a/go.sum b/go.sum index 8c65725a..08b870c8 100644 --- a/go.sum +++ b/go.sum @@ -70,6 +70,7 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/getkin/kin-openapi v0.124.0 h1:VSFNMB9C9rTKBnQ/fpyDU8ytMTr4dWI9QovSKj9kz/M= @@ -82,6 +83,7 @@ github.com/go-openapi/jsonpointer v0.20.2/go.mod h1:bHen+N0u1KEO3YlmqOjTT9Adn1Rf github.com/go-openapi/swag v0.22.8 h1:/9RjDSQ0vbFR+NyjGMkFTsA1IA0fmhKSThmfGZjicbw= github.com/go-openapi/swag v0.22.8/go.mod h1:6QT22icPLEqAM/z/TChgb4WAveCHF92+2gF0CNjHpPI= github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= +github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -120,6 +122,7 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -154,10 +157,13 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/launchdarkly/api-client-go/v14 v14.0.0 h1:fZfi5zKwgjpaOgK4NKcU5mJT2C8sYsR8nnuJYTaFvNU= github.com/launchdarkly/api-client-go/v14 v14.0.0/go.mod h1:K7ejD5nn9ar94p/5qrQ0t9iJygdIQyH70U9M9rYvw5Y= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= @@ -213,6 +219,7 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= @@ -248,6 +255,7 @@ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8 github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= +github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -521,6 +529,7 @@ google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHh gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=