Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orion/create release 2 #48

Merged
merged 13 commits into from
Aug 9, 2022
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: 'Unit and Integration tests'
name: 'Integration tests'
on:
workflow_dispatch:
push:
paths-ignore:
- '**.md'
# no push trigger, this only runs nightly
schedule:
# Daily 5am australian/brisbane time (7pm UTC)
- cron: '0 19 * * *'
Expand Down Expand Up @@ -31,7 +29,7 @@ jobs:
# NOTE: we'd rather pin to a major version (e.g. 2022.3), but because 2022.3 is not
# generally available for onprem customers yet this isn't possible.
# Change this when it GA's later
image: docker.packages.octopushq.com/octopusdeploy/octopusdeploy:2022.3.7064-linux
image: docker.packages.octopushq.com/octopusdeploy/octopusdeploy:2022.3.7584-linux
env:
ACCEPT_EULA: Y
DB_CONNECTION_STRING: 'Server=sqlserver;Database=OctopusDeploy;User Id=sa;Password=${{ env.SA_PASSWORD }};'
Expand All @@ -40,8 +38,8 @@ jobs:
OCTOPUS_SERVER_BASE64_LICENSE: ${{ secrets.OCTOPUS_SERVER_BASE64_LICENSE }}
ports:
- 8080:8080
# https://github.com/dorny/test-reporter/issues/168
permissions:

permissions: # https://github.com/dorny/test-reporter/issues/168
statuses: write
checks: write
steps:
Expand All @@ -55,6 +53,7 @@ jobs:
- name: Setup gotestsum
run: go install gotest.tools/gotestsum@latest

# we don't technically need to run the unit tests but they're fast so why not
- name: Unit Tests
run: gotestsum --format testname --junitfile ../unit-tests.xml
working-directory: ./pkg
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'PR and Commit Validation'
on:
workflow_dispatch:
push:
paths-ignore:
- '**.md'
jobs:
test:
runs-on: ubuntu-latest

permissions: # https://github.com/dorny/test-reporter/issues/168
statuses: write
checks: write
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

# if we just run the unit tests then go doesn't compile the parts of the app that aren't covered by
# unit tests; this forces it
- name: Build binary
run: go build -o bin/octopus cmd/octopus/main.go

- name: Setup gotestsum
run: go install gotest.tools/gotestsum@latest

- name: Unit Tests
run: gotestsum --format testname --junitfile ../unit-tests.xml
working-directory: ./pkg

- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Test Results
path: '*-tests.xml'
reporter: java-junit
26 changes: 5 additions & 21 deletions cmd/octopus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import (
"time"

"github.com/AlecAivazis/survey/v2"
"github.com/OctopusDeploy/cli/pkg/constants"
"github.com/OctopusDeploy/cli/pkg/question"
"github.com/spf13/cobra"

"github.com/OctopusDeploy/cli/pkg/factory"
"github.com/OctopusDeploy/cli/pkg/question"
"github.com/OctopusDeploy/cli/pkg/usage"
"github.com/briandowns/spinner"

Expand Down Expand Up @@ -43,23 +40,10 @@ func main() {

f := factory.New(clientFactory, askProvider, s)

cmd := root.NewCmdRoot(f)
// commands are expected to print their own errors to avoid double-ups
cmd.SilenceUsage = true
cmd.SilenceErrors = true

// if we attempt to check the flags before Execute is called, cobra hasn't parsed anything yet,
// so we'll get bad values. PersistentPreRun is a convenient callback for setting up our
// environment after parsing but before execution.
cmd.PersistentPreRun = func(_ *cobra.Command, args []string) {
if noPrompt, err := cmd.PersistentFlags().GetBool(constants.FlagNoPrompt); err == nil && noPrompt {
askProvider.DisableInteractive()
}

if spaceNameOrId, err := cmd.PersistentFlags().GetString(constants.FlagSpace); err == nil && spaceNameOrId != "" {
clientFactory.SetSpaceNameOrId(spaceNameOrId)
}
}
cmd := root.NewCmdRoot(f, clientFactory, askProvider)
// if we don't do this then cmd.Print will get sent to stderr
cmd.SetOut(os.Stdout)
cmd.SetErr(os.Stderr)

if err := cmd.Execute(); err != nil {
cmd.PrintErr(err)
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/account/aws/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
"github.com/briandowns/spinner"
"github.com/spf13/cobra"
)

type CreateOptions struct {
Writer io.Writer
Octopus *client.Client
Ask question.Asker
Spinner *spinner.Spinner
Spinner factory.Spinner

Name string
Description string
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/account/aws/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/OctopusDeploy/cli/pkg/output"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/briandowns/spinner"
"github.com/spf13/cobra"
)

Expand All @@ -31,7 +30,7 @@ func NewCmdList(f factory.Factory) *cobra.Command {
return cmd
}

func listAwsAccounts(client *client.Client, cmd *cobra.Command, s *spinner.Spinner) error {
func listAwsAccounts(client *client.Client, cmd *cobra.Command, s factory.Spinner) error {
s.Start()
accountResources, err := client.Accounts.Get(accounts.AccountsQuery{
AccountType: accounts.AccountTypeAmazonWebServicesAccount,
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/account/azure/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
"github.com/briandowns/spinner"
"github.com/google/uuid"
"github.com/spf13/cobra"
)
Expand All @@ -28,7 +27,7 @@ type CreateOptions struct {
Writer io.Writer
Octopus *client.Client
Ask question.Asker
Spinner *spinner.Spinner
Spinner factory.Spinner

Name string
Description string
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/account/azure/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/OctopusDeploy/cli/pkg/output"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/briandowns/spinner"
"github.com/spf13/cobra"
)

Expand All @@ -31,7 +30,7 @@ func NewCmdList(f factory.Factory) *cobra.Command {
return cmd
}

func listAzureAccounts(client *client.Client, cmd *cobra.Command, s *spinner.Spinner) error {
func listAzureAccounts(client *client.Client, cmd *cobra.Command, s factory.Spinner) error {
s.Start()
accountResources, err := client.Accounts.Get(accounts.AccountsQuery{
AccountType: accounts.AccountTypeAzureServicePrincipal,
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/account/gcp/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
"github.com/briandowns/spinner"
"github.com/spf13/cobra"
)

type CreateOptions struct {
Writer io.Writer
Octopus *client.Client
Ask question.Asker
Spinner *spinner.Spinner
Spinner factory.Spinner

Name string
Description string
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/account/gcp/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/OctopusDeploy/cli/pkg/output"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/briandowns/spinner"
"github.com/spf13/cobra"
)

Expand All @@ -31,7 +30,7 @@ func NewCmdList(f factory.Factory) *cobra.Command {
return cmd
}

func listGcpAccounts(client *client.Client, cmd *cobra.Command, s *spinner.Spinner) error {
func listGcpAccounts(client *client.Client, cmd *cobra.Command, s factory.Spinner) error {
s.Start()
accountResources, err := client.Accounts.Get(accounts.AccountsQuery{
AccountType: accounts.AccountTypeGoogleCloudPlatformAccount,
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/account/helper/helper.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package helper

import (
"github.com/OctopusDeploy/cli/pkg/factory"
"strings"

"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments"
"github.com/briandowns/spinner"
)

// ResolveNamesOrId takes in an array of names and trys to find an exact match.
// If a match is found it will return its corresponding ID. If no match is found
// it will return the name as is, in assumption it is an ID.
func ResolveEnvironmentNames(envs []string, octopus *client.Client, spinner *spinner.Spinner) ([]string, error) {
func ResolveEnvironmentNames(envs []string, octopus *client.Client, spinner factory.Spinner) ([]string, error) {
spinner.Start()
envIds := make([]string, 0, len(envs))
loop:
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/account/ssh/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
"github.com/briandowns/spinner"
"github.com/spf13/cobra"
)

type CreateOptions struct {
Writer io.Writer
Octopus *client.Client
Ask question.Asker
Spinner *spinner.Spinner
Spinner factory.Spinner

Name string
Description string
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/account/ssh/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/OctopusDeploy/cli/pkg/output"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/briandowns/spinner"
"github.com/spf13/cobra"
)

Expand All @@ -31,7 +30,7 @@ func NewCmdList(f factory.Factory) *cobra.Command {
return cmd
}

func listSshAccounts(client *client.Client, cmd *cobra.Command, s *spinner.Spinner) error {
func listSshAccounts(client *client.Client, cmd *cobra.Command, s factory.Spinner) error {
s.Start()
accountResources, err := client.Accounts.Get(accounts.AccountsQuery{
AccountType: accounts.AccountTypeSSHKeyPair,
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/account/token/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
"github.com/briandowns/spinner"
"github.com/spf13/cobra"
)

type CreateOptions struct {
Writer io.Writer
Octopus *client.Client
Ask question.Asker
Spinner *spinner.Spinner
Spinner factory.Spinner

Name string
Description string
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/account/token/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/OctopusDeploy/cli/pkg/output"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/briandowns/spinner"
"github.com/spf13/cobra"
)

Expand All @@ -31,7 +30,7 @@ func NewCmdList(f factory.Factory) *cobra.Command {
return cmd
}

func listTokenAccounts(client *client.Client, cmd *cobra.Command, s *spinner.Spinner) error {
func listTokenAccounts(client *client.Client, cmd *cobra.Command, s factory.Spinner) error {
s.Start()
accountResources, err := client.Accounts.Get(accounts.AccountsQuery{
AccountType: accounts.AccountTypeToken,
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/account/username/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
"github.com/briandowns/spinner"
"github.com/spf13/cobra"
)

type CreateOptions struct {
Writer io.Writer
Octopus *client.Client
Ask question.Asker
Spinner *spinner.Spinner
Spinner factory.Spinner

Name string
Description string
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/account/username/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/OctopusDeploy/cli/pkg/output"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/accounts"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/briandowns/spinner"
"github.com/spf13/cobra"
)

Expand All @@ -31,7 +30,7 @@ func NewCmdList(f factory.Factory) *cobra.Command {
return cmd
}

func listUsernameAccounts(client *client.Client, cmd *cobra.Command, s *spinner.Spinner) error {
func listUsernameAccounts(client *client.Client, cmd *cobra.Command, s factory.Spinner) error {
s.Start()
accountResources, err := client.Accounts.Get(accounts.AccountsQuery{
AccountType: accounts.AccountTypeUsernamePassword,
Expand Down
Loading