Skip to content

Commit 89cd744

Browse files
authored
Merge pull request #33 from YaRissi/ci
feat: testing ci with linter
2 parents 694b4f8 + 9f5a44b commit 89cd744

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+915
-651
lines changed

.github/pull_request_template.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Changes
2+
3+
-
4+
5+
## Issues & Discussions
6+
7+
- fix #

.github/workflows/test.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Testing CLI
2+
3+
on:
4+
push:
5+
branches: ["v4.x"]
6+
pull_request:
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v5
14+
15+
- name: Run gofmt
16+
run: diff -u <(echo -n) <(gofmt -d -s .)
17+
18+
- name: Run golangci-lint
19+
uses: golangci/golangci-lint-action@v8
20+
with:
21+
version: v2.5.0 # pin version for consistency
22+
23+
test:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v5
28+
29+
- name: Set up Go
30+
uses: actions/setup-go@v5
31+
with:
32+
go-version-file: 'go.mod'
33+
34+
- name: Run tests
35+
run: go test -v -race -cover ./...
36+
37+
go-mod-tidy:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v5
42+
43+
- name: Set up Go
44+
uses: actions/setup-go@v5
45+
with:
46+
go-version-file: 'go.mod'
47+
48+
- name: Run go mod tidy
49+
run: go mod tidy
50+
51+
- name: Check uncommitted changes
52+
run: git diff --exit-code
53+
54+
- if: failure()
55+
run: echo "::error::Check failed, please run 'go mod tidy' and commit the changes."

.golangci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
version: "2"
2+
3+
run:
4+
timeout: 5m
5+
6+
linters:
7+
enable:
8+
- asasalint
9+
- asciicheck
10+
- bidichk
11+
- bodyclose
12+
- contextcheck
13+
- durationcheck
14+
- errchkjson
15+
- errorlint
16+
- exhaustive
17+
- gocheckcompilerdirectives
18+
- gochecksumtype
19+
- gocritic
20+
- gomoddirectives
21+
- gomodguard
22+
- gosec
23+
- gosmopolitan
24+
- loggercheck
25+
- makezero
26+
- musttag
27+
- nilerr
28+
- nilnesserr
29+
- noctx
30+
- protogetter
31+
- reassign
32+
- recvcheck
33+
- revive
34+
- rowserrcheck
35+
- spancheck
36+
- sqlclosecheck
37+
- testifylint
38+
- unparam
39+
- zerologlint
40+
41+
settings:
42+
exhaustive:
43+
default-signifies-exhaustive: true
44+
45+
staticcheck:
46+
checks: ["all", "-ST1005", "-S1016"]
47+
48+
gosec:
49+
excludes:
50+
- G115
51+
52+
gosmopolitan:
53+
allow-time-local: true
54+
55+
exclusions:
56+
generated: lax
57+
presets:
58+
- comments
59+
- common-false-positives
60+
- std-error-handling
61+
62+
formatters:
63+
enable:
64+
- gci
65+
- goimports
66+
67+
settings:
68+
gci:
69+
sections:
70+
- standard
71+
- default
72+
- prefix(github.com/coollabsio)
73+
74+
exclusions:
75+
generated: lax

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func NewListCommand() *cobra.Command {
177177
Use: "list",
178178
Short: "List all myfeature resources",
179179
RunE: func(cmd *cobra.Command, args []string) error {
180-
ctx := context.Background()
180+
ctx := cmd.Context()
181181

182182
// Get API client
183183
client, err := cli.GetAPIClient(cmd)
@@ -330,7 +330,7 @@ func TestMyFeatureService_List(t *testing.T) {
330330
client := api.NewClient(server.URL, "test-token")
331331
svc := NewMyFeatureService(client)
332332

333-
items, err := svc.List(context.Background())
333+
items, err := svc.List(cmd.Context())
334334

335335
require.NoError(t, err)
336336
assert.Len(t, items, 2)

cmd/application/delete.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package application
22

33
import (
4-
"context"
54
"fmt"
65

6+
"github.com/spf13/cobra"
7+
78
"github.com/coollabsio/coolify-cli/internal/cli"
89
"github.com/coollabsio/coolify-cli/internal/service"
9-
"github.com/spf13/cobra"
1010
)
1111

1212
func NewDeleteCommand() *cobra.Command {
@@ -16,15 +16,19 @@ func NewDeleteCommand() *cobra.Command {
1616
Long: `Delete an application. This action cannot be undone.`,
1717
Args: cli.ExactArgs(1, "<uuid>"),
1818
RunE: func(cmd *cobra.Command, args []string) error {
19-
ctx := context.Background()
19+
ctx := cmd.Context()
2020
uuid := args[0]
2121

2222
force, _ := cmd.Flags().GetBool("force")
2323

2424
if !force {
2525
var response string
2626
fmt.Printf("Are you sure you want to delete application %s? This cannot be undone. (yes/no): ", uuid)
27-
fmt.Scanln(&response)
27+
_, err := fmt.Scanln(&response)
28+
29+
if err != nil {
30+
return fmt.Errorf("failed to read input: %w", err)
31+
}
2832

2933
if response != "yes" && response != "y" {
3034
fmt.Println("Delete cancelled.")

cmd/application/env/create.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
package env
22

33
import (
4-
"context"
54
"fmt"
65

6+
"github.com/spf13/cobra"
7+
78
"github.com/coollabsio/coolify-cli/internal/cli"
89
"github.com/coollabsio/coolify-cli/internal/models"
910
"github.com/coollabsio/coolify-cli/internal/service"
10-
"github.com/spf13/cobra"
1111
)
1212

1313
func NewCreateEnvCommand() *cobra.Command {
1414
cmd := &cobra.Command{
1515
Use: "create <app_uuid>",
1616
Short: "Create an environment variable for an application",
1717
Long: `Create a new environment variable for a specific application. Use --key and --value flags to specify the variable.`,
18-
Args: cli.ExactArgs(1, "<uuid>"),
18+
Args: cli.ExactArgs(1, "<app_uuid>"),
1919
RunE: func(cmd *cobra.Command, args []string) error {
20-
ctx := context.Background()
21-
uuid := args[0]
20+
ctx := cmd.Context()
21+
appUUID := args[0]
2222

2323
client, err := cli.GetAPIClient(cmd)
2424
if err != nil {
@@ -58,7 +58,7 @@ func NewCreateEnvCommand() *cobra.Command {
5858
}
5959

6060
appSvc := service.NewApplicationService(client)
61-
env, err := appSvc.CreateEnv(ctx, uuid, req)
61+
env, err := appSvc.CreateEnv(ctx, appUUID, req)
6262
if err != nil {
6363
return fmt.Errorf("failed to create environment variable: %w", err)
6464
}

cmd/application/env/delete.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package env
22

33
import (
4-
"context"
54
"fmt"
65

6+
"github.com/spf13/cobra"
7+
78
"github.com/coollabsio/coolify-cli/internal/cli"
89
"github.com/coollabsio/coolify-cli/internal/service"
9-
"github.com/spf13/cobra"
1010
)
1111

1212
func NewDeleteEnvCommand() *cobra.Command {
@@ -16,7 +16,7 @@ func NewDeleteEnvCommand() *cobra.Command {
1616
Long: `Delete an environment variable from an application. First UUID is the application, second is the specific environment variable to delete.`,
1717
Args: cli.ExactArgs(2, "<uuid1> <uuid2>"),
1818
RunE: func(cmd *cobra.Command, args []string) error {
19-
ctx := context.Background()
19+
ctx := cmd.Context()
2020
appUUID := args[0]
2121
envUUID := args[1]
2222

@@ -31,7 +31,11 @@ func NewDeleteEnvCommand() *cobra.Command {
3131
if !force {
3232
var response string
3333
fmt.Printf("Are you sure you want to delete this environment variable? (yes/no): ")
34-
fmt.Scanln(&response)
34+
_, err := fmt.Scanln(&response)
35+
36+
if err != nil {
37+
return fmt.Errorf("failed to read confirmation: %w", err)
38+
}
3539

3640
if response != "yes" && response != "y" {
3741
fmt.Println("Delete cancelled.")

cmd/application/env/get.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
package env
22

33
import (
4-
"context"
54
"fmt"
65

6+
"github.com/spf13/cobra"
7+
78
"github.com/coollabsio/coolify-cli/internal/cli"
89
"github.com/coollabsio/coolify-cli/internal/output"
910
"github.com/coollabsio/coolify-cli/internal/service"
10-
"github.com/spf13/cobra"
1111
)
1212

1313
func NewGetEnvCommand() *cobra.Command {
1414
return &cobra.Command{
1515
Use: "get <app_uuid> <env_uuid_or_key>",
1616
Short: "Get environment variable details",
1717
Long: `Get detailed information about a specific environment variable by UUID or key name.`,
18-
Args: cli.ExactArgs(2, "<uuid1> <uuid2>"),
18+
Args: cli.ExactArgs(2, "<app_uuid> <env_uuid_or_key>"),
1919
RunE: func(cmd *cobra.Command, args []string) error {
20-
ctx := context.Background()
20+
ctx := cmd.Context()
2121
appUUID := args[0]
22-
envUUID := args[1]
22+
envUUIDOrKey := args[1]
2323

2424
client, err := cli.GetAPIClient(cmd)
2525
if err != nil {
2626
return fmt.Errorf("failed to get API client: %w", err)
2727
}
2828

2929
appSvc := service.NewApplicationService(client)
30-
env, err := appSvc.GetEnv(ctx, appUUID, envUUID)
30+
env, err := appSvc.GetEnv(ctx, appUUID, envUUIDOrKey)
3131
if err != nil {
3232
return fmt.Errorf("failed to get environment variable: %w", err)
3333
}

cmd/application/env/list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package env
22

33
import (
4-
"context"
54
"fmt"
65

6+
"github.com/spf13/cobra"
7+
78
"github.com/coollabsio/coolify-cli/internal/cli"
89
"github.com/coollabsio/coolify-cli/internal/output"
910
"github.com/coollabsio/coolify-cli/internal/service"
10-
"github.com/spf13/cobra"
1111
)
1212

1313
func NewListEnvCommand() *cobra.Command {
@@ -17,7 +17,7 @@ func NewListEnvCommand() *cobra.Command {
1717
Long: `List all environment variables for a specific application.`,
1818
Args: cli.ExactArgs(1, "<uuid>"),
1919
RunE: func(cmd *cobra.Command, args []string) error {
20-
ctx := context.Background()
20+
ctx := cmd.Context()
2121
uuid := args[0]
2222

2323
client, err := cli.GetAPIClient(cmd)

cmd/application/env/sync.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package env
22

33
import (
4-
"context"
54
"fmt"
65
"strings"
76

7+
"github.com/spf13/cobra"
8+
89
"github.com/coollabsio/coolify-cli/internal/cli"
910
"github.com/coollabsio/coolify-cli/internal/models"
1011
"github.com/coollabsio/coolify-cli/internal/parser"
1112
"github.com/coollabsio/coolify-cli/internal/service"
12-
"github.com/spf13/cobra"
1313
)
1414

1515
func NewSyncEnvCommand() *cobra.Command {
@@ -24,7 +24,7 @@ func NewSyncEnvCommand() *cobra.Command {
2424
Example: coolify app env sync abc123 --file .env.production`,
2525
Args: cli.ExactArgs(1, "<uuid>"),
2626
RunE: func(cmd *cobra.Command, args []string) error {
27-
ctx := context.Background()
27+
ctx := cmd.Context()
2828
uuid := args[0]
2929

3030
client, err := cli.GetAPIClient(cmd)

0 commit comments

Comments
 (0)