Repository navigation
177 lines (169 loc) · 6.62 KB
/
Copy pathci.yml
File metadata and controls
177 lines (169 loc) · 6.62 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
name: ci
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
# Copied from go-notebook/notebook's ci.yml and adapted in two ways:
#
# - every lane runs twice where it matters, on rbgo's default build and on
# its rbgo_core build (-tags rbgo_core: the language and the numeric stack,
# no gem), which is what a notebook worker and a browser page link;
# - the cross-compile lane covers the targets rbgo itself builds for (its
# release matrix plus js/wasm), not every GOOS/GOARCH: rbgo's internal/vm
# does not compile for plan9, aix, solaris, illumos, the BSDs or 32-bit
# targets, so neither can anything that embeds it.
jobs:
test:
name: test (${{ matrix.os }}, ${{ matrix.tags || 'default' }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
tags: ['', rbgo_core]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: '1.27.3'
- run: go version
# Not on Windows: its checkout converts line endings to CRLF.
- name: gofmt
if: runner.os != 'Windows'
shell: bash
run: |
unformatted=$(gofmt -l .)
[ -z "$unformatted" ] || { echo "::error::not gofmt-formatted:"; echo "$unformatted"; exit 1; }
- run: go vet -tags "${{ matrix.tags }}" ./...
- run: go build -tags "${{ matrix.tags }}" ./...
- name: Test + 100% coverage gate
shell: bash
run: |
COVERPKG=$(go list ./... | paste -sd, -)
go test -tags "${{ matrix.tags }}" -race -coverpkg="$COVERPKG" -coverprofile=cover.out ./...
go tool cover -func=cover.out | tail -n 25
cov=$(go tool cover -func=cover.out | tail -1 | awk '{print $3}' | tr -d '%')
echo "coverage: ${cov}%"
awk -v t="$cov" 'BEGIN { exit !(t+0 >= 100.0) }' || {
echo "::error::coverage ${cov}% < 100%"; exit 1; }
security:
name: govulncheck + fuzz
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: '1.27.3'
- name: govulncheck
run: go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./...
- name: Fuzz the binding arguments for 60 s
run: go test -tags rbgo_core -run '^$' -fuzz FuzzBindingArguments -fuzztime 60s .
arch-native:
name: arch arm64
runs-on: ubuntu-26.04-arm
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: '1.27.3'
- run: go vet ./... && go test ./... && go test -tags rbgo_core ./...
arch-qemu:
name: arch ${{ matrix.goarch }} (qemu)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- { goarch: riscv64, qemu: qemu-riscv64-static }
- { goarch: loong64, qemu: qemu-loongarch64-static }
- { goarch: ppc64le, qemu: qemu-ppc64le-static }
- { goarch: s390x, qemu: qemu-s390x-static }
# 32-bit: int is 32 bits.
- { goarch: arm, qemu: qemu-arm-static }
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: '1.27.3'
# ⛔ `qemu-user-static` is a VIRTUAL package on Ubuntu 26.04, which
# `ubuntu-latest` became on 2026-10-19, and apt refuses to choose between its
# two providers:
#
# E: Package 'qemu-user-static' has no installation candidate
#
# ⚠ Installing a provider is NOT the fix: `qemu-user-binfmt` registers binfmt
# handlers, it does not ship the `qemu-<arch>-static` binaries this lane
# invokes. `qemu-user` ships the dynamic `qemu-<arch>`, which is all that
# `go test -exec` needs, so both are installed and BOTH NAMES are accepted
# below. go-tex/engine#645 has the full account.
- name: install qemu user-mode emulators
timeout-minutes: 10
run: sudo apt-get update && sudo apt-get install -y qemu-user qemu-user-binfmt
- name: Vet + test under qemu (${{ matrix.goarch }})
run: |
base="${{ matrix.qemu }}"
q=""
for cand in "$base" "${base%-static}"; do
command -v "$cand" >/dev/null 2>&1 && q="$cand" && break
done
# ⛔ A missing emulator FAILS this lane. A lane that reports success for
# an architecture it never ran is the one outcome this matrix exists to
# rule out.
if [ -z "$q" ]; then
echo "::error::no qemu user emulator for ${{ matrix.goarch }} (looked for $base and ${base%-static})"
exit 1
fi
# Printed on purpose: without it, "ran under emulation" and "skipped" are
# indistinguishable from a green tick.
echo "running ${{ matrix.goarch }} under $q"
GOARCH=${{ matrix.goarch }} go test -tags rbgo_core -short -exec="$q" ./...
# 386 runs natively on the amd64 runner (the kernel executes 32-bit x86
# binaries), not under qemu-i386, whose emulation loses x87/SSE state across
# preemption.
arch-386:
name: arch 386
runs-on: ubuntu-latest
env:
CGO_ENABLED: "0"
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: '1.27.3'
- name: Vet + test (GOARCH=386), both builds
run: |
GOARCH=386 go vet ./...
GOARCH=386 go test ./...
GOARCH=386 go test -tags rbgo_core ./...
cross:
name: compile on every target rbgo builds for
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: '1.27.3'
# Since rbgo v0.8.3 that is every `go tool dist list` pair but plan9
# (go-embedded-ruby/ruby#832). go vet type-checks every package and its
# tests without linking; android and ios link only through cgo, so their
# library packages are built instead.
- name: go vet for each target, both builds
shell: bash
env:
CGO_ENABLED: "0"
run: |
fail=0
for t in $(go tool dist list | grep -v '^plan9/'); do
os=${t%/*}; arch=${t#*/}
for tags in "" rbgo_core; do
case $os in
android|ios) cmd="go build -tags=$tags $(go list -f '{{if ne .Name "main"}}{{.ImportPath}}{{end}}' ./...)" ;;
*) cmd="go vet -tags=$tags ./..." ;;
esac
GOOS=$os GOARCH=$arch $cmd >/dev/null 2>err.txt || { echo "::error::$t [$tags]"; cat err.txt; fail=1; }
done
done
exit $fail