Skip to content
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 15 additions & 1 deletion .rwx/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,25 @@ tasks:
-- \
-ldflags "-w -s -X github.com/rwx-cloud/cli/cmd/rwx/config.Version=testing-${{ init.commit-sha }}" \
-parallel 4 \
./internal/... ./cmd/... ./test/...
$(go list ./internal/... ./cmd/... ./test/... | grep -v /captain/)
outputs:
test-results:
- path: tmp/go-test.json

# TODO: Once internal/captain/ no longer uses Ginkgo, remove this task
# and add captain packages back to unit-tests above.
- key: captain-tests
use: [go-deps, gotestsum]
run: |
gotestsum \
--jsonfile tmp/go-test-captain.json \
-- \
-ldflags "-w -s -X github.com/rwx-cloud/cli/cmd/rwx/config.Version=testing-${{ init.commit-sha }}" \
./internal/captain/...
outputs:
test-results:
- path: tmp/go-test-captain.json

- key: rwx-cli
use: [go-deps, lsp-server]
run: |
Expand Down
12 changes: 12 additions & 0 deletions cmd/rwx/env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

import "os"

// getEnvWithFallback checks the primary env var first, falling back to the
// legacy name for backwards compatibility during the CAPTAIN_ → RWX_TEST_ migration.
func getEnvWithFallback(primary, fallback string) string {
if v := os.Getenv(primary); v != "" {
return v
}
return os.Getenv(fallback)
}
95 changes: 95 additions & 0 deletions cmd/rwx/identity_recipes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
[
{
"language": ".NET",
"kind": "xUnit",
"recipe": { "components": ["assembly", "description"], "strict": true }
},
{
"language": "Elixir",
"kind": "ExUnit",
"recipe": { "components": ["file", "description"], "strict": true }
},
{
"language": "Go",
"kind": "Ginkgo",
"recipe": { "components": ["file", "description"], "strict": true }
},
{
"language": "Go",
"kind": "go test",
"recipe": { "components": ["package", "description"], "strict": true }
},
{
"language": "JavaScript",
"kind": "Cucumber",
"recipe": { "components": ["file", "description"], "strict": true }
},
{
"language": "JavaScript",
"kind": "Cypress",
"recipe": { "components": ["description"], "strict": true }
},
{
"language": "JavaScript",
"kind": "Jest",
"recipe": { "components": ["file", "description"], "strict": true }
},
{
"language": "JavaScript",
"kind": "Karma",
"recipe": { "components": ["browserName", "description"], "strict": true }
},
{
"language": "JavaScript",
"kind": "Mocha",
"recipe": { "components": ["file", "description"], "strict": true }
},
{
"language": "JavaScript",
"kind": "Playwright",
"recipe": {
"components": ["project", "file", "description"],
"strict": true
}
},
{
"language": "JavaScript",
"kind": "Vitest",
"recipe": { "components": ["file", "description"], "strict": true }
},
{
"language": "PHP",
"kind": "PHPUnit",
"recipe": { "components": ["file", "description"], "strict": true }
},
{
"language": "Python",
"kind": "pytest",
"recipe": { "components": ["file", "description"], "strict": true }
},
{
"language": "Python",
"kind": "unittest",
"recipe": { "components": ["file", "description"], "strict": true }
},
{
"language": "Ruby",
"kind": "Cucumber",
"recipe": { "components": ["file", "description"], "strict": true }
},
{
"language": "Ruby",
"kind": "minitest",
"recipe": { "components": ["file", "description"], "strict": true }
},
{
"language": "Ruby",
"kind": "RSpec",
"recipe": { "components": ["file", "description"], "strict": true }
},
{
"language": "other",
"kind": "other",
"recipe": { "components": ["file", "description"], "strict": false }
}
]
6 changes: 6 additions & 0 deletions cmd/rwx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"

captainerrors "github.com/rwx-cloud/cli/internal/captain/errors"
"github.com/rwx-cloud/cli/internal/cli"
)

Expand All @@ -18,6 +19,11 @@ func main() {
return
}

// Captain's ExecutionError carries custom exit codes from subprocess execution
if e, ok := captainerrors.AsExecutionError(err); ok {
os.Exit(e.Code)
}

if !errors.Is(err, HandledError) {
if Debug {
// Enabling debug output will print stacktraces
Expand Down
13 changes: 13 additions & 0 deletions cmd/rwx/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var (

accessTokenBackend = accesstoken.NewFileBackend(fileBackend)
docsTokenBackend := docstoken.NewFileBackend(fileBackend)

versionsBackend := versions.NewFileBackend(fileBackend)

c, err := api.NewClient(api.Config{AccessToken: AccessToken, Host: rwxHost, AccessTokenBackend: accessTokenBackend, VersionsBackend: versionsBackend})
Expand Down Expand Up @@ -98,6 +99,17 @@ var (
}
)

func initAccessTokenBackend() (accesstoken.Backend, error) {
fileBackend, err := internalconfig.NewFileBackend([]string{
filepath.Join("~", ".config", "rwx"),
filepath.Join("~", ".mint"),
})
if err != nil {
return nil, errors.Wrap(err, "unable to initialize config backend")
}
return accesstoken.NewFileBackend(fileBackend), nil
}

func addRwxDirFlag(cmd *cobra.Command) {
cmd.Flags().StringVarP(&RwxDirectory, "dir", "d", "", "the directory your RWX configuration files are located in, typically `.rwx`. By default, the CLI traverses up until it finds a `.rwx` directory.")
}
Expand Down Expand Up @@ -159,6 +171,7 @@ func init() {
rootCmd.AddCommand(vaultsCmd)
rootCmd.AddCommand(docsCmd)
rootCmd.AddCommand(resultsCmd)
rootCmd.AddCommand(testCmd)
rootCmd.AddCommand(whoamiCmd)

cobra.OnInitialize(func() {
Expand Down
Loading