Skip to content

fix(balances): derive is_funded from native balance, hide balances wh… #311

fix(balances): derive is_funded from native balance, hide balances wh…

fix(balances): derive is_funded from native balance, hide balances wh… #311

Workflow file for this run

name: Go
on:
push:
branches: [main]
pull_request:
branches: ["**"]
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.25"
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.5.0
args: --timeout=5m
- name: Run `shadow@v0.44.0`
run: |
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@v0.44.0
shadow ./...
- name: Run `deadcode@v0.44.0`
run: |
go install golang.org/x/tools/cmd/deadcode@v0.44.0
output=$(deadcode -test ./...)
if [[ -n "$output" ]]; then
echo "🚨 Deadcode found:"
echo "$output"
exit 1
else
echo "✅ No deadcode found"
fi
- name: Run `goimports@v0.44.0`
run: |
go install golang.org/x/tools/cmd/goimports@v0.44.0
# Find all .go files excluding paths containing 'mock' and run goimports
non_compliant_files=$(find . -type f -name "*.go" ! -path "*mock*" | xargs goimports -local "github.com/stellar/freighter-backend-v2" -l)
if [ -n "$non_compliant_files" ]; then
echo "🚨 The following files are not compliant with goimports:"
echo "$non_compliant_files"
exit 1
else
echo "✅ All files are compliant with goimports."
fi
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.25"
cache: true
- name: Build Project
run: go build ./...
unit-test:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.25"
cache: true
- name: Run Unit Tests
env:
ENABLE_INTEGRATION_TESTS: "false"
run: go test -v -race -cover -coverprofile=c.out ./...
- name: Validate Test Coverage Threshold
env:
TESTCOVERAGE_THRESHOLD: 80 # percentage
run: |
chmod +x ./scripts/exclude_from_coverage.sh # Add execute permissions
echo "Quality Gate: Checking if test coverage is above threshold..."
echo "Threshold: $TESTCOVERAGE_THRESHOLD%"
totalCoverage=`./scripts/exclude_from_coverage.sh && go tool cover -func=c.out | grep total: | grep -Eo '[0-9]+\.[0-9]+'`
echo "Test Coverage: $totalCoverage%"
echo "-------------------------"
if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 >= $2)}') )); then
echo " $totalCoverage% > $TESTCOVERAGE_THRESHOLD%"
echo "Current test coverage is above threshold 🎉🎉🎉! Please keep up the good work!"
else
echo " $totalCoverage% < $TESTCOVERAGE_THRESHOLD%"
echo "🚨 Current test coverage is below threshold 😱! Please add more unit tests or adjust threshold to a lower value."
echo "Failed 😭"
exit 1
fi
integration-test:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.25"
cache: true
- name: Run Integration Tests
env:
ENABLE_INTEGRATION_TESTS: "true"
run: go test -v -race -cover ./internal/integrationtests/... ./internal/db/...