SDP-1875: Implement contract account support for SEP-24 #4037
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 | |
| 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 |