-
-
Notifications
You must be signed in to change notification settings - Fork 1
108 lines (92 loc) · 3.65 KB
/
Copy pathbuild.yml
File metadata and controls
108 lines (92 loc) · 3.65 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
name: CI
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
env:
RUNS_ON: ${{ github.event_name == 'pull_request' && 'ubuntu-latest' || 'self-hosted' }}
GO_VERSION: '1.25.0'
jobs:
test-and-cover:
runs-on: ${{ github.event_name == 'pull_request' && 'ubuntu-latest' || 'self-hosted' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Set cache to /tmp
run: |
echo "GOCACHE=/tmp/go-build-cache" >> $GITHUB_ENV
echo "GOMODCACHE=/tmp/go-mod-cache" >> $GITHUB_ENV
mkdir -p /tmp/go-build-cache /tmp/go-mod-cache
go clean -cache
shell: bash
- name: Run Go tests
run: go test -v $(go list ./... | grep -v fz/internal/musl)
- name: Run Go coverage
run: go test -cover $(go list ./... | grep -v fz/internal/musl)
race-detector:
runs-on: ${{ github.event_name == 'pull_request' && 'ubuntu-latest' || 'self-hosted' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Set cache to /tmp
run: |
echo "GOCACHE=/tmp/go-build-cache" >> $GITHUB_ENV
echo "GOMODCACHE=/tmp/go-mod-cache" >> $GITHUB_ENV
mkdir -p /tmp/go-build-cache /tmp/go-mod-cache
shell: bash
- name: Run Go race detector
run: go test -race -cpu 4 $(go list ./... | grep -v fz/internal/musl)
benchmarks:
runs-on: ${{ github.event_name == 'pull_request' && 'ubuntu-latest' || 'self-hosted' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Set cache to /tmp
run: |
echo "GOCACHE=/tmp/go-build-cache" >> $GITHUB_ENV
echo "GOMODCACHE=/tmp/go-mod-cache" >> $GITHUB_ENV
mkdir -p /tmp/go-build-cache /tmp/go-mod-cache
go clean -cache
shell: bash
- name: Benchmark Go Code and allocations count
run: go test -bench=. -benchmem $(go list ./... | grep -v fz/internal/musl)
build:
runs-on: ${{ github.event_name == 'pull_request' && 'ubuntu-latest' || 'self-hosted' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Set cache to /tmp
run: |
echo "GOCACHE=/tmp/go-build-cache" >> $GITHUB_ENV
echo "GOMODCACHE=/tmp/go-mod-cache" >> $GITHUB_ENV
mkdir -p /tmp/go-build-cache /tmp/go-mod-cache
go clean -cache
shell: bash
- name: Cross-compile all platforms
run: |
set -e
mkdir -p release
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -p 4 -buildvcs=false -ldflags="-s -w" -o release/fz-linux-amd64 ./cmd/fz
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -p 4 -buildvcs=false -ldflags="-s -w" -o release/fz-linux-arm64 ./cmd/fz
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -p 4 -buildvcs=false -ldflags="-s -w" -o release/fz-windows-amd64.exe ./cmd/fz
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -p 4 -buildvcs=false -ldflags="-s -w" -o release/fz-darwin-amd64 ./cmd/fz
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -p 4 -buildvcs=false -ldflags="-s -w" -o release/fz-darwin-arm64 ./cmd/fz
ls -la release/
- name: Upload compiled binaries
uses: actions/upload-artifact@v4
with:
name: fz-binaries
path: release/