Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit c30c076

Browse files
authored
chore: cleanup ci scripts (#228)
1 parent b8067c0 commit c30c076

36 files changed

+107
-101
lines changed

.github/workflows/integration.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
with:
2424
go-version: '^1.14'
2525
- name: integration tests
26-
run: ./ci/steps/integration.sh
26+
run: ./ci/scripts/integration.sh

.github/workflows/test.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ jobs:
1515
- name: fmt
1616
uses: ./ci/image
1717
with:
18-
args: ./ci/steps/fmt.sh
18+
args: make -j fmt
19+
- run: ./ci/scripts/files_changed.sh
1920
lint:
2021
runs-on: ubuntu-latest
2122
steps:
@@ -38,7 +39,7 @@ jobs:
3839
- name: test
3940
uses: ./ci/image
4041
with:
41-
args: ./ci/steps/unit_test.sh
42+
args: make -j test/go
4243
gendocs:
4344
runs-on: ubuntu-latest
4445
steps:
@@ -52,4 +53,5 @@ jobs:
5253
- name: generate-docs
5354
uses: ./ci/image
5455
with:
55-
args: ./ci/steps/gendocs.sh
56+
args: make -j gendocs
57+
- run: ./ci/scripts/files_changed.sh

Makefile

+23-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Makefile for Coder CLI
22

3-
.PHONY: clean build build/macos build/windows build/linux
3+
.PHONY: clean build build/macos build/windows build/linux fmt lint gendocs test/go
4+
5+
PROJECT_ROOT := $(shell git rev-parse --show-toplevel)
6+
MAKE_ROOT := $(shell pwd)
47

58
clean:
69
rm -rf ./ci/bin
@@ -9,8 +12,24 @@ build: build/macos build/windows build/linux
912

1013
build/macos:
1114
# requires darwin
12-
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 ./ci/steps/build.sh
15+
CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 ./ci/scripts/build.sh
1316
build/windows:
14-
CGO_ENABLED=0 GOOS=windows GOARCH=386 ./ci/steps/build.sh
17+
CGO_ENABLED=0 GOOS=windows GOARCH=386 ./ci/scripts/build.sh
1518
build/linux:
16-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ./ci/steps/build.sh
19+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ./ci/scripts/build.sh
20+
21+
fmt:
22+
go mod tidy
23+
gofmt -w -s .
24+
goimports -w "-local=$$(go list -m)" .
25+
26+
lint:
27+
golangci-lint run -c .golangci.yml
28+
29+
gendocs:
30+
rm -rf ./docs
31+
mkdir ./docs
32+
go run ./cmd/coder gen-docs ./docs
33+
34+
test/go:
35+
go test $$(go list ./... | grep -v pkg/tcli | grep -v ci/integration | grep -v coder-sdk)

ci/integration/envs_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ import (
1010
"testing"
1111
"time"
1212

13-
"cdr.dev/coder-cli/coder-sdk"
14-
"cdr.dev/coder-cli/pkg/tcli"
1513
"cdr.dev/slog"
1614
"cdr.dev/slog/sloggers/slogtest"
1715
"cdr.dev/slog/sloggers/slogtest/assert"
1816
"github.com/google/go-cmp/cmp"
17+
18+
"cdr.dev/coder-cli/coder-sdk"
19+
"cdr.dev/coder-cli/pkg/tcli"
1920
)
2021

2122
func cleanupClient(ctx context.Context, t *testing.T) *coder.Client {

ci/integration/integration_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import (
66
"testing"
77
"time"
88

9-
"cdr.dev/coder-cli/pkg/tcli"
109
"cdr.dev/slog/sloggers/slogtest/assert"
10+
11+
"cdr.dev/coder-cli/pkg/tcli"
1112
)
1213

1314
func run(t *testing.T, container string, execute func(t *testing.T, ctx context.Context, runner *tcli.ContainerRunner)) {

ci/integration/setup_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import (
99
"strings"
1010
"testing"
1111

12-
"cdr.dev/coder-cli/pkg/tcli"
1312
"golang.org/x/xerrors"
13+
14+
"cdr.dev/coder-cli/pkg/tcli"
1415
)
1516

1617
// binpath is populated during package initialization with a path to the coder binary.

ci/integration/tags_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import (
44
"context"
55
"testing"
66

7+
"cdr.dev/slog/sloggers/slogtest/assert"
8+
79
"cdr.dev/coder-cli/coder-sdk"
810
"cdr.dev/coder-cli/pkg/tcli"
9-
"cdr.dev/slog/sloggers/slogtest/assert"
1011
)
1112

1213
func TestTags(t *testing.T) {

ci/integration/users_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import (
44
"context"
55
"testing"
66

7+
"cdr.dev/slog/sloggers/slogtest/assert"
8+
79
"cdr.dev/coder-cli/coder-sdk"
810
"cdr.dev/coder-cli/pkg/tcli"
9-
"cdr.dev/slog/sloggers/slogtest/assert"
1011
)
1112

1213
func TestUsers(t *testing.T) {

ci/steps/build.sh renamed to ci/scripts/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ popd() { builtin popd >/dev/null; }
66

77
set -euo pipefail
88

9-
cd "$(git rev-parse --show-toplevel)/ci/steps"
9+
cd "$(git rev-parse --show-toplevel)/ci/scripts"
1010

1111
tag=$(git describe --tags)
1212

ci/scripts/files_changed.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
cd "$(git rev-parse --show-toplevel)"
6+
7+
if [[ $(git ls-files --other --modified --exclude-standard) ]]; then
8+
echo "Files have changed:"
9+
git -c color.ui=never status
10+
exit 1
11+
fi
File renamed without changes.

ci/steps/fmt.sh

-18
This file was deleted.

ci/steps/gendocs.sh

-18
This file was deleted.

ci/steps/lint.sh

-8
This file was deleted.

ci/steps/unit_test.sh

-8
This file was deleted.

coder-sdk/config_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import (
77
"testing"
88
"time"
99

10-
"cdr.dev/coder-cli/coder-sdk"
1110
"cdr.dev/slog"
1211
"cdr.dev/slog/sloggers/slogtest"
1312
"cdr.dev/slog/sloggers/slogtest/assert"
13+
14+
"cdr.dev/coder-cli/coder-sdk"
1415
)
1516

1617
func newClient(t *testing.T) *coder.Client {

internal/cmd/ceapi.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import (
55
"fmt"
66
"strings"
77

8+
"golang.org/x/xerrors"
9+
810
"cdr.dev/coder-cli/coder-sdk"
911
"cdr.dev/coder-cli/pkg/clog"
10-
"golang.org/x/xerrors"
1112
)
1213

1314
// Helpers for working with the Coder Enterprise API.

internal/cmd/cmd.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ package cmd
44
import (
55
"os"
66

7-
"cdr.dev/coder-cli/internal/x/xcobra"
87
"github.com/spf13/cobra"
98
"github.com/spf13/cobra/doc"
9+
10+
"cdr.dev/coder-cli/internal/x/xcobra"
1011
)
1112

1213
// verbose is a global flag for specifying that a command should give verbose output.

internal/cmd/configssh.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ import (
1212

1313
"cdr.dev/coder-cli/pkg/clog"
1414

15+
"github.com/spf13/cobra"
16+
"golang.org/x/xerrors"
17+
1518
"cdr.dev/coder-cli/coder-sdk"
1619
"cdr.dev/coder-cli/internal/coderutil"
1720
"cdr.dev/coder-cli/internal/config"
18-
"github.com/spf13/cobra"
19-
"golang.org/x/xerrors"
2021
)
2122

2223
const sshStartToken = "# ------------START-CODER-ENTERPRISE-----------"

internal/cmd/images.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import (
44
"encoding/json"
55
"os"
66

7+
"github.com/spf13/cobra"
8+
"golang.org/x/xerrors"
9+
710
"cdr.dev/coder-cli/coder-sdk"
811
"cdr.dev/coder-cli/pkg/clog"
912
"cdr.dev/coder-cli/pkg/tablewriter"
10-
"github.com/spf13/cobra"
11-
"golang.org/x/xerrors"
1213
)
1314

1415
func imgsCmd() *cobra.Command {

internal/cmd/login.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ import (
88
"net/url"
99
"strings"
1010

11+
"github.com/pkg/browser"
12+
"github.com/spf13/cobra"
13+
"golang.org/x/sync/errgroup"
14+
"golang.org/x/xerrors"
15+
1116
"cdr.dev/coder-cli/coder-sdk"
1217
"cdr.dev/coder-cli/internal/config"
1318
"cdr.dev/coder-cli/internal/loginsrv"
1419
"cdr.dev/coder-cli/internal/version"
1520
"cdr.dev/coder-cli/internal/x/xcobra"
1621
"cdr.dev/coder-cli/pkg/clog"
17-
"github.com/pkg/browser"
18-
"github.com/spf13/cobra"
19-
"golang.org/x/sync/errgroup"
20-
"golang.org/x/xerrors"
2122
)
2223

2324
func loginCmd() *cobra.Command {

internal/cmd/logout.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package cmd
33
import (
44
"os"
55

6-
"cdr.dev/coder-cli/internal/config"
7-
"cdr.dev/coder-cli/pkg/clog"
86
"github.com/spf13/cobra"
97
"golang.org/x/xerrors"
8+
9+
"cdr.dev/coder-cli/internal/config"
10+
"cdr.dev/coder-cli/pkg/clog"
1011
)
1112

1213
func logoutCmd() *cobra.Command {

internal/cmd/rebuild.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ import (
77
"strings"
88
"time"
99

10-
"cdr.dev/coder-cli/coder-sdk"
11-
"cdr.dev/coder-cli/internal/x/xcobra"
12-
"cdr.dev/coder-cli/pkg/clog"
1310
"github.com/briandowns/spinner"
1411
"github.com/fatih/color"
1512
"github.com/manifoldco/promptui"
1613
"github.com/spf13/cobra"
1714
"golang.org/x/crypto/ssh/terminal"
1815
"golang.org/x/xerrors"
16+
17+
"cdr.dev/coder-cli/coder-sdk"
18+
"cdr.dev/coder-cli/internal/x/xcobra"
19+
"cdr.dev/coder-cli/pkg/clog"
1920
)
2021

2122
func rebuildEnvCommand() *cobra.Command {

internal/cmd/resourcemanager.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import (
77
"sort"
88
"text/tabwriter"
99

10-
"cdr.dev/coder-cli/coder-sdk"
11-
"cdr.dev/coder-cli/pkg/clog"
1210
"github.com/spf13/cobra"
1311
"golang.org/x/xerrors"
12+
13+
"cdr.dev/coder-cli/coder-sdk"
14+
"cdr.dev/coder-cli/pkg/clog"
1415
)
1516

1617
func resourceCmd() *cobra.Command {

internal/cmd/shell.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ import (
1515
"golang.org/x/xerrors"
1616
"nhooyr.io/websocket"
1717

18+
"cdr.dev/wsep"
19+
1820
"cdr.dev/coder-cli/coder-sdk"
1921
"cdr.dev/coder-cli/internal/activity"
2022
"cdr.dev/coder-cli/internal/coderutil"
2123
"cdr.dev/coder-cli/internal/x/xterminal"
2224
"cdr.dev/coder-cli/pkg/clog"
23-
"cdr.dev/wsep"
2425
)
2526

2627
func getEnvsForCompletion(user string) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {

internal/cmd/sync.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import (
88
"path/filepath"
99
"strings"
1010

11+
"github.com/spf13/cobra"
12+
"golang.org/x/xerrors"
13+
1114
"cdr.dev/coder-cli/coder-sdk"
1215
"cdr.dev/coder-cli/internal/sync"
1316
"cdr.dev/coder-cli/internal/x/xcobra"
1417
"cdr.dev/coder-cli/pkg/clog"
15-
"github.com/spf13/cobra"
16-
"golang.org/x/xerrors"
1718
)
1819

1920
func syncCmd() *cobra.Command {

internal/cmd/tags.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"encoding/json"
55
"os"
66

7+
"github.com/spf13/cobra"
8+
"golang.org/x/xerrors"
9+
710
"cdr.dev/coder-cli/coder-sdk"
811
"cdr.dev/coder-cli/internal/x/xcobra"
912
"cdr.dev/coder-cli/pkg/clog"
1013
"cdr.dev/coder-cli/pkg/tablewriter"
11-
"github.com/spf13/cobra"
12-
"golang.org/x/xerrors"
1314
)
1415

1516
func tagsCmd() *cobra.Command {

0 commit comments

Comments
 (0)