Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CI

on:
push:
branches: [main, rewrite/go]
pull_request:
branches: [main, rewrite/go]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['1.23', '1.24']

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Download dependencies
run: go mod download

- name: Vet
run: go vet ./...

- name: Test
run: go test ./... -count=1 -timeout 120s

- name: Build
run: go build -trimpath -ldflags "-s -w" -o gpu-benchmark ./cmd/gpu-benchmark

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: gpu-benchmark-linux-amd64-go${{ matrix.go-version }}
path: gpu-benchmark

cross-compile:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'

- name: Cross-compile
run: make cross-compile

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: gpu-benchmark-binaries
path: dist/
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Release

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
verify-main:
runs-on: ubuntu-latest
outputs:
is_main: ${{ steps.check.outputs.is_main }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check tag is on main
id: check
run: |
git fetch origin main
if git merge-base --is-ancestor "$(git rev-parse HEAD)" origin/main; then
echo "is_main=true" >> "$GITHUB_OUTPUT"
echo "✅ Tag is on main"
else
echo "is_main=false" >> "$GITHUB_OUTPUT"
echo "❌ Tag is NOT on main — skipping release"
fi

release:
runs-on: ubuntu-latest
needs: verify-main
if: needs.verify-main.outputs.is_main == 'true'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'

- name: Cross-compile binaries
run: make cross-compile

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
prerelease: ${{ contains(github.ref_name, '-rc') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-alpha') }}
files: |
dist/gpu-benchmark-linux-amd64
dist/gpu-benchmark-linux-arm64
dist/gpu-benchmark-darwin-arm64
19 changes: 15 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
node_modules/
results/
dist/
gpu-benchmark
# Build artifacts
/gpu-benchmark
/dist/
/results/

# Go
*.exe
*.exe~
*.dll
*.so
*.dylib
*.test
*.out

# OS
.DS_Store
53 changes: 53 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
BINARY := gpu-benchmark
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS := -ldflags "-s -w -X main.version=$(VERSION)"
GO := go
GOFLAGS := -trimpath

.PHONY: build run test clean install cross-compile

## build: Build the binary for the current platform
build:
$(GO) build $(GOFLAGS) $(LDFLAGS) -o $(BINARY) ./cmd/gpu-benchmark

## run: Run directly without building
run:
$(GO) run ./cmd/gpu-benchmark $(ARGS)

## test: Run tests
test:
$(GO) test ./... -v -count=1

## clean: Remove built binary
clean:
rm -f $(BINARY)

## install: Install to $GOPATH/bin
install:
$(GO) install $(GOFLAGS) $(LDFLAGS) ./cmd/gpu-benchmark

## cross-compile: Build for all target platforms
cross-compile:
GOOS=linux GOARCH=amd64 $(GO) build $(GOFLAGS) $(LDFLAGS) -o dist/$(BINARY)-linux-amd64 ./cmd/gpu-benchmark
GOOS=linux GOARCH=arm64 $(GO) build $(GOFLAGS) $(LDFLAGS) -o dist/$(BINARY)-linux-arm64 ./cmd/gpu-benchmark
GOOS=darwin GOARCH=arm64 $(GO) build $(GOFLAGS) $(LDFLAGS) -o dist/$(BINARY)-darwin-arm64 ./cmd/gpu-benchmark

## tidy: Tidy go modules
tidy:
$(GO) mod tidy

## release TAG=v0.x.x: Tag latest main and push to trigger release
release:
@if [ -z "$(TAG)" ]; then echo "Usage: make release TAG=v0.2.0"; exit 1; fi
git fetch origin main
git tag $(TAG) origin/main
git push origin $(TAG)
@echo "✅ Tagged $(TAG) on origin/main — release workflow triggered"

## bench: Quick benchmark run (dev helper)
bench:
$(GO) run ./cmd/gpu-benchmark run --model-id Qwen/Qwen3-8B --gpu-rate 2.00 --dry-run

## help: Show this help
help:
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## //'
Loading
Loading