Skip to content

SDP-1875: Implement contract account support for SEP-24 #4037

SDP-1875: Implement contract account support for SEP-24

SDP-1875: Implement contract account support for SEP-24 #4037

Workflow file for this run

name: Go
on:
push:
branches:
- main
pull_request:
workflow_call: # allows this workflow to be called from another workflow
permissions:
contents: read
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 1.24.0
cache: true
cache-dependency-path: go.sum
- name: Run ./gomod.sh
run: ./gomod.sh
- name: Run `[email protected]`
run: |
go install github.com/golangci/golangci-lint/v2/cmd/[email protected]
golangci-lint run
- name: Run `[email protected]`
run: |
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/[email protected]
shadow ./... | { grep -v "generated.go" || true; }
- name: Run `[email protected]`
run: |
go install github.com/nishanths/exhaustive/cmd/[email protected]
exhaustive -default-signifies-exhaustive ./...
- name: Run `[email protected]`
run: |
go install golang.org/x/tools/cmd/[email protected]
output=$(deadcode -test ./... | { grep -v "UnmarshalUInt32" || true; })
if [[ -n "$output" ]]; then
echo "🚨 Deadcode found:"
echo "$output"
exit 1
else
echo "βœ… No deadcode found"
fi
- name: Run `[email protected]`
run: |
go install golang.org/x/tools/cmd/[email protected]
# 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/stellar-disbursement-platform-backend" -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
check-helm-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install NodeJs
uses: actions/setup-node@v6
with:
node-version: 14
- name: Install Helm Readme Generator (@bitnami/readme-generator-for-helm)
run: npm install -g @bitnami/[email protected]
- name: Generate README.md for comparison
run: readme-generator -v helmchart/sdp/values.yaml -r helmchart/sdp/README.md
- name: Check if helmchart/sdp/README.md is in sync with helmchart/sdp/values.yaml
run: |
if git diff --exit-code --stat helmchart/sdp/README.md; then
echo "βœ… helmchart/sdp/README.md is in sync with helmchart/sdp/values.yaml"
else
echo "🚨 helmchart/sdp/README.md needs to be re-generated!"
echo "Run 'readme-generator -v helmchart/sdp/values.yaml -r helmchart/sdp/README.md' locally and commit the changes."
echo "Refer to https://github.com/bitnami/readme-generator-for-helm for more information."
exit 1
fi
check-sep24-react-dist:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install NodeJs
uses: actions/setup-node@v6
with:
node-version: 20
- name: Install dependencies
working-directory: internal/serve/sep24frontend/app
run: yarn install
- name: Build React app
working-directory: internal/serve/sep24frontend/app
run: yarn build
- name: Check If `sep24frontend/app/dist` folder is in sync
run: |
if [[ -z $(git status --porcelain) ]]; then
echo "βœ… dist folder is in sync"
else
echo "🚨 dist folder is not in sync"
exit 1
fi
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 1.24.0
cache: true
cache-dependency-path: go.sum
- name: Build Project
run: go build ./...
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12-alpine
env:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
PGHOST: localhost
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
PGHOST: localhost
PGPORT: 5432
PGUSER: postgres
PGPASSWORD: postgres
PGDATABASE: postgres
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: 1.24.0
cache: true
cache-dependency-path: go.sum
- name: Install [email protected]
run: go install gotest.tools/[email protected]
- name: Run tests
run: gotestsum --format-hide-empty-pkg --format pkgname-and-test-fails -- -coverprofile=c.out ./... -timeout 3m -coverpkg ./...
- name: Validate Test Coverage Threshold
env:
TESTCOVERAGE_THRESHOLD: 84 # percentage
run: |
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
complete:
if: always()
needs: [check, check-helm-readme, build, test]
runs-on: ubuntu-latest
steps:
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1