Browse Source

ci: detect Go backwards compatibility test version automatically

For our submodules and other places we choose to test against previous
Go versions, detect this version automatically from the current one
rather than hard-coding it.
pull/20177/head
Michael Zalimeni 11 months ago
parent
commit
26d97a163d
  1. 30
      .github/workflows/go-tests.yml
  2. 8
      .github/workflows/reusable-get-go-version.yml

30
.github/workflows/go-tests.yml

@ -408,9 +408,11 @@ jobs:
consul-license: ${{secrets.CONSUL_LICENSE}} consul-license: ${{secrets.CONSUL_LICENSE}}
datadog-api-key: "${{ !endsWith(github.repository, '-enterprise') && secrets.DATADOG_API_KEY || '' }}" datadog-api-key: "${{ !endsWith(github.repository, '-enterprise') && secrets.DATADOG_API_KEY || '' }}"
go-test-api-1-19: go-test-api-backwards-compatibility:
name: go-test-api-${{ needs.get-go-version.outputs.go-version-previous }}
needs: needs:
- setup - setup
- get-go-version
- dev-build - dev-build
uses: ./.github/workflows/reusable-unit.yml uses: ./.github/workflows/reusable-unit.yml
with: with:
@ -418,7 +420,7 @@ jobs:
runs-on: ${{ needs.setup.outputs.compute-large }} runs-on: ${{ needs.setup.outputs.compute-large }}
repository-name: ${{ github.repository }} repository-name: ${{ github.repository }}
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consuldev' || '' }}" go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consuldev' || '' }}"
go-version: "1.19" go-version: ${{ needs.get-go-version.outputs.go-version-previous }}
permissions: permissions:
id-token: write # NOTE: this permission is explicitly required for Vault auth. id-token: write # NOTE: this permission is explicitly required for Vault auth.
contents: read contents: read
@ -427,9 +429,10 @@ jobs:
consul-license: ${{secrets.CONSUL_LICENSE}} consul-license: ${{secrets.CONSUL_LICENSE}}
datadog-api-key: "${{ !endsWith(github.repository, '-enterprise') && secrets.DATADOG_API_KEY || '' }}" datadog-api-key: "${{ !endsWith(github.repository, '-enterprise') && secrets.DATADOG_API_KEY || '' }}"
go-test-api-1-20: go-test-api:
needs: needs:
- setup - setup
- get-go-version
- dev-build - dev-build
uses: ./.github/workflows/reusable-unit.yml uses: ./.github/workflows/reusable-unit.yml
with: with:
@ -437,7 +440,7 @@ jobs:
runs-on: ${{ needs.setup.outputs.compute-large }} runs-on: ${{ needs.setup.outputs.compute-large }}
repository-name: ${{ github.repository }} repository-name: ${{ github.repository }}
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consuldev' || '' }}" go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consuldev' || '' }}"
go-version: "1.20" go-version: ${{ needs.get-go-version.outputs.go-version }}
permissions: permissions:
id-token: write # NOTE: this permission is explicitly required for Vault auth. id-token: write # NOTE: this permission is explicitly required for Vault auth.
contents: read contents: read
@ -446,9 +449,11 @@ jobs:
consul-license: ${{secrets.CONSUL_LICENSE}} consul-license: ${{secrets.CONSUL_LICENSE}}
datadog-api-key: "${{ !endsWith(github.repository, '-enterprise') && secrets.DATADOG_API_KEY || '' }}" datadog-api-key: "${{ !endsWith(github.repository, '-enterprise') && secrets.DATADOG_API_KEY || '' }}"
go-test-sdk-1-19: go-test-sdk-backwards-compatibility:
name: go-test-sdk-${{ needs.get-go-version.outputs.go-version-previous }}
needs: needs:
- setup - setup
- get-go-version
- dev-build - dev-build
uses: ./.github/workflows/reusable-unit.yml uses: ./.github/workflows/reusable-unit.yml
with: with:
@ -456,7 +461,7 @@ jobs:
runs-on: ${{ needs.setup.outputs.compute-large }} runs-on: ${{ needs.setup.outputs.compute-large }}
repository-name: ${{ github.repository }} repository-name: ${{ github.repository }}
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consuldev' || '' }}" go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consuldev' || '' }}"
go-version: "1.19" go-version: ${{ needs.get-go-version.outputs.go-version-previous }}
permissions: permissions:
id-token: write # NOTE: this permission is explicitly required for Vault auth. id-token: write # NOTE: this permission is explicitly required for Vault auth.
contents: read contents: read
@ -465,9 +470,10 @@ jobs:
consul-license: ${{secrets.CONSUL_LICENSE}} consul-license: ${{secrets.CONSUL_LICENSE}}
datadog-api-key: "${{ !endsWith(github.repository, '-enterprise') && secrets.DATADOG_API_KEY || '' }}" datadog-api-key: "${{ !endsWith(github.repository, '-enterprise') && secrets.DATADOG_API_KEY || '' }}"
go-test-sdk-1-20: go-test-sdk:
needs: needs:
- setup - setup
- get-go-version
- dev-build - dev-build
uses: ./.github/workflows/reusable-unit.yml uses: ./.github/workflows/reusable-unit.yml
with: with:
@ -475,7 +481,7 @@ jobs:
runs-on: ${{ needs.setup.outputs.compute-large }} runs-on: ${{ needs.setup.outputs.compute-large }}
repository-name: ${{ github.repository }} repository-name: ${{ github.repository }}
go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consuldev' || '' }}" go-tags: "${{ github.event.repository.name == 'consul-enterprise' && 'consulent consuldev' || '' }}"
go-version: "1.20" go-version: ${{ needs.get-go-version.outputs.go-version }}
permissions: permissions:
id-token: write # NOTE: this permission is explicitly required for Vault auth. id-token: write # NOTE: this permission is explicitly required for Vault auth.
contents: read contents: read
@ -521,10 +527,10 @@ jobs:
- go-test-race - go-test-race
- go-test-envoyextensions - go-test-envoyextensions
- go-test-troubleshoot - go-test-troubleshoot
- go-test-api-1-19 - go-test-api-backwards-compatibility
- go-test-api-1-20 - go-test-api
- go-test-sdk-1-19 - go-test-sdk-backwards-compatibility
- go-test-sdk-1-20 - go-test-sdk
- go-test-32bit - go-test-32bit
# - go-test-s390x # - go-test-s390x
runs-on: ${{ fromJSON(needs.setup.outputs.compute-small) }} runs-on: ${{ fromJSON(needs.setup.outputs.compute-small) }}

8
.github/workflows/reusable-get-go-version.yml

@ -6,6 +6,9 @@ on:
go-version: go-version:
description: "The Go version detected by this workflow" description: "The Go version detected by this workflow"
value: ${{ jobs.get-go-version.outputs.go-version }} value: ${{ jobs.get-go-version.outputs.go-version }}
go-version-previous:
description: "The Go version (MAJOR.MINOR) prior to the current one, used for backwards compatibility testing"
value: ${{ jobs.get-go-version.outputs.go-version-previous }}
jobs: jobs:
get-go-version: get-go-version:
@ -13,6 +16,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
go-version: ${{ steps.get-go-version.outputs.go-version }} go-version: ${{ steps.get-go-version.outputs.go-version }}
go-version-previous: ${{ steps.get-go-version.outputs.go-version-previous }}
steps: steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Determine Go version - name: Determine Go version
@ -32,3 +36,7 @@ jobs:
GO_VERSION=$(head -n 1 .go-version) GO_VERSION=$(head -n 1 .go-version)
echo "Building with Go ${GO_VERSION}" echo "Building with Go ${GO_VERSION}"
echo "go-version=${GO_VERSION}" >> $GITHUB_OUTPUT echo "go-version=${GO_VERSION}" >> $GITHUB_OUTPUT
GO_MINOR_VERSION=${GO_VERSION%.*}
GO_VERSION_PREVIOUS="${GO_MINOR_VERSION%.*}.$((${GO_MINOR_VERSION#*.}-1))"
echo "Previous version ${GO_VERSION_PREVIOUS}"
echo "go-version-previous=${GO_VERSION_PREVIOUS}" >> $GITHUB_OUTPUT

Loading…
Cancel
Save