Skip to content

[SDP-1318] Update /wallet-registration/verification to accommodate different contact info fields #2107

[SDP-1318] Update /wallet-registration/verification to accommodate different contact info fields

[SDP-1318] Update /wallet-registration/verification to accommodate different contact info fields #2107

Workflow file for this run

name: Go
on:
push:
branches:
- main
pull_request:
workflow_call: # allows this workflow to be called from another workflow
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.22.1
cache: true
cache-dependency-path: go.sum
- name: golangci-lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # version v6.1.0
with:
version: v1.56.2 # this is the golangci-lint version
args: --timeout 5m0s
- name: Run ./gomod.sh
run: ./gomod.sh
- name: Install nishanths/exhaustive@v0.12.0, deadcode@v0.18.0 and goimports@v0.22.0
run: |
go install github.com/nishanths/exhaustive/cmd/exhaustive@v0.12.0
go install golang.org/x/tools/cmd/deadcode@v0.18.0
go install golang.org/x/tools/cmd/goimports@v0.22.0
- name: Run `exhaustive`
run: exhaustive -default-signifies-exhaustive ./...
- name: Run `deadcode`
run: |
output=$(deadcode -test ./...)
if [[ -n "$output" ]]; then
echo "🚨 Deadcode found:"
echo "$output"
exit 1
else
echo "βœ… No deadcode found"
fi
- name: Run `goimports`
run: |
# 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@v4
- name: Install NodeJs
uses: actions/setup-node@v4
with:
node-version: 14
- name: Install Helm Readme Generator (@bitnami/readme-generator-for-helm)
run: npm install -g @bitnami/readme-generator-for-helm
- 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
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.22.1
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@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22.1
cache: true
cache-dependency-path: go.sum
- name: Install gotestsum@v1.11.0
run: go install gotest.tools/gotestsum@v1.11.0
- 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