Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
go run github.com/playwright-community/playwright-go/cmd/playwright
install chromium --with-deps
- run: make lint
- run: go test ./...
- run: go test -race ./...
env:
ORY_RATE_LIMIT_HEADER: ${{ secrets.ORY_RATE_LIMIT_HEADER }}
ORY_CONSOLE_URL: https://console.staging.ory.dev
Expand Down
6 changes: 0 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ licenses: .bin/licenses node_modules # checks open-source licenses
docker:
docker build -f .docker/Dockerfile-build -t oryd/ory:latest-sqlite .


# Runs tests in short mode, without database adapters
.PHONY: post-release
post-release:
echo "nothing to do"

node_modules: package-lock.json
npm ci
touch node_modules
6 changes: 6 additions & 0 deletions cmd/cloudx/testhelpers/testhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ func SetupPlaywright(t testing.TB) (playwright.Browser, playwright.Page, func())
page := NewPage(t, browser)

return browser, page, func() {
// Drain any in-flight Route handlers (registered in NewPage) before closing
// the page; otherwise page.Close() can race the handler goroutine inside
// playwright-go.
t.Logf("unroute error: %+v", page.Context().UnrouteAll(playwright.BrowserContextUnrouteAllOptions{
Behavior: playwright.UnrouteBehaviorWait,
}))
t.Logf("page close error: %+v", page.Close())
t.Logf("browser close error: %+v", browser.Close())
t.Logf("playwright stop error: %+v", pw.Stop())
Expand Down
4 changes: 3 additions & 1 deletion cmd/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ import (
"github.com/ory/cli/cmd/dev"
)

var devCommands = []*cobra.Command{dev.Main}
func newDevCommands() []*cobra.Command {
return []*cobra.Command{dev.NewCommand()}
}
19 changes: 10 additions & 9 deletions cmd/dev/ci/deps/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import (
"github.com/spf13/cobra"
)

var Main = &cobra.Command{
Use: "deps",
Short: "Helpers for binary dependencies in Makefiles.",
}

func init() {
Main.PersistentFlags().StringP("os", "o", "", "OS the binary should run on. Currently only 'linux' and 'darwin' are supported.")
Main.PersistentFlags().StringP("architecture", "a", "", "Architecture the binary should run on. Currently only 'amd64' is supported.")
Main.PersistentFlags().StringP("config", "c", "", "Path to config files.")
func NewCommand() *cobra.Command {
c := &cobra.Command{
Use: "deps",
Short: "Helpers for binary dependencies in Makefiles.",
}
c.PersistentFlags().StringP("os", "o", "", "OS the binary should run on. Currently only 'linux' and 'darwin' are supported.")
c.PersistentFlags().StringP("architecture", "a", "", "Architecture the binary should run on. Currently only 'amd64' is supported.")
c.PersistentFlags().StringP("config", "c", "", "Path to config files.")
c.AddCommand(newURLCmd())
return c
}
46 changes: 22 additions & 24 deletions cmd/dev/ci/deps/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,28 +116,26 @@ func (c *Component) getRenderedURL(osString string, archString string) (string,
return buf.String(), nil
}

var url = &cobra.Command{
Use: "url",
Short: "Returns the download url based on the provided config file.",
Long: `Returns the download url based on the provided config file. This is used to simplify our Makefile logic when downloading binary dependencies. As the values used for os and arch as well as the structure of the download url for different binary tools are not standardized it makes it quite cumbersome to handle this efficiently in Makefiles.`,
RunE: func(cmd *cobra.Command, args []string) error {
component := Component{}
var pConfig = flagx.MustGetString(cmd, "config")
err := component.getComponentFromConfig(pConfig)
if err != nil {
return err
}
var pOS = flagx.MustGetString(cmd, "os")
var pArch = flagx.MustGetString(cmd, "architecture")
url, err := component.getRenderedURL(pOS, pArch)
if err != nil {
return err
}
fmt.Fprintln(os.Stdout, url)
return nil
},
}

func init() {
Main.AddCommand(url)
func newURLCmd() *cobra.Command {
return &cobra.Command{
Use: "url",
Short: "Returns the download url based on the provided config file.",
Long: `Returns the download url based on the provided config file. This is used to simplify our Makefile logic when downloading binary dependencies. As the values used for os and arch as well as the structure of the download url for different binary tools are not standardized it makes it quite cumbersome to handle this efficiently in Makefiles.`,
RunE: func(cmd *cobra.Command, args []string) error {
component := Component{}
var pConfig = flagx.MustGetString(cmd, "config")
err := component.getComponentFromConfig(pConfig)
if err != nil {
return err
}
var pOS = flagx.MustGetString(cmd, "os")
var pArch = flagx.MustGetString(cmd, "architecture")
url, err := component.getRenderedURL(pOS, pArch)
if err != nil {
return err
}
fmt.Fprintln(os.Stdout, url)
return nil
},
}
}
77 changes: 38 additions & 39 deletions cmd/dev/ci/github/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,46 @@ import (
const tagPrefix = "refs/tags/"
const branchPrefix = "refs/heads/"

var env = &cobra.Command{
Use: "env",
Short: "Sets up environment variables",
Long: `Sets up environment variables. To load the environment variables use:
func newEnvCmd() *cobra.Command {
return &cobra.Command{
Use: "env",
Short: "Sets up environment variables",
Long: `Sets up environment variables. To load the environment variables use:

$ source $(ory dev ci github env)`,
Run: func(cmd *cobra.Command, args []string) {
if ref := os.Getenv("GITHUB_REF"); strings.HasPrefix(ref, tagPrefix) {
// it's a tag
fmt.Printf("export GIT_TAG=%s",
strings.ReplaceAll(ref, tagPrefix, ""))
} else if strings.HasPrefix(ref, branchPrefix) {
fmt.Printf("export GIT_BRANCH=%s",
strings.ReplaceAll(ref, branchPrefix, ""))
} else {
fmt.Printf("export GIT_BRANCH=%s",
strings.TrimSpace(pkg.CommandGetOutput("git", "rev-parse", "--abbrev-ref", "HEAD")))
}

repo := strings.Split(os.Getenv("GITHUB_REPOSITORY"), "/")
if len(repo) != 2 {
pkg.Fatalf("Malformed repository information in GITHUB_REPOSITORY: %s", os.Getenv("GITHUB_REPOSITORY"))
}
fmt.Printf("export GITHUB_ORG=%s\n", repo[0])
fmt.Printf("export GITHUB_REPO=%s\n", repo[1])

caser := cases.Title(language.AmericanEnglish)
fmt.Printf("export SWAGGER_APP_NAME=%s_%s\n",
caser.String(strings.ToLower(repo[0])),
caser.String(strings.ToLower(repo[1])),
)

if ignorePkgs := strings.Split(os.Getenv("SWAGGER_SPEC_IGNORE_PKGS"), ","); len(ignorePkgs) > 0 {
for k, p := range ignorePkgs {
ignorePkgs[k] = "-x " + p
Run: func(cmd *cobra.Command, args []string) {
if ref := os.Getenv("GITHUB_REF"); strings.HasPrefix(ref, tagPrefix) {
// it's a tag
fmt.Printf("export GIT_TAG=%s",
strings.ReplaceAll(ref, tagPrefix, ""))
} else if strings.HasPrefix(ref, branchPrefix) {
fmt.Printf("export GIT_BRANCH=%s",
strings.ReplaceAll(ref, branchPrefix, ""))
} else {
fmt.Printf("export GIT_BRANCH=%s",
strings.TrimSpace(pkg.CommandGetOutput("git", "rev-parse", "--abbrev-ref", "HEAD")))
}
fmt.Printf(`export SWAGGER_SPEC_IGNORE_PKGS='%s'`, strings.Join(ignorePkgs, " "))
}
},
}

func init() {
Main.AddCommand(env)
repo := strings.Split(os.Getenv("GITHUB_REPOSITORY"), "/")
if len(repo) != 2 {
pkg.Fatalf("Malformed repository information in GITHUB_REPOSITORY: %s", os.Getenv("GITHUB_REPOSITORY"))
}
fmt.Printf("export GITHUB_ORG=%s\n", repo[0])
fmt.Printf("export GITHUB_REPO=%s\n", repo[1])

caser := cases.Title(language.AmericanEnglish)
fmt.Printf("export SWAGGER_APP_NAME=%s_%s\n",
caser.String(strings.ToLower(repo[0])),
caser.String(strings.ToLower(repo[1])),
)

if raw := os.Getenv("SWAGGER_SPEC_IGNORE_PKGS"); raw != "" {
ignorePkgs := strings.Split(raw, ",")
for k, p := range ignorePkgs {
ignorePkgs[k] = "-x " + p
}
fmt.Printf(`export SWAGGER_SPEC_IGNORE_PKGS='%s'`, strings.Join(ignorePkgs, " "))
}
},
}
}
10 changes: 7 additions & 3 deletions cmd/dev/ci/github/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
"github.com/spf13/cobra"
)

var Main = &cobra.Command{
Use: "github",
Short: "Helpers for GitHub",
func NewCommand() *cobra.Command {
c := &cobra.Command{
Use: "github",
Short: "Helpers for GitHub",
}
c.AddCommand(newEnvCmd())
return c
}
22 changes: 11 additions & 11 deletions cmd/dev/ci/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import (

"github.com/ory/cli/cmd/dev/ci/deps"
"github.com/ory/cli/cmd/dev/ci/github"
"github.com/ory/cli/cmd/dev/ci/monorepo"
"github.com/ory/cli/cmd/dev/ci/orbs"
)

var Main = &cobra.Command{
Use: "ci",
Short: "Continuous Integration helpers",
}

func init() {
Main.AddCommand(orbs.Main)
Main.AddCommand(github.Main)
Main.AddCommand(monorepo.Main)
Main.AddCommand(deps.Main)
func NewCommand() *cobra.Command {
c := &cobra.Command{
Use: "ci",
Short: "Continuous Integration helpers",
}
c.AddCommand(
orbs.NewCommand(),
github.NewCommand(),
deps.NewCommand(),
)
return c
}
Loading
Loading