Skip to content

Commit b8ccd81

Browse files
authored
Merge pull request #1003 from Elbehery/20250625_1.4-use-temmplate-for-cross-build-tests
[release-1.4] Add template to cross arch build tests
2 parents 992a56a + 61713a0 commit b8ccd81

File tree

2 files changed

+55
-125
lines changed

2 files changed

+55
-125
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Reusable Cross-Platform Build Workflow
3+
on:
4+
workflow_call:
5+
inputs:
6+
archs:
7+
required: true
8+
type: string
9+
os:
10+
required: true
11+
type: string
12+
permissions: read-all
13+
14+
jobs:
15+
cross-build:
16+
strategy:
17+
matrix:
18+
arch: ${{ fromJSON(inputs.archs) }}
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
- id: goversion
23+
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
24+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
25+
with:
26+
go-version: ${{ steps.goversion.outputs.goversion }}
27+
- name: Build for ${{ inputs.os }}/${{ matrix.arch }}
28+
run: |
29+
GOOS=${{ inputs.os }} GOARCH=${{ matrix.arch }} go build ./...
Lines changed: 26 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,36 @@
11
---
22
name: Cross-Platform Build Tests
3-
4-
on:
5-
push:
6-
branches: [ main ]
7-
pull_request:
8-
branches: [ main ]
3+
permissions: read-all
4+
on: [push, pull_request]
95

106
jobs:
117
build-aix:
12-
strategy:
13-
matrix:
14-
goarch: [ppc64]
15-
runs-on: ubuntu-latest
16-
steps:
17-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18-
- id: goversion
19-
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
20-
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
21-
with:
22-
go-version: ${{ steps.goversion.outputs.goversion }}
23-
- name: Run golangci-lint
24-
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
25-
with:
26-
version: v2.1.6
27-
28-
- name: Build for aix/${{ matrix.goarch }}
29-
run: |
30-
GOOS=aix GOARCH=${{ matrix.GOARCH }} go build ./...
31-
8+
uses: ./.github/workflows/cross-arch-template.yaml
9+
with:
10+
os: aix
11+
archs: "['ppc64']"
3212
build-android:
33-
strategy:
34-
matrix:
35-
goarch: [arm64]
36-
runs-on: ubuntu-latest
37-
steps:
38-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
39-
- id: goversion
40-
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
41-
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
42-
with:
43-
go-version: ${{ steps.goversion.outputs.goversion }}
44-
- name: Run golangci-lint
45-
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
46-
with:
47-
version: v2.1.6
48-
49-
- name: Build for android/${{ matrix.goarch }}
50-
run: |
51-
GOOS=android GOARCH=${{ matrix.goarch }} go build ./...
52-
13+
uses: ./.github/workflows/cross-arch-template.yaml
14+
with:
15+
os: android
16+
archs: "['arm64']"
5317
build-linux:
54-
strategy:
55-
matrix:
56-
goarch: [386, amd64, arm, arm64, loong64, mips, mips64, mips64le, mipsle, ppc64, ppc64le, riscv64, s390x]
57-
runs-on: ubuntu-latest
58-
steps:
59-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
60-
- id: goversion
61-
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
62-
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
63-
with:
64-
go-version: ${{ steps.goversion.outputs.goversion }}
65-
- name: Run golangci-lint
66-
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
67-
with:
68-
version: v2.1.6
69-
70-
- name: Build for linux/${{ matrix.goarch }}
71-
run: |
72-
GOOS=linux GOARCH=${{ matrix.GOARCH }} go build ./...
73-
18+
uses: ./.github/workflows/cross-arch-template.yaml
19+
with:
20+
os: linux
21+
archs: "['386','amd64','arm','arm64','loong64','mips','mips64','mips64le','mipsle','ppc64','ppc64le','riscv64','s390x']"
7422
build-openbsd:
75-
strategy:
76-
matrix:
77-
goarch: [386, amd64, arm, arm64, ppc64, riscv64]
78-
runs-on: ubuntu-latest
79-
steps:
80-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
81-
- id: goversion
82-
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
83-
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
84-
with:
85-
go-version: ${{ steps.goversion.outputs.goversion }}
86-
- name: Run golangci-lint
87-
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
88-
with:
89-
version: v2.1.6
90-
91-
- name: Build for openbsd/${{ matrix.goarch }}
92-
run: |
93-
GOOS=openbsd GOARCH=${{ matrix.GOARCH }} go build ./...
94-
23+
uses: ./.github/workflows/cross-arch-template.yaml
24+
with:
25+
os: openbsd
26+
archs: "['386','amd64','arm','arm64','ppc64','riscv64']"
9527
build-solaris:
96-
strategy:
97-
matrix:
98-
goarch: [amd64]
99-
runs-on: ubuntu-latest
100-
steps:
101-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
102-
- id: goversion
103-
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
104-
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
105-
with:
106-
go-version: ${{ steps.goversion.outputs.goversion }}
107-
- name: Run golangci-lint
108-
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
109-
with:
110-
version: v2.1.6
111-
112-
- name: Build for solaris/${{ matrix.goarch }}
113-
run: |
114-
GOOS=solaris GOARCH=${{ matrix.GOARCH }} go build ./...
115-
28+
uses: ./.github/workflows/cross-arch-template.yaml
29+
with:
30+
os: solaris
31+
archs: "['amd64']"
11632
build-windows:
117-
strategy:
118-
matrix:
119-
goarch: [386, amd64, arm64]
120-
runs-on: windows-latest
121-
steps:
122-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
123-
- id: goversion
124-
run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT"
125-
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
126-
with:
127-
go-version: ${{ steps.goversion.outputs.goversion }}
128-
- name: Run golangci-lint
129-
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
130-
with:
131-
version: v2.1.6
132-
133-
- name: Build for windows/${{ matrix.goarch }}
134-
run: |
135-
$env:GOOS="windows"; $env:GOARCH="${{ matrix.GOARCH }}"; go build ./...
33+
uses: ./.github/workflows/cross-arch-template.yaml
34+
with:
35+
os: windows
36+
archs: "['386','amd64','arm64']"

0 commit comments

Comments
 (0)