Monorepo Setup¶
Configure Go Gamma Actions for repositories with multiple Go modules.
Overview¶
A monorepo contains multiple Go modules:
my-monorepo/
├── api/
│ ├── go.mod
│ └── main.go
├── worker/
│ ├── go.mod
│ └── main.go
└── shared/
├── go.mod
└── lib.go
Configuration¶
Parallel CI for Each Module¶
name: CI
on: [push, pull_request]
jobs:
ci-api:
uses: go-gamma/actions/.github/workflows/ci.yml@v1
with:
go-version: '1.24'
working-directory: './api'
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
ci-worker:
uses: go-gamma/actions/.github/workflows/ci.yml@v1
with:
go-version: '1.24'
working-directory: './worker'
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
ci-shared:
uses: go-gamma/actions/.github/workflows/ci.yml@v1
with:
go-version: '1.24'
working-directory: './shared'
skip-build: true # Library only
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Path-Based Triggers¶
Only run CI when relevant files change:
on:
push:
paths:
- 'api/**'
pull_request:
paths:
- 'api/**'
jobs:
ci-api:
uses: go-gamma/actions/.github/workflows/ci.yml@v1
with:
working-directory: './api'
Matrix Strategy¶
For simpler configuration:
jobs:
ci:
strategy:
matrix:
module: [api, worker, shared]
uses: go-gamma/actions/.github/workflows/ci.yml@v1
with:
go-version: '1.24'
working-directory: './${{ matrix.module }}'
Codecov Configuration¶
Create codecov.yml in repository root:
coverage:
status:
project:
default:
target: 80%
patch:
default:
target: 80%
flags:
api:
paths:
- api/
worker:
paths:
- worker/
shared:
paths:
- shared/
Update workflows to use flags:
jobs:
ci-api:
uses: go-gamma/actions/.github/workflows/test.yml@v1
with:
working-directory: './api'
# Coverage will be tagged with directory name
Release Strategy¶
Independent Versioning¶
Each module gets its own tags:
Configure releases:
name: Release API
on:
push:
tags:
- 'api/v*.*.*'
jobs:
release:
uses: go-gamma/actions/.github/workflows/release.yml@v1
with:
working-directory: './api'
Unified Versioning¶
Single version for all modules: