From 83ca73ec0b9ed2ee43235e19470dc6dbf2eef3bd Mon Sep 17 00:00:00 2001 From: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> Date: Fri, 18 Jun 2021 11:44:01 -0700 Subject: [PATCH] Cross Compile in Parallel two archs at a time (#825) * Cross Compile in Parallel two archs at a time Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> * Remove echo. Fix args Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> --- .github/workflows/crosscompile-1.yml | 34 +++++++++++++++++++ .github/workflows/crosscompile-2.yml | 34 +++++++++++++++++++ .github/workflows/crosscompile-3.yml | 34 +++++++++++++++++++ .github/workflows/crosscompile-4.yml | 34 +++++++++++++++++++ .../{crosscompile.yml => crosscompile-5.yml} | 2 +- Makefile | 2 +- cross-compile.sh | 13 ++++--- 7 files changed, 144 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/crosscompile-1.yml create mode 100644 .github/workflows/crosscompile-2.yml create mode 100644 .github/workflows/crosscompile-3.yml create mode 100644 .github/workflows/crosscompile-4.yml rename .github/workflows/{crosscompile.yml => crosscompile-5.yml} (91%) diff --git a/.github/workflows/crosscompile-1.yml b/.github/workflows/crosscompile-1.yml new file mode 100644 index 000000000..6114c0625 --- /dev/null +++ b/.github/workflows/crosscompile-1.yml @@ -0,0 +1,34 @@ +name: Go + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + build: + name: Cross compile + runs-on: ${{ matrix.os }} + strategy: + matrix: + go-version: [1.16.x] + os: [ubuntu-latest] + steps: + - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }} + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Build on ${{ matrix.os }} + env: + GO111MODULE: on + GOOS: linux + run: | + make crosscompile arg1="'linux/ppc64le linux/mips64'" diff --git a/.github/workflows/crosscompile-2.yml b/.github/workflows/crosscompile-2.yml new file mode 100644 index 000000000..65cebc7fe --- /dev/null +++ b/.github/workflows/crosscompile-2.yml @@ -0,0 +1,34 @@ +name: Go + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + build: + name: Cross compile + runs-on: ${{ matrix.os }} + strategy: + matrix: + go-version: [1.16.x] + os: [ubuntu-latest] + steps: + - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }} + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Build on ${{ matrix.os }} + env: + GO111MODULE: on + GOOS: linux + run: | + make crosscompile arg1="'linux/arm64 linux/s390x'" diff --git a/.github/workflows/crosscompile-3.yml b/.github/workflows/crosscompile-3.yml new file mode 100644 index 000000000..460e0bfbb --- /dev/null +++ b/.github/workflows/crosscompile-3.yml @@ -0,0 +1,34 @@ +name: Go + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + build: + name: Cross compile + runs-on: ${{ matrix.os }} + strategy: + matrix: + go-version: [1.16.x] + os: [ubuntu-latest] + steps: + - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }} + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Build on ${{ matrix.os }} + env: + GO111MODULE: on + GOOS: linux + run: | + make crosscompile arg1="'darwin/amd64 freebsd/amd64'" diff --git a/.github/workflows/crosscompile-4.yml b/.github/workflows/crosscompile-4.yml new file mode 100644 index 000000000..90a5bf122 --- /dev/null +++ b/.github/workflows/crosscompile-4.yml @@ -0,0 +1,34 @@ +name: Go + +on: + pull_request: + branches: + - master + push: + branches: + - master + +jobs: + build: + name: Cross compile + runs-on: ${{ matrix.os }} + strategy: + matrix: + go-version: [1.16.x] + os: [ubuntu-latest] + steps: + - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }} + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Build on ${{ matrix.os }} + env: + GO111MODULE: on + GOOS: linux + run: | + make crosscompile arg1="'windows/amd64 linux/arm'" diff --git a/.github/workflows/crosscompile.yml b/.github/workflows/crosscompile-5.yml similarity index 91% rename from .github/workflows/crosscompile.yml rename to .github/workflows/crosscompile-5.yml index 507460b87..e4885299b 100644 --- a/.github/workflows/crosscompile.yml +++ b/.github/workflows/crosscompile-5.yml @@ -31,4 +31,4 @@ jobs: GO111MODULE: on GOOS: linux run: | - make crosscompile + make crosscompile arg1="'linux/386 netbsd/amd64'" diff --git a/Makefile b/Makefile index 91866cb12..afacbb590 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ fmt: @GO111MODULE=on gofmt -d cluster/ crosscompile: - @(env bash $(PWD)/cross-compile.sh) + @(env bash $(PWD)/cross-compile.sh $(arg1)) lint: @echo "Running $@ check" diff --git a/cross-compile.sh b/cross-compile.sh index 790b33cd9..da145ff30 100755 --- a/cross-compile.sh +++ b/cross-compile.sh @@ -4,13 +4,12 @@ set -e # Enable tracing if set. [ -n "$BASH_XTRACEFD" ] && set -x -_init() { - ## All binaries are static make sure to disable CGO. - export CGO_ENABLED=0 +## All binaries are static make sure to disable CGO. +export CGO_ENABLED=0 - ## List of architectures and OS to test coss compilation. - SUPPORTED_OSARCH="linux/ppc64le linux/mips64 linux/arm64 linux/s390x darwin/amd64 freebsd/amd64 windows/amd64 linux/arm linux/386 netbsd/amd64" -} +## List of architectures and OS to test cross compilation. +SUPPORTED_OSARCH_DEFAULTS="linux/ppc64le linux/mips64 linux/arm64 linux/s390x darwin/amd64 freebsd/amd64 windows/amd64 linux/arm linux/386 netbsd/amd64" +SUPPORTED_OSARCH=${1:-$SUPPORTED_OSARCH_DEFAULTS} _build() { local osarch=$1 @@ -31,4 +30,4 @@ main() { done } -_init && main "$@" +main "$@"