Skip to content

Commit fcda660

Browse files
authored
feat: modernize CI (#415)
* fix: use 127.0.0.1 rather than localhost for OAuth2 * chore: modernize CI and upgrade dependencies
1 parent 9a6af5e commit fcda660

22 files changed

Lines changed: 214 additions & 231 deletions

.docker/Dockerfile-build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ WORKDIR /go/src/github.com/ory/cli
77
ADD ./go.mod go.mod
88
ADD ./go.sum go.sum
99

10-
ENV GO111MODULE=on
1110
ENV CGO_ENABLED=1
1211

1312
RUN go mod download

.github/workflows/ci.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: ory/ci/checkout@master
19-
- uses: actions/setup-go@v5
19+
- name: Set up Go
20+
uses: actions/setup-go@v6
2021
with:
21-
go-version: "1.24"
22+
go-version-file: go.mod
23+
cache-dependency-path: go.mod
2224
- uses: actions/cache@v4
2325
with:
2426
path: |
2527
~/.cache/ms-playwright
26-
key: ${{ runner.os }}-playwright-${{ hashFiles('go.sum') }}
28+
key: ${{ runner.os }}-playwright-${{ hashFiles('go.mod') }}
2729
restore-keys: ${{ runner.os }}-playwright-
2830
- run:
2931
go run github.com/playwright-community/playwright-go/cmd/playwright

.github/workflows/cve-scan.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
make docker
2626
- name: Scan image
2727
id: scan
28-
uses: anchore/scan-action@v3
28+
uses: anchore/scan-action@v7
2929
with:
3030
image: oryd/ory:latest-sqlite
3131
fail-build: false
@@ -34,12 +34,12 @@ jobs:
3434
- name: Inspect action SARIF report
3535
run: cat ${{ steps.scan.outputs.sarif }}
3636
- name: Upload SARIF report
37-
uses: github/codeql-action/upload-sarif@v2
37+
uses: github/codeql-action/upload-sarif@v4
3838
with:
3939
sarif_file: ${{ steps.scan.outputs.sarif }}
4040
- name: Inspect scan result
4141
id: report
42-
uses: anchore/scan-action@v3
42+
uses: anchore/scan-action@v7
4343
with:
4444
image: oryd/ory:latest-sqlite
4545
output-format: table

.github/workflows/format.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v3
12-
- uses: actions/setup-go@v3
12+
- name: Set up Go
13+
uses: actions/setup-go@v6
1314
with:
14-
go-version: "1.24"
15+
go-version-file: go.mod
16+
cache-dependency-path: go.mod
1517
- run: make format
1618
- name: Indicate formatting issues
1719
run: git diff HEAD --exit-code --color

.github/workflows/test-e2e.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v2
15-
- uses: actions/setup-go@v2
15+
- name: Set up Go
16+
uses: actions/setup-go@v6
1617
with:
17-
go-version: "1.24"
18+
go-version-file: go.mod
19+
cache-dependency-path: go.mod
1820
- uses: actions/setup-node@v2
1921
with:
2022
node-version: "16"
@@ -51,9 +53,11 @@ jobs:
5153
runs-on: ubuntu-latest
5254
steps:
5355
- uses: actions/checkout@v2
54-
- uses: actions/setup-go@v2
56+
- name: Set up Go
57+
uses: actions/setup-go@v6
5558
with:
56-
go-version: "1.24"
59+
go-version-file: go.mod
60+
cache-dependency-path: go.mod
5761
- uses: actions/setup-node@v2
5862
with:
5963
node-version: "16"

Makefile

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,18 @@
11
SHELL=/bin/bash -o pipefail
22

3-
# EXECUTABLES = docker-compose docker node npm go
4-
# K := $(foreach exec,$(EXECUTABLES),\
5-
# $(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
6-
7-
export GO111MODULE := on
83
export PATH := .bin:${PATH}
94
export PWD := $(shell pwd)
105

11-
GOLANGCI_LINT_VERSION = 2.3.1
12-
13-
GO_DEPENDENCIES = github.com/ory/go-acc \
14-
github.com/golang/mock/mockgen \
15-
github.com/go-swagger/go-swagger/cmd/swagger \
16-
golang.org/x/tools/cmd/goimports \
17-
github.com/mikefarah/yq \
18-
github.com/mattn/goveralls
19-
20-
define make-go-dependency
21-
# go install is responsible for not re-building when the code hasn't changed
22-
.bin/$(notdir $1): go.mod go.sum Makefile
23-
GOBIN=$(PWD)/.bin/ go install $1
24-
endef
25-
$(foreach dep, $(GO_DEPENDENCIES), $(eval $(call make-go-dependency, $(dep))))
6+
GOLANGCI_LINT_VERSION = 2.11.4
267

27-
.bin/clidoc: Makefile go.mod go.sum cmd
8+
.bin/clidoc: Makefile go.mod cmd
289
go build -tags nodev -o .bin/clidoc ./cmd/clidoc/.
2910

3011
docs/cli: .bin/clidoc
3112
curl -o docs/sidebar.json https://raw.githubusercontent.com/ory/docs/master/docs/sidebar.json
3213
clidoc .
3314

34-
.bin/cli: go.mod go.sum Makefile
15+
.bin/cli: go.mod Makefile
3516
go build -o .bin/cli -tags sqlite github.com/ory/cli
3617

3718
.bin/golangci-lint-$(GOLANGCI_LINT_VERSION):
@@ -47,17 +28,17 @@ lint: .bin/golangci-lint-$(GOLANGCI_LINT_VERSION)
4728

4829
.PHONY: install
4930
install:
50-
GO111MODULE=on go install -tags sqlite .
31+
go install -tags sqlite .
5132

5233
.PHONY: refresh
5334
refresh:
5435
UPDATE_SNAPSHOTS=true go test -tags sqlite,json1,refresh ./...
5536

5637
# Formats the code
5738
.PHONY: format
58-
format: .bin/cli .bin/goimports node_modules
39+
format: .bin/cli node_modules go.mod
5940
.bin/cli dev headers copyright --type=open-source
60-
goimports -w -local github.com/ory .
41+
go tool goimports -w -local github.com/ory .
6142
npm exec -- prettier --write "{**/,}*{.js,.md,.ts}"
6243

6344
licenses: .bin/licenses node_modules # checks open-source licenses

cmd/cloudx/client/auth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (h *CommandHelper) oAuth2DanceWithServer(ctx context.Context, client *oauth
180180
serverErr = make(chan error)
181181
serverToken = make(chan *oauth2.Token)
182182
)
183-
l, err := net.Listen("tcp", "localhost:0")
183+
l, err := net.Listen("tcp", "127.0.0.1:0")
184184
if err != nil {
185185
return nil, fmt.Errorf("failed to allocate port for OAuth2 callback handler, try again later: %w", err)
186186
}

cmd/cloudx/client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
"github.com/spf13/cobra"
1111

12-
hydra "github.com/ory/hydra-client-go/v2"
12+
hydra "github.com/ory/hydra-client-go/v26"
1313
hydracli "github.com/ory/hydra/v2/cmd/cliclient"
1414
kratoscli "github.com/ory/kratos/cmd/cliclient"
1515
)

cmd/cloudx/client/command_helper.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"github.com/ory/x/cmdx"
2525
"github.com/ory/x/flagx"
2626
"github.com/ory/x/jsonx"
27-
"github.com/ory/x/pointerx"
2827
)
2928

3029
const (
@@ -100,7 +99,7 @@ func WithProjectOverride(project string) CommandHelperOption {
10099

101100
func WithWorkspaceOverride(workspace string) CommandHelperOption {
102101
return func(h *CommandHelper) {
103-
h.workspaceOverride = pointerx.Ptr(workspace)
102+
h.workspaceOverride = new(workspace)
104103
}
105104
}
106105

@@ -322,7 +321,7 @@ func (h *CommandHelper) WorkspaceID() *string {
322321
if h.workspaceID == uuid.Nil {
323322
return nil
324323
}
325-
return pointerx.Ptr(h.workspaceID.String())
324+
return new(h.workspaceID.String())
326325
}
327326

328327
func (h *CommandHelper) UserName(ctx context.Context) string {

cmd/cloudx/client/command_helper_setup_test.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import (
1919

2020
"github.com/stretchr/testify/assert"
2121
"github.com/stretchr/testify/require"
22-
23-
. "github.com/ory/x/pointerx"
2422
)
2523

2624
func TestDetermineIDs(t *testing.T) {
@@ -63,7 +61,7 @@ func TestDetermineIDs(t *testing.T) {
6361
setup := func(t *testing.T) (*CommandHelper, *Config) {
6462
h := &CommandHelper{
6563
configLocation: t.TempDir() + "/config.json",
66-
cloudConsoleAPIURL: Ptr(ts.URL),
64+
cloudConsoleAPIURL: new(ts.URL),
6765
}
6866
cfg, err := h.getOrCreateConfig()
6967
require.NoError(t, err)
@@ -107,15 +105,15 @@ func TestDetermineIDs(t *testing.T) {
107105
t.Run("errors when workspace override is set", func(t *testing.T) {
108106
h, cfg := setup(t)
109107

110-
h.workspaceAPIKey = Ptr("workspace-api-key")
111-
h.workspaceOverride = Ptr("workspace-override")
108+
h.workspaceAPIKey = new("workspace-api-key")
109+
h.workspaceOverride = new("workspace-override")
112110

113111
assert.ErrorContains(t, h.determineWorkspaceID(ctx, cfg), "workspace API key is set but workspace flag is also set, please remove one")
114112
})
115113

116114
h, cfg := setup(t)
117115

118-
h.workspaceAPIKey = Ptr("workspace-api-key")
116+
h.workspaceAPIKey = new("workspace-api-key")
119117

120118
require.NoError(t, h.determineWorkspaceID(ctx, cfg))
121119
assert.Equal(t, wsID, h.workspaceID)
@@ -126,23 +124,23 @@ func TestDetermineIDs(t *testing.T) {
126124
t.Run("errors when project override is set", func(t *testing.T) {
127125
h, cfg := setup(t)
128126

129-
h.projectAPIKey = Ptr("project-api-key")
130-
h.projectOverride = Ptr("project-override")
127+
h.projectAPIKey = new("project-api-key")
128+
h.projectOverride = new("project-override")
131129

132130
assert.ErrorContains(t, h.determineProjectID(ctx, cfg), "project API key is set but project flag is also set, please remove one")
133131
})
134132
t.Run("errors when workspace is set", func(t *testing.T) {
135133
h, cfg := setup(t)
136134

137-
h.projectAPIKey = Ptr("project-api-key")
135+
h.projectAPIKey = new("project-api-key")
138136
h.workspaceID = uuid.Must(uuid.NewV4())
139137

140138
assert.ErrorContains(t, h.determineProjectID(ctx, cfg), "project API key is set but workspace is also set, please remove one")
141139
})
142140

143141
h, cfg := setup(t)
144142

145-
h.projectAPIKey = Ptr("project-api-key")
143+
h.projectAPIKey = new("project-api-key")
146144

147145
require.NoError(t, h.determineProjectID(ctx, cfg))
148146
assert.Equal(t, pjID, h.projectID)
@@ -177,7 +175,7 @@ func TestDetermineIDs(t *testing.T) {
177175
} {
178176
t.Run(tc.name, func(t *testing.T) {
179177
for _, setValue := range []func(*CommandHelper){
180-
func(h *CommandHelper) { h.workspaceOverride = Ptr(tc.value) },
178+
func(h *CommandHelper) { h.workspaceOverride = new(tc.value) },
181179
func(*CommandHelper) { t.Setenv(WorkspaceKey, tc.value) },
182180
} {
183181
h, cfg := setup(t)
@@ -224,7 +222,7 @@ func TestDetermineIDs(t *testing.T) {
224222
} {
225223
t.Run(tc.name, func(t *testing.T) {
226224
for _, setValue := range []func(*CommandHelper){
227-
func(h *CommandHelper) { h.projectOverride = Ptr(tc.value) },
225+
func(h *CommandHelper) { h.projectOverride = new(tc.value) },
228226
func(*CommandHelper) { t.Setenv(ProjectKey, tc.value) },
229227
} {
230228
h, cfg := setup(t)

0 commit comments

Comments
 (0)