Skip to content

Commit 83ca73e

Browse files
authored
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>
1 parent b14d67e commit 83ca73e

File tree

7 files changed

+144
-9
lines changed

7 files changed

+144
-9
lines changed

.github/workflows/crosscompile-1.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Go
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
push:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build:
13+
name: Cross compile
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
go-version: [1.16.x]
18+
os: [ubuntu-latest]
19+
steps:
20+
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
21+
uses: actions/setup-go@v2
22+
with:
23+
go-version: ${{ matrix.go-version }}
24+
id: go
25+
26+
- name: Check out code into the Go module directory
27+
uses: actions/checkout@v2
28+
29+
- name: Build on ${{ matrix.os }}
30+
env:
31+
GO111MODULE: on
32+
GOOS: linux
33+
run: |
34+
make crosscompile arg1="'linux/ppc64le linux/mips64'"

.github/workflows/crosscompile-2.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Go
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
push:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build:
13+
name: Cross compile
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
go-version: [1.16.x]
18+
os: [ubuntu-latest]
19+
steps:
20+
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
21+
uses: actions/setup-go@v2
22+
with:
23+
go-version: ${{ matrix.go-version }}
24+
id: go
25+
26+
- name: Check out code into the Go module directory
27+
uses: actions/checkout@v2
28+
29+
- name: Build on ${{ matrix.os }}
30+
env:
31+
GO111MODULE: on
32+
GOOS: linux
33+
run: |
34+
make crosscompile arg1="'linux/arm64 linux/s390x'"

.github/workflows/crosscompile-3.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Go
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
push:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build:
13+
name: Cross compile
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
go-version: [1.16.x]
18+
os: [ubuntu-latest]
19+
steps:
20+
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
21+
uses: actions/setup-go@v2
22+
with:
23+
go-version: ${{ matrix.go-version }}
24+
id: go
25+
26+
- name: Check out code into the Go module directory
27+
uses: actions/checkout@v2
28+
29+
- name: Build on ${{ matrix.os }}
30+
env:
31+
GO111MODULE: on
32+
GOOS: linux
33+
run: |
34+
make crosscompile arg1="'darwin/amd64 freebsd/amd64'"

.github/workflows/crosscompile-4.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Go
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
push:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build:
13+
name: Cross compile
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
go-version: [1.16.x]
18+
os: [ubuntu-latest]
19+
steps:
20+
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
21+
uses: actions/setup-go@v2
22+
with:
23+
go-version: ${{ matrix.go-version }}
24+
id: go
25+
26+
- name: Check out code into the Go module directory
27+
uses: actions/checkout@v2
28+
29+
- name: Build on ${{ matrix.os }}
30+
env:
31+
GO111MODULE: on
32+
GOOS: linux
33+
run: |
34+
make crosscompile arg1="'windows/amd64 linux/arm'"

.github/workflows/crosscompile.yml renamed to .github/workflows/crosscompile-5.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131
GO111MODULE: on
3232
GOOS: linux
3333
run: |
34-
make crosscompile
34+
make crosscompile arg1="'linux/386 netbsd/amd64'"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fmt:
3131
@GO111MODULE=on gofmt -d cluster/
3232

3333
crosscompile:
34-
@(env bash $(PWD)/cross-compile.sh)
34+
@(env bash $(PWD)/cross-compile.sh $(arg1))
3535

3636
lint:
3737
@echo "Running $@ check"

cross-compile.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ set -e
44
# Enable tracing if set.
55
[ -n "$BASH_XTRACEFD" ] && set -x
66

7-
_init() {
8-
## All binaries are static make sure to disable CGO.
9-
export CGO_ENABLED=0
7+
## All binaries are static make sure to disable CGO.
8+
export CGO_ENABLED=0
109

11-
## List of architectures and OS to test coss compilation.
12-
SUPPORTED_OSARCH="linux/ppc64le linux/mips64 linux/arm64 linux/s390x darwin/amd64 freebsd/amd64 windows/amd64 linux/arm linux/386 netbsd/amd64"
13-
}
10+
## List of architectures and OS to test cross compilation.
11+
SUPPORTED_OSARCH_DEFAULTS="linux/ppc64le linux/mips64 linux/arm64 linux/s390x darwin/amd64 freebsd/amd64 windows/amd64 linux/arm linux/386 netbsd/amd64"
12+
SUPPORTED_OSARCH=${1:-$SUPPORTED_OSARCH_DEFAULTS}
1413

1514
_build() {
1615
local osarch=$1
@@ -31,4 +30,4 @@ main() {
3130
done
3231
}
3332

34-
_init && main "$@"
33+
main "$@"

0 commit comments

Comments
 (0)