-
-
Notifications
You must be signed in to change notification settings - Fork 33
188 lines (165 loc) · 6.16 KB
/
Copy pathgo.yml
File metadata and controls
188 lines (165 loc) · 6.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: Go
on:
push:
branches: [ master ]
tags:
- '*.*.*' # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request:
branches: [ master ]
jobs:
test:
name: Lint and Test
runs-on: ubuntu-latest
steps:
- name: Install libsensors-dev (needed for gosensors testing)
run: sudo apt-get install -y libsensors-dev
- name: Checkout the repository
uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: '^1.23'
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9.3.0
with:
version: latest
skip-cache: false
- name: Test
run: make test
build:
name: Build linux/${{ matrix.goarch }}
runs-on: ${{ matrix.runner }}
needs: test
strategy:
fail-fast: false
matrix:
include:
- goarch: amd64
runner: ubuntu-latest
native: true
make_target: build
- goarch: arm64
runner: ubuntu-24.04-arm
native: true
make_target: build
- goarch: ppc64le
runner: ubuntu-24.04
native: false
make_target: build-cross
cc: powerpc64le-linux-gnu-gcc
dpkg_arch: ppc64el
cross_pkg: crossbuild-essential-ppc64el
libsensors_pkg: libsensors-dev:ppc64el
qemu_bin: qemu-ppc64le-static
- goarch: s390x
runner: ubuntu-24.04
native: false
make_target: build-cross
cc: s390x-linux-gnu-gcc
dpkg_arch: s390x
cross_pkg: crossbuild-essential-s390x
libsensors_pkg: libsensors-dev:s390x
qemu_bin: qemu-s390x-static
- goarch: riscv64
runner: ubuntu-24.04
native: false
make_target: build-cross
cc: riscv64-linux-gnu-gcc
dpkg_arch: riscv64
cross_pkg: crossbuild-essential-riscv64
libsensors_pkg: libsensors-dev:riscv64
qemu_bin: qemu-riscv64-static
steps:
- name: Install libsensors-dev (native)
if: matrix.native
run: sudo apt-get install -y libsensors-dev
- name: Set up multiarch and cross-compilation toolchain
if: ${{ !matrix.native }}
run: |
sudo dpkg --add-architecture ${{ matrix.dpkg_arch }}
# Replace the runner's ubuntu.sources with one pinned to amd64 only.
# The default file uses a mirrorlist URI that also serves ppc64el/s390x
# requests to security.ubuntu.com, which returns 404 for those arches.
sudo tee /etc/apt/sources.list.d/ubuntu.sources > /dev/null << 'EOF'
Types: deb
URIs: http://azure.archive.ubuntu.com/ubuntu
Suites: noble noble-updates noble-backports noble-security
Components: main restricted universe multiverse
Architectures: amd64
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
EOF
# Add ports.ubuntu.com for the foreign arch
printf 'Types: deb\nURIs: http://ports.ubuntu.com/ubuntu-ports\nSuites: noble noble-updates noble-security\nComponents: main restricted universe multiverse\nArchitectures: %s\nSigned-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg\n' "${{ matrix.dpkg_arch }}" | sudo tee /etc/apt/sources.list.d/ports-${{ matrix.dpkg_arch }}.sources
sudo apt-get update
sudo apt-get install -y ${{ matrix.cross_pkg }} ${{ matrix.libsensors_pkg }} qemu-user-static
- name: Checkout the repository
uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: '^1.23'
- name: Generate build files (${{ matrix.goarch }})
env:
CGO_ENABLED: "1"
CC: ${{ matrix.cc }}
GOOS: linux
GOARCH: ${{ matrix.goarch }}
run: |
OUTPUT_BIN="dist/fan2go-linux-${{ matrix.goarch }}"
make ${{ matrix.make_target }} OUTPUT_BIN="${OUTPUT_BIN}"
make ${{ matrix.make_target }}-no-nvml OUTPUT_BIN="${OUTPUT_BIN}-no-nvml"
file "${OUTPUT_BIN}"
file "${OUTPUT_BIN}-no-nvml"
- name: Smoke test (${{ matrix.goarch }})
env:
QEMU_BIN: ${{ matrix.qemu_bin }}
run: |
OUTPUT_BIN="dist/fan2go-linux-${{ matrix.goarch }}"
RUNNER="${QEMU_BIN}"
if [ "${{ matrix.native }}" = "true" ]; then
RUNNER=""
fi
${RUNNER} "${OUTPUT_BIN}" version
${RUNNER} "${OUTPUT_BIN}-no-nvml" version
- name: Nvml check (amd64 only)
if: matrix.goarch == 'amd64'
run: |
set -x
# make sure the no-nvml build *really* doesn't use nvml
# ("nvml" is printed by objdump at least once because of the filename,
# but if nvml is linked, it has hundreds of occurrences)
test `objdump -T ./dist/fan2go-linux-amd64-no-nvml | grep -c nvml` -lt 3
# .. and that the regular build *does* have symbols with "nvml" in it
test `objdump -T ./dist/fan2go-linux-amd64 | grep -c nvml` -ge 3
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: fan2go-linux-${{ matrix.goarch }}
path: dist/fan2go-linux-${{ matrix.goarch }}*
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
needs: build
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: dist/
merge-multiple: true
- name: Release
uses: softprops/action-gh-release@v3
with:
files: |
dist/fan2go-linux-amd64
dist/fan2go-linux-amd64-no-nvml
dist/fan2go-linux-arm64
dist/fan2go-linux-arm64-no-nvml
dist/fan2go-linux-ppc64le
dist/fan2go-linux-ppc64le-no-nvml
dist/fan2go-linux-s390x
dist/fan2go-linux-s390x-no-nvml
dist/fan2go-linux-riscv64
dist/fan2go-linux-riscv64-no-nvml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}