From d06ede9daf9b2420cddb18ce69cfbafbeccdeb35 Mon Sep 17 00:00:00 2001 From: Dan Bond Date: Thu, 23 Mar 2023 16:40:48 -0700 Subject: [PATCH] ci: use correct build-distros workflow (#16757) Signed-off-by: Dan Bond --- .github/workflows/build-distros.yml | 60 ++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-distros.yml b/.github/workflows/build-distros.yml index 9a43a7f520..87d6f96054 100644 --- a/.github/workflows/build-distros.yml +++ b/.github/workflows/build-distros.yml @@ -1,17 +1,32 @@ +# NOTE: this workflow builds Consul binaries on multiple architectures for PRs. +# It is aimed at checking new commits don't introduce any breaking build changes. name: build-distros -on: - pull_request: - branches: ["main"] - push: - branches: ["main"] - tags: ["*"] +on: [pull_request] + +permissions: + contents: read jobs: + check-go-mod: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3.3.0 + - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@v3.5.0 + with: + go-version-file: 'go.mod' + - run: go mod tidy + - run: | + if [[ -n $(git status -s) ]]; then + echo "Git directory has changes" + git status -s + exit 1 + fi + build-386: - strategy: - matrix: - os: ['freebsd', 'linux', 'windows'] + needs: check-go-mod + env: + XC_OS: "freebsd linux windows" runs-on: ubuntu-22.04 steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3.3.0 @@ -19,12 +34,15 @@ jobs: with: go-version-file: 'go.mod' - name: Build - run: GOOS=${{ matrix.os }} GOARCH=386 CGO_ENABLED=0 go build + run: | + for os in $XC_OS; do + GOOS="$os" GOARCH=386 CGO_ENABLED=0 go build + done build-amd64: - strategy: - matrix: - os: ['darwin', 'freebsd', 'linux', 'solaris', 'windows'] + needs: check-go-mod + env: + XC_OS: "darwin freebsd linux solaris windows" runs-on: ubuntu-22.04 steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3.3.0 @@ -32,12 +50,26 @@ jobs: with: go-version-file: 'go.mod' - name: Build - run: GOOS=${{ matrix.os }} GOARCH=amd64 CGO_ENABLED=0 go build + run: | + for os in $XC_OS; do + GOOS="$os" GOARCH=amd64 CGO_ENABLED=0 go build + done build-arm: + needs: check-go-mod runs-on: ubuntu-22.04 + env: + CGO_ENABLED: 1 + GOOS: linux steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3.3.0 - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@v3.5.0 with: go-version-file: 'go.mod' + - run: | + sudo rm -fv /etc/apt/sources.list.d/github_git-lfs.list # workaround for https://github.com/actions/runner-images/issues/1983 + sudo apt-get update --allow-releaseinfo-change-suite --allow-releaseinfo-change-version && sudo apt-get install -y gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu + + - run: CC=arm-linux-gnueabi-gcc GOARCH=arm GOARM=5 go build + - run: CC=arm-linux-gnueabihf-gcc GOARCH=arm GOARM=6 go build + - run: CC=aarch64-linux-gnu-gcc GOARCH=arm64 go build