Merge pull request #9 from Treefle-labs/chore/modules #28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go CI/CD Pipeline | |
on: | |
push: | |
branches: [ "main", "develop" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
test: | |
name: Build & Test All Modules | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
- name: Find Go Modules | |
id: find-modules | |
run: | | |
echo "modules=$(find . -name 'go.mod' -not -path './go.work' -exec dirname {} \; | tr '\n' ' ')" >> $GITHUB_OUTPUT | |
- name: Run go test in each module | |
run: | | |
for module in ${{ steps.find-modules.outputs.modules }}; do | |
echo "📦 Testing $module" | |
cd $module | |
go mod tidy | |
go test -v -race -cover ./... | |
cd - | |
done | |
- name: Run golangci-lint in each module | |
run: | | |
for module in ${{ steps.find-modules.outputs.modules }}; do | |
echo "🔍 Linting $module" | |
cd $module | |
golangci-lint run --timeout=2m | |
cd - | |
done |