Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NET-4103] ci: build s390x #18067

Merged
merged 13 commits into from
Jul 12, 2023
48 changes: 34 additions & 14 deletions .github/workflows/build-distros.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# It is aimed at checking new commits don't introduce any breaking build changes.
name: build-distros

on:
on:
pull_request:
push:
branches:
Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
run: ./.github/scripts/get_runner_classes.sh

check-go-mod:
needs:
needs:
- setup
uses: ./.github/workflows/reusable-check-go-mod.yml
with:
Expand All @@ -43,8 +43,8 @@ jobs:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}

build-386:
needs:
- setup
needs:
- setup
- check-go-mod
env:
XC_OS: "freebsd linux windows"
Expand All @@ -56,7 +56,7 @@ jobs:
- name: Setup Git
if: ${{ endsWith(github.repository, '-enterprise') }}
run: git config --global url."https://${{ secrets.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com"

- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
Expand All @@ -68,7 +68,7 @@ jobs:

build-amd64:
needs:
- setup
- setup
- check-go-mod
env:
XC_OS: "darwin freebsd linux solaris windows"
Expand All @@ -80,7 +80,7 @@ jobs:
- name: Setup Git
if: ${{ endsWith(github.repository, '-enterprise') }}
run: git config --global url."https://${{ secrets.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com"

- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
Expand All @@ -92,7 +92,7 @@ jobs:

build-arm:
needs:
- setup
- setup
- check-go-mod
runs-on: ${{ fromJSON(needs.setup.outputs.compute-xl) }}
env:
Expand All @@ -105,7 +105,7 @@ jobs:
- name: Setup Git
if: ${{ endsWith(github.repository, '-enterprise') }}
run: git config --global url."https://${{ secrets.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com"


- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
Expand All @@ -117,6 +117,26 @@ jobs:
- 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 }}"


build-s390x:
if: ${{ endsWith(github.repository, '-enterprise') }}
needs:
- setup
- check-go-mod
runs-on: ${{ fromJSON(needs.setup.outputs.compute-xl) }}
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

# 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"

- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
- name: Build
run: GOOS=linux GOARCH=s390x CGO_ENABLED=0 go build -tags "${{ env.GOTAGS }}"

# 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:
Expand All @@ -126,18 +146,18 @@ jobs:
# - 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
# - 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
# - 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
# sure it does not get skipped.

build-distros-success:
needs:
needs:
- setup
- check-go-mod
- build-386
- build-amd64
- build-arm
- build-s390x
runs-on: ${{ fromJSON(needs.setup.outputs.compute-small) }}
if: ${{ always() }}
steps:
Expand Down
57 changes: 55 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
echo "Product Date: ${{ needs.set-product-version.outputs.product-date }}"
echo "Prerelease Version: ${{ needs.set-product-version.outputs.pre-version }}"
echo "Ldflags: ${{ needs.set-product-version.outputs.shared-ldflags }}"

generate-metadata-file:
needs: set-product-version
runs-on: ubuntu-latest
Expand Down Expand Up @@ -173,6 +174,57 @@ jobs:
name: ${{ env.DEB_PACKAGE }}
path: out/${{ env.DEB_PACKAGE }}

build-s390x:
needs: set-product-version
if: ${{ endsWith(github.repository, '-enterprise') }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- {go: "1.20.4", goos: "linux", goarch: "s390x"}
fail-fast: true

name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

- name: Setup with node and yarn
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: '14'
cache: 'yarn'
cache-dependency-path: 'ui/yarn.lock'

- name: Build UI
run: |
CONSUL_VERSION=${{ needs.set-product-version.outputs.product-version }}
CONSUL_DATE=${{ needs.set-product-version.outputs.product-date }}
CONSUL_BINARY_TYPE=${CONSUL_BINARY_TYPE}
CONSUL_COPYRIGHT_YEAR=$(git show -s --format=%cd --date=format:%Y HEAD)
echo "consul_version is ${CONSUL_VERSION}"
echo "consul_date is ${CONSUL_DATE}"
echo "consul binary type is ${CONSUL_BINARY_TYPE}"
echo "consul copyright year is ${CONSUL_COPYRIGHT_YEAR}"
cd ui && make && cd ..
rm -rf agent/uiserver/dist
mv ui/packages/consul-ui/dist agent/uiserver/
- name: Go Build
env:
PRODUCT_VERSION: ${{ needs.set-product-version.outputs.product-version }}
PRERELEASE_VERSION: ${{ needs.set-product-version.outputs.pre-version }}
CGO_ENABLED: "0"
GOLDFLAGS: "${{needs.set-product-version.outputs.shared-ldflags}}"
uses: hashicorp/[email protected]
with:
product_name: ${{ env.PKG_NAME }}
product_version: ${{ needs.set-product-version.outputs.product-version }}
go_version: ${{ matrix.go }}
os: ${{ matrix.goos }}
arch: ${{ matrix.goarch }}
reproducible: report
instructions: |-
go build -ldflags="$GOLDFLAGS" -o "$BIN_PATH" -trimpath -buildvcs=false

build-darwin:
needs: set-product-version
runs-on: macos-latest
Expand All @@ -186,7 +238,7 @@ jobs:
name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

- name: Setup with node and yarn
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
Expand Down Expand Up @@ -319,12 +371,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
arch: ["386", "amd64", "arm", "arm64"]
arch: ["386", "amd64", "arm", "arm64", "s390x"]
fail-fast: true
env:
version: ${{ needs.set-product-version.outputs.product-version }}
zip_name: consul_${{ needs.set-product-version.outputs.product-version }}_linux_${{ matrix.arch }}.zip

if: ${{ endsWith(github.repository, '-enterprise') }} || ${{ matrix.arch != 's390x' }}
loshz marked this conversation as resolved.
Show resolved Hide resolved
name: Verify ${{ matrix.arch }} linux binary
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
Expand Down
Loading