From cbb92896343eb8d3651f416446b8df611208557f Mon Sep 17 00:00:00 2001 From: Ashesh Vidyut Date: Wed, 14 Feb 2024 16:42:20 +0530 Subject: [PATCH] support for arm64 init --- .github/workflows/bin-ci.yml | 31 ++++------- .github/workflows/build.yml | 51 +++++++++++-------- .github/workflows/reusable-get-go-version.yml | 25 +++++++++ .github/workflows/terraform-ci.yml | 26 ++++------ 4 files changed, 77 insertions(+), 56 deletions(-) create mode 100644 .github/workflows/reusable-get-go-version.yml diff --git a/.github/workflows/bin-ci.yml b/.github/workflows/bin-ci.yml index 78d3cd7..4d62c53 100644 --- a/.github/workflows/bin-ci.yml +++ b/.github/workflows/bin-ci.yml @@ -13,22 +13,8 @@ jobs: - name: Lint workflow uses: docker://docker.mirror.hashicorp.services/rhysd/actionlint:latest get-go-version: - name: "Determine Go toolchain version" - defaults: - run: - working-directory: ./consul-lambda - runs-on: ubuntu-latest - needs: - - action-lint - outputs: - go-version: ${{ steps.get-go-version.outputs.go-version }} - steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 - - name: Determine Go version - id: get-go-version - run: | - echo "Building with Go $(cat .go-version)" - echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT" + needs: action-lint + uses: ./.github/workflows/reusable-get-go-version.yml lint: defaults: run: @@ -58,8 +44,11 @@ jobs: strategy: matrix: consul-version: - - 1.15.2 - - 1.15.2+ent + - 1.15.2 + - 1.15.2+ent + platform: + - { goos: "linux", goarch: "amd64" } + - { goos: "linux", goarch: "arm64" } needs: - get-go-version defaults: @@ -80,7 +69,8 @@ jobs: shell: bash run: | CONSUL_VERSION="${{ matrix.consul-version }}" - FILENAME="consul_${CONSUL_VERSION}_linux_amd64.zip" + PLATFORM="${{ matrix.platform.goos }}_${{ matrix.platform.goarch }}" + FILENAME="consul_${CONSUL_VERSION}_${PLATFORM}.zip" curl -sSLO "https://releases.hashicorp.com/consul/${CONSUL_VERSION}/${FILENAME}" && \ unzip "${FILENAME}" -d /usr/local/bin && \ rm "${FILENAME}" @@ -90,8 +80,9 @@ jobs: - name: Setup gotestsum shell: bash run: | + PLATFORM="${{ matrix.platform.goos }}_${{ matrix.platform.goarch }}" url=https://github.com/gotestyourself/gotestsum/releases/download - curl -sSL "${url}/v${{ env.GOTESTSUM_VERSION }}/gotestsum_${{ env.GOTESTSUM_VERSION }}_linux_amd64.tar.gz" | \ + curl -sSL "${url}/v${{ env.GOTESTSUM_VERSION }}/gotestsum_${{ env.GOTESTSUM_VERSION }}_${PLATFORM}.tar.gz" | \ tar -xz --overwrite -C /usr/local/bin gotestsum - name: Test run: | diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 67a61ab..b1db28a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,22 +14,8 @@ jobs: - name: Lint workflow uses: docker://docker.mirror.hashicorp.services/rhysd/actionlint:latest get-go-version: - name: "Determine Go toolchain version" - defaults: - run: - working-directory: ./consul-lambda - runs-on: ubuntu-latest needs: action-lint - outputs: - go-version: ${{ steps.get-go-version.outputs.go-version }} - steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 - - name: Determine Go version - id: get-go-version - run: | - echo "Building with Go $(cat .go-version)" - echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT" - + uses: ./.github/workflows/reusable-get-go-version.yml get-product-version: defaults: run: @@ -75,12 +61,19 @@ jobs: path: ${{ steps.generate-metadata-file.outputs.filepath }} build-linux: + strategy: + matrix: + goos: + - linux + goarch: + - amd64 + - arm64 defaults: run: working-directory: ./consul-lambda env: - GOOS: linux - GOARCH: amd64 + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} LDFLAGS: ${{ needs.get-product-version.outputs.ldflags }} CGO_ENABLED: 0 needs: @@ -122,6 +115,13 @@ jobs: path: ./consul-lambda/out/${{ env.EXT_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ env.GOOS }}_${{ env.GOARCH }}.zip build-docker-default: + strategy: + matrix: + goos: + - linux + goarch: + - amd64 + - arm64 defaults: run: working-directory: ./consul-lambda/consul-lambda-registrator @@ -132,7 +132,7 @@ jobs: runs-on: ubuntu-latest env: version: ${{ needs.get-product-version.outputs.product-version }} - arch: amd64 + arch: ${{ matrix.goarch }} steps: - name: Checkout @@ -147,6 +147,7 @@ jobs: target: release-default workdir: ./consul-lambda/consul-lambda-registrator arch: ${{ env.arch }} + os: ${{ env.os }} tags: | docker.io/hashicorp/${{ env.REG_NAME }}:${{ env.version }} public.ecr.aws/hashicorp/${{ env.REG_NAME }}:${{ env.version }} @@ -155,6 +156,13 @@ jobs: docker.io/hashicorppreview/${{ env.REG_NAME }}:${{ env.version }} upload-dev-docker: + strategy: + matrix: + goos: + - linux + goarch: + - amd64 + - arm64 name: Upload dev image (hashicorpdev/consul-lambda-registrator:) environment: dockerhub/hashicorpdev needs: @@ -164,20 +172,21 @@ jobs: env: repo: ${{ github.event.repository.name }} version: ${{ needs.get-product-version.outputs.product-version }} - arch: amd64 + arch: ${{ matrix.goarch }} + os: ${{ matrix.goos }} target: release-default git-short-sha: ${{ needs.get-product-version.outputs.git-short-sha }} steps: - name: Download image artifact uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 with: - name: ${{ env.repo }}_${{ env.target }}_linux_${{ env.arch }}_${{ env.version }}_${{ github.sha }}.docker.dev.tar + name: ${{ env.repo }}_${{ env.target }}_${{ env.os }}_${{ env.arch }}_${{ env.version }}_${{ github.sha }}.docker.dev.tar - name: Docker push shell: bash run: | TAG=hashicorpdev/${{ env.REG_NAME }}:${{ env.git-short-sha }} echo "==> Load docker image from tar archive" - docker load -i "${{ env.repo }}_${{ env.target }}_linux_${{ env.arch }}_${{ env.version }}_${{ github.sha }}.docker.dev.tar" + docker load -i "${{ env.repo }}_${{ env.target }}_${{ env.os }}_${{ env.arch }}_${{ env.version }}_${{ github.sha }}.docker.dev.tar" echo "==> Tag docker image $TAG" docker tag "hashicorppreview/${{ env.REG_NAME }}:${{ env.version }}" "$TAG" echo "==> Docker login" diff --git a/.github/workflows/reusable-get-go-version.yml b/.github/workflows/reusable-get-go-version.yml new file mode 100644 index 0000000..fdad805 --- /dev/null +++ b/.github/workflows/reusable-get-go-version.yml @@ -0,0 +1,25 @@ +name: get-go-version + +on: + workflow_call: + outputs: + go-version: + description: "The Go version detected by this workflow" + value: ${{ jobs.get-go-version.outputs.go-version }} + +jobs: + get-go-version: + name: "Determine Go toolchain version" + defaults: + run: + working-directory: ./consul-lambda + runs-on: ubuntu-latest + outputs: + go-version: ${{ steps.get-go-version.outputs.go-version }} + steps: + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + - name: Determine Go version + id: get-go-version + run: | + echo "Building with Go $(cat .go-version)" + echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT" \ No newline at end of file diff --git a/.github/workflows/terraform-ci.yml b/.github/workflows/terraform-ci.yml index a3e418a..3a440a5 100644 --- a/.github/workflows/terraform-ci.yml +++ b/.github/workflows/terraform-ci.yml @@ -30,20 +30,7 @@ jobs: - name: Validate run: terraform fmt -check -recursive . get-go-version: - name: "Determine Go toolchain version" - defaults: - run: - working-directory: ./consul-lambda - runs-on: ubuntu-latest - outputs: - go-version: ${{ steps.get-go-version.outputs.go-version }} - steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 - - name: Determine Go version - id: get-go-version - run: | - echo "Building with Go $(cat .go-version)" - echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT" + uses: ./.github/workflows/reusable-get-go-version.yml go-test-lint: runs-on: ubuntu-latest defaults: @@ -73,6 +60,13 @@ jobs: skip-build-cache: true working-directory: ./test/acceptance acceptance: + strategy: + matrix: + goos: + - linux + goarch: + - amd64 + - arm64 runs-on: ubuntu-latest defaults: run: @@ -80,6 +74,8 @@ jobs: env: TEST_RESULTS: /tmp/test-results GOTESTSUM_VERSION: 1.8.0 + OS: ${{ matrix.goos }} + ARCH: ${{ matrix.goarch }} needs: - action-lint - go-test-lint @@ -96,7 +92,7 @@ jobs: shell: bash run: | url=https://github.com/gotestyourself/gotestsum/releases/download - curl -sSL "${url}/v${{ env.GOTESTSUM_VERSION }}/gotestsum_${{ env.GOTESTSUM_VERSION }}_linux_amd64.tar.gz" | \ + curl -sSL "${url}/v${{ env.GOTESTSUM_VERSION }}/gotestsum_${{ env.GOTESTSUM_VERSION }}_${{ env.OS }}_${{ env.ARCH }}.tar.gz" | \ tar -xz --overwrite -C /usr/local/bin gotestsum - name: Install dependencies run: |