Skip to content

Commit

Permalink
support for arm64 init
Browse files Browse the repository at this point in the history
  • Loading branch information
absolutelightning committed Feb 14, 2024
1 parent 5eb5155 commit cbb9289
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 56 deletions.
31 changes: 11 additions & 20 deletions .github/workflows/bin-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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}"
Expand All @@ -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: |
Expand Down
51 changes: 30 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -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:<commit>)
environment: dockerhub/hashicorpdev
needs:
Expand All @@ -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"
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/reusable-get-go-version.yml
Original file line number Diff line number Diff line change
@@ -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"
26 changes: 11 additions & 15 deletions .github/workflows/terraform-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -73,13 +60,22 @@ jobs:
skip-build-cache: true
working-directory: ./test/acceptance
acceptance:
strategy:
matrix:
goos:
- linux
goarch:
- amd64
- arm64
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./test/acceptance
env:
TEST_RESULTS: /tmp/test-results
GOTESTSUM_VERSION: 1.8.0
OS: ${{ matrix.goos }}
ARCH: ${{ matrix.goarch }}
needs:
- action-lint
- go-test-lint
Expand All @@ -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: |
Expand Down

0 comments on commit cbb9289

Please sign in to comment.