2023-03-21 17:37:32 +00:00
|
|
|
# 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
|
|
|
|
|
2023-07-12 23:10:34 +00:00
|
|
|
on:
|
2023-04-06 22:29:32 +00:00
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
# Push events on the main branch
|
|
|
|
- main
|
|
|
|
- release/**
|
2023-03-21 17:37:32 +00:00
|
|
|
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
2023-04-10 17:16:44 +00:00
|
|
|
env:
|
|
|
|
GOTAGS: ${{ endsWith(github.repository, '-enterprise') && 'consulent' || '' }}
|
2023-06-21 15:26:27 +00:00
|
|
|
GOPRIVATE: github.com/hashicorp # Required for enterprise deps
|
2023-04-10 17:16:44 +00:00
|
|
|
|
2023-08-28 16:05:25 +00:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2023-03-21 17:37:32 +00:00
|
|
|
jobs:
|
2023-03-28 21:29:27 +00:00
|
|
|
setup:
|
|
|
|
name: Setup
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
compute-small: ${{ steps.setup-outputs.outputs.compute-small }}
|
|
|
|
compute-medium: ${{ steps.setup-outputs.outputs.compute-medium }}
|
|
|
|
compute-large: ${{ steps.setup-outputs.outputs.compute-large }}
|
|
|
|
compute-xl: ${{ steps.setup-outputs.outputs.compute-xl }}
|
2023-03-21 17:37:32 +00:00
|
|
|
steps:
|
2024-05-14 19:49:03 +00:00
|
|
|
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
|
2023-03-28 21:29:27 +00:00
|
|
|
- id: setup-outputs
|
|
|
|
name: Setup outputs
|
|
|
|
run: ./.github/scripts/get_runner_classes.sh
|
|
|
|
|
2024-01-08 22:18:41 +00:00
|
|
|
get-go-version:
|
|
|
|
uses: ./.github/workflows/reusable-get-go-version.yml
|
|
|
|
|
2023-03-28 21:29:27 +00:00
|
|
|
check-go-mod:
|
2023-07-12 23:10:34 +00:00
|
|
|
needs:
|
2023-03-28 21:29:27 +00:00
|
|
|
- setup
|
2024-01-08 22:18:41 +00:00
|
|
|
- get-go-version
|
2023-03-28 21:29:27 +00:00
|
|
|
uses: ./.github/workflows/reusable-check-go-mod.yml
|
|
|
|
with:
|
|
|
|
runs-on: ${{ needs.setup.outputs.compute-medium }}
|
2023-03-30 16:57:11 +00:00
|
|
|
repository-name: ${{ github.repository }}
|
2024-01-08 22:18:41 +00:00
|
|
|
go-version: ${{ needs.get-go-version.outputs.go-version }}
|
2023-03-30 16:57:11 +00:00
|
|
|
secrets:
|
|
|
|
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
|
2023-03-21 17:37:32 +00:00
|
|
|
|
|
|
|
build-386:
|
2023-07-12 23:10:34 +00:00
|
|
|
needs:
|
|
|
|
- setup
|
2024-01-08 22:18:41 +00:00
|
|
|
- get-go-version
|
2023-03-28 21:29:27 +00:00
|
|
|
- check-go-mod
|
2023-03-21 17:37:32 +00:00
|
|
|
env:
|
|
|
|
XC_OS: "freebsd linux windows"
|
2023-04-07 17:10:47 +00:00
|
|
|
runs-on: ${{ fromJSON(needs.setup.outputs.compute-xl) }}
|
2023-03-21 17:37:32 +00:00
|
|
|
steps:
|
2024-05-14 19:49:03 +00:00
|
|
|
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
|
2023-03-30 16:57:11 +00:00
|
|
|
|
|
|
|
# NOTE: This step is specifically needed for ENT. It allows us to access the required private HashiCorp repos.
|
|
|
|
- name: Setup Git
|
|
|
|
if: ${{ endsWith(github.repository, '-enterprise') }}
|
|
|
|
run: git config --global url."https://${{ secrets.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com"
|
2023-07-12 23:10:34 +00:00
|
|
|
|
2024-05-14 19:49:03 +00:00
|
|
|
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
|
2023-03-21 17:37:32 +00:00
|
|
|
with:
|
2024-01-08 22:18:41 +00:00
|
|
|
go-version: ${{ needs.get-go-version.outputs.go-version }}
|
2023-03-21 17:37:32 +00:00
|
|
|
- name: Build
|
|
|
|
run: |
|
|
|
|
for os in $XC_OS; do
|
2023-04-10 17:16:44 +00:00
|
|
|
GOOS="$os" GOARCH=386 CGO_ENABLED=0 go build -tags "${{ env.GOTAGS }}"
|
2023-03-21 17:37:32 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
build-amd64:
|
2023-03-28 21:29:27 +00:00
|
|
|
needs:
|
2023-07-12 23:10:34 +00:00
|
|
|
- setup
|
2024-01-08 22:18:41 +00:00
|
|
|
- get-go-version
|
2023-03-28 21:29:27 +00:00
|
|
|
- check-go-mod
|
2023-03-21 17:37:32 +00:00
|
|
|
env:
|
|
|
|
XC_OS: "darwin freebsd linux solaris windows"
|
2023-04-07 17:10:47 +00:00
|
|
|
runs-on: ${{ fromJSON(needs.setup.outputs.compute-xl) }}
|
2023-03-21 17:37:32 +00:00
|
|
|
steps:
|
2024-05-14 19:49:03 +00:00
|
|
|
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
|
2023-03-30 16:57:11 +00:00
|
|
|
|
|
|
|
# NOTE: This step is specifically needed for ENT. It allows us to access the required private HashiCorp repos.
|
|
|
|
- name: Setup Git
|
|
|
|
if: ${{ endsWith(github.repository, '-enterprise') }}
|
|
|
|
run: git config --global url."https://${{ secrets.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com"
|
2023-07-12 23:10:34 +00:00
|
|
|
|
2024-05-14 19:49:03 +00:00
|
|
|
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
|
2023-03-21 17:37:32 +00:00
|
|
|
with:
|
2024-01-08 22:18:41 +00:00
|
|
|
go-version: ${{ needs.get-go-version.outputs.go-version }}
|
2023-03-21 17:37:32 +00:00
|
|
|
- name: Build
|
|
|
|
run: |
|
|
|
|
for os in $XC_OS; do
|
2023-04-10 17:16:44 +00:00
|
|
|
GOOS="$os" GOARCH=amd64 CGO_ENABLED=0 go build -tags "${{ env.GOTAGS }}"
|
2023-03-21 17:37:32 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
build-arm:
|
2023-03-28 21:29:27 +00:00
|
|
|
needs:
|
2023-07-12 23:10:34 +00:00
|
|
|
- setup
|
2024-01-08 22:18:41 +00:00
|
|
|
- get-go-version
|
2023-03-28 21:29:27 +00:00
|
|
|
- check-go-mod
|
2023-04-10 17:16:44 +00:00
|
|
|
runs-on: ${{ fromJSON(needs.setup.outputs.compute-xl) }}
|
2023-03-21 17:37:32 +00:00
|
|
|
env:
|
|
|
|
CGO_ENABLED: 1
|
|
|
|
GOOS: linux
|
|
|
|
steps:
|
2024-05-14 19:49:03 +00:00
|
|
|
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
|
2023-03-30 16:57:11 +00:00
|
|
|
|
|
|
|
# NOTE: This step is specifically needed for ENT. It allows us to access the required private HashiCorp repos.
|
|
|
|
- name: Setup Git
|
|
|
|
if: ${{ endsWith(github.repository, '-enterprise') }}
|
|
|
|
run: git config --global url."https://${{ secrets.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com"
|
2023-07-12 23:10:34 +00:00
|
|
|
|
2023-03-30 16:57:11 +00:00
|
|
|
|
2024-05-14 19:49:03 +00:00
|
|
|
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
|
2023-03-21 17:37:32 +00:00
|
|
|
with:
|
2024-01-08 22:18:41 +00:00
|
|
|
go-version: ${{ needs.get-go-version.outputs.go-version }}
|
2023-03-21 17:37:32 +00:00
|
|
|
- run: |
|
|
|
|
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
|
|
|
|
|
2023-04-10 17:16:44 +00:00
|
|
|
- run: CC=arm-linux-gnueabi-gcc GOARCH=arm GOARM=5 go build -tags "${{ env.GOTAGS }}"
|
|
|
|
- run: CC=arm-linux-gnueabihf-gcc GOARCH=arm GOARM=6 go build -tags "${{ env.GOTAGS }}"
|
|
|
|
- run: CC=aarch64-linux-gnu-gcc GOARCH=arm64 go build -tags "${{ env.GOTAGS }}"
|
2023-04-06 22:29:32 +00:00
|
|
|
|
2023-07-12 23:10:34 +00:00
|
|
|
|
|
|
|
build-s390x:
|
|
|
|
if: ${{ endsWith(github.repository, '-enterprise') }}
|
|
|
|
needs:
|
|
|
|
- setup
|
2024-01-08 22:18:41 +00:00
|
|
|
- get-go-version
|
2023-07-12 23:10:34 +00:00
|
|
|
- check-go-mod
|
|
|
|
runs-on: ${{ fromJSON(needs.setup.outputs.compute-xl) }}
|
|
|
|
steps:
|
2024-05-14 19:49:03 +00:00
|
|
|
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
|
2023-07-12 23:10:34 +00:00
|
|
|
|
|
|
|
# NOTE: This step is specifically needed for ENT. It allows us to access the required private HashiCorp repos.
|
|
|
|
- name: Setup Git
|
|
|
|
run: git config --global url."https://${{ secrets.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com"
|
|
|
|
|
2024-05-14 19:49:03 +00:00
|
|
|
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
|
2023-07-12 23:10:34 +00:00
|
|
|
with:
|
2024-01-08 22:18:41 +00:00
|
|
|
go-version: ${{ needs.get-go-version.outputs.go-version }}
|
2023-07-12 23:10:34 +00:00
|
|
|
- name: Build
|
|
|
|
run: GOOS=linux GOARCH=s390x CGO_ENABLED=0 go build -tags "${{ env.GOTAGS }}"
|
|
|
|
|
2023-04-06 22:29:32 +00:00
|
|
|
# This is job is required for branch protection as a required gihub check
|
|
|
|
# because GitHub actions show up as checks at the job level and not the
|
|
|
|
# workflow level. This is currently a feature request:
|
|
|
|
# https://github.com/orgs/community/discussions/12395
|
|
|
|
#
|
|
|
|
# This job must:
|
|
|
|
# - be placed after the fanout of a workflow so that everything fans back in
|
|
|
|
# to this job.
|
|
|
|
# - "need" any job that is part of the fan out / fan in
|
2023-07-12 23:10:34 +00:00
|
|
|
# - implement the if logic because we have conditional jobs
|
|
|
|
# (go-test-enteprise) that this job needs and this would potentially get
|
|
|
|
# skipped if a previous job got skipped. So we use the if clause to make
|
2023-04-06 22:29:32 +00:00
|
|
|
# sure it does not get skipped.
|
|
|
|
build-distros-success:
|
2023-07-12 23:10:34 +00:00
|
|
|
needs:
|
2023-04-06 22:29:32 +00:00
|
|
|
- setup
|
|
|
|
- check-go-mod
|
|
|
|
- build-386
|
|
|
|
- build-amd64
|
|
|
|
- build-arm
|
2023-07-12 23:10:34 +00:00
|
|
|
- build-s390x
|
2023-04-06 22:29:32 +00:00
|
|
|
runs-on: ${{ fromJSON(needs.setup.outputs.compute-small) }}
|
2023-04-25 20:17:48 +00:00
|
|
|
if: ${{ always() }}
|
2023-04-06 22:29:32 +00:00
|
|
|
steps:
|
2023-04-25 20:17:48 +00:00
|
|
|
- name: evaluate upstream job results
|
|
|
|
run: |
|
|
|
|
# exit 1 if failure or cancelled result for any upstream job
|
|
|
|
if printf '${{ toJSON(needs) }}' | grep -E -i '\"result\": \"(failure|cancelled)\"'; then
|
|
|
|
printf "Tests failed or workflow cancelled:\n\n${{ toJSON(needs) }}"
|
|
|
|
exit 1
|
|
|
|
fi
|