Skip to content

Commit

Permalink
[Chore] Reformat the imports using goimports and enforce it through…
Browse files Browse the repository at this point in the history
… a GH Action (#337)

### What

Reformat the imports using `goimports -local "github.com/stellar/stellar-disbursement-platform-backend" -w .`
Also, enforce the goimports format through a GH Action

### Why

To keep the imports organized and consistent across the project
  • Loading branch information
marcelosalloum authored Jul 9, 2024
1 parent edb624e commit ae879fd
Show file tree
Hide file tree
Showing 129 changed files with 284 additions and 166 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ jobs:
- name: Run ./gomod.sh
run: ./gomod.sh

- name: Install github.com/nishanths/[email protected] and golang.org/x/tools/cmd/[email protected]
- name: Install nishanths/[email protected], [email protected].0 and [email protected].0
run: |
go install github.com/nishanths/exhaustive/cmd/[email protected]
go install golang.org/x/tools/cmd/[email protected]
go install golang.org/x/tools/cmd/[email protected]
- name: Run `exhaustive`
run: exhaustive -default-signifies-exhaustive ./...
Expand All @@ -55,6 +56,19 @@ jobs:
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:
Expand Down
3 changes: 2 additions & 1 deletion cmd/integration_tests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
"testing"

"github.com/spf13/cobra"
"github.com/stellar/stellar-disbursement-platform-backend/internal/integrationtests"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/internal/integrationtests"
)

type mockIntegrationTests struct {
Expand Down
1 change: 1 addition & 0 deletions cmd/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/spf13/cobra"
"github.com/stellar/go/support/config"
"github.com/stellar/go/support/log"

cmdUtils "github.com/stellar/stellar-disbursement-platform-backend/cmd/utils"
"github.com/stellar/stellar-disbursement-platform-backend/internal/message"
)
Expand Down
5 changes: 3 additions & 2 deletions cmd/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"testing"

"github.com/spf13/cobra"
cmdUtils "github.com/stellar/stellar-disbursement-platform-backend/cmd/utils"
"github.com/stellar/stellar-disbursement-platform-backend/internal/message"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

cmdUtils "github.com/stellar/stellar-disbursement-platform-backend/cmd/utils"
"github.com/stellar/stellar-disbursement-platform-backend/internal/message"
)

type mockMessengerService struct {
Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/spf13/cobra"
"github.com/stellar/go/support/config"
"github.com/stellar/go/support/log"

"github.com/stellar/stellar-disbursement-platform-backend/cmd/db"
cmdUtils "github.com/stellar/stellar-disbursement-platform-backend/cmd/utils"
"github.com/stellar/stellar-disbursement-platform-backend/internal/monitor"
Expand Down
3 changes: 2 additions & 1 deletion cmd/utils/global_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package utils
import (
"testing"

"github.com/stellar/stellar-disbursement-platform-backend/internal/crashtracker"
"github.com/stretchr/testify/assert"

"github.com/stellar/stellar-disbursement-platform-backend/internal/crashtracker"
)

func Test_globalOptions_PopulateCrashTrackerOptions(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion db/db_connection_pool_with_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"testing"

"github.com/jmoiron/sqlx"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
)

func TestConnectionPoolWithRouter_BeginTxx(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion db/router/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"strings"
"testing"

"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
)

func Test_GetDSNForAdmin(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions db/sql_exec_with_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/jmoiron/sqlx"
"github.com/stellar/go/support/log"

"github.com/stellar/stellar-disbursement-platform-backend/internal/monitor"
)

Expand Down
3 changes: 2 additions & 1 deletion db/sql_exec_with_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"fmt"
"testing"

"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
)

type MockDataSourceRouter struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/anchorplatform/platform_api_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"strings"

"github.com/gorilla/schema"

"github.com/stellar/go/support/log"

"github.com/stellar/stellar-disbursement-platform-backend/internal/serve/httpclient"
"github.com/stellar/stellar-disbursement-platform-backend/internal/utils"
)
Expand Down
4 changes: 2 additions & 2 deletions internal/anchorplatform/sep24_auth_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"net/http"
"strings"

"github.com/stellar/stellar-disbursement-platform-backend/stellar-multitenant/pkg/tenant"

"github.com/stellar/go/network"
"github.com/stellar/go/support/http/httpdecode"
"github.com/stellar/go/support/log"

"github.com/stellar/stellar-disbursement-platform-backend/internal/serve/httperror"
"github.com/stellar/stellar-disbursement-platform-backend/internal/utils"
"github.com/stellar/stellar-disbursement-platform-backend/stellar-multitenant/pkg/tenant"
)

type ContextType string
Expand Down
1 change: 1 addition & 0 deletions internal/anchorplatform/sep24_jwt_claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/golang-jwt/jwt/v4"
"github.com/stellar/go/keypair"

"github.com/stellar/stellar-disbursement-platform-backend/internal/utils"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/data/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"time"

"github.com/lib/pq"

"github.com/stellar/go/protocols/horizon/base"

"github.com/stellar/stellar-disbursement-platform-backend/db"
)

Expand Down
5 changes: 3 additions & 2 deletions internal/data/assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"time"

"github.com/stellar/go/protocols/horizon/base"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
"github.com/stellar/stellar-disbursement-platform-backend/internal/message"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func Test_Asset_IsNative(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions internal/data/countries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
"testing"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
)

func Test_CountryModelGet(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions internal/data/disbursement_instructions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"database/sql"
"testing"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
)

func Test_DisbursementInstructionModel_ProcessAll(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion internal/data/disbursement_receivers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"context"
"testing"

"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
"github.com/stretchr/testify/require"
)

func Test_DisbursementReceiverModel_Count(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions internal/data/disbursements.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/lib/pq"
"github.com/stellar/go/support/log"

"github.com/stellar/stellar-disbursement-platform-backend/db"
)

Expand Down
5 changes: 3 additions & 2 deletions internal/data/disbursements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"testing"
"time"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
)

func Test_DisbursementModelInsert(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion internal/data/fixtures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"strings"
"testing"

"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
"github.com/stretchr/testify/require"
)

func Test_CreateReceiverFixture(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions internal/data/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/lib/pq"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/internal/message"
)
Expand Down
5 changes: 3 additions & 2 deletions internal/data/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
"github.com/stellar/stellar-disbursement-platform-backend/internal/message"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func Test_MessageModel_Insert(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion internal/data/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package data
import (
"testing"

"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
"github.com/stretchr/testify/require"
)

func Test_NewModels(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions internal/data/organizations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
"image/png"
"testing"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
)

func Test_Organizations_DatabaseTriggers(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions internal/data/receiver_verification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"testing"
"time"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
)

func Test_ReceiverVerificationModel_GetByReceiverIDsAndVerificationField(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions internal/data/receivers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (
"time"

"github.com/lib/pq"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
"github.com/stellar/stellar-disbursement-platform-backend/internal/message"
"github.com/stellar/stellar-disbursement-platform-backend/internal/utils"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func Test_ReceiversModelGet(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/data/receivers_wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"time"

"github.com/lib/pq"

"github.com/stellar/go/network"
"github.com/stellar/go/support/log"

"github.com/stellar/stellar-disbursement-platform-backend/db"
)

Expand Down
5 changes: 3 additions & 2 deletions internal/data/receivers_wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import (
"time"

"github.com/stellar/go/network"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
"github.com/stellar/stellar-disbursement-platform-backend/internal/message"
"github.com/stellar/stellar-disbursement-platform-backend/internal/utils"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func Test_ReceiversWalletModelGetWithReceiverId(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions internal/data/wallets.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/lib/pq"

"github.com/stellar/stellar-disbursement-platform-backend/db"
)

Expand Down
5 changes: 3 additions & 2 deletions internal/data/wallets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
"testing"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/stellar/stellar-disbursement-platform-backend/db"
"github.com/stellar/stellar-disbursement-platform-backend/db/dbtest"
)

func Test_WalletModelGet(t *testing.T) {
Expand Down
Loading

0 comments on commit ae879fd

Please sign in to comment.