CI/CD for a Fiber Web Service with GitHub Actions
Vet, lint, test, and build your Fasthttp-based Fiber service.
Fiber is an Express-inspired Go framework built on fasthttp. Its CI mirrors any Go service: vet, lint, test, build. This recipe produces a static binary and a tiny deploy image.
What the pipeline does
- set up Go with module caching
- run go vet
- lint with golangci-lint
- run tests
- build a static binary and container
The workflow
A standard Go pipeline. Fiber uses fasthttp, so use Fiber test helpers rather than net/http/httptest for handler tests.
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
- run: go vet ./...
- uses: golangci/golangci-lint-action@v6
- run: go test ./...
- run: CGO_ENABLED=0 go build -o server ./...
- uses: actions/upload-artifact@v4
with:
name: server
path: serverCaching and speed
setup-go caches modules and build output keyed on go.sum. Go test suites are fast, so CI is dominated by linting and compiles on larger services; cheaper managed runners such as Latchkey (around 69% cheaper than GitHub-hosted) keep them quick and auto-retry transient failures.
Deploying
Package the static binary in a scratch or distroless image and deploy to ECS, Cloud Run, Fly.io, or Kubernetes. Fiber reads config from env vars cleanly, so the same image runs across environments by changing the environment configuration.
Key takeaways
- Fiber is built on fasthttp; use its test helpers.
- setup-go caches modules and build output.
- Ship a static binary in a scratch image.