Skip to content

Commit

Permalink
Don't run spinners in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidS-ovm committed Jun 24, 2024
1 parent ce5f6ac commit 673f76c
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 16 deletions.
8 changes: 4 additions & 4 deletions cmd/tea_ensuretoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ func (m ensureTokenModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case instanceLoadedMsg:
m.oi = msg.instance
m.status = taskStatusRunning
cmds = append(cmds,
m.ensureTokenCmd(m.ctx),
m.spinner.Tick,
)
cmds = append(cmds, m.ensureTokenCmd(m.ctx))
if os.Getenv("CI") == "" {
cmds = append(cmds, m.spinner.Tick)
}
case displayAuthorizationInstructionsMsg:
m.deviceMessage = "manual"
m.deviceConfig = msg.config
Expand Down
4 changes: 3 additions & 1 deletion cmd/tea_initialisesources.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ func (m initialiseSourcesModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

m.status = taskStatusRunning
cmds = append(cmds, m.loadSourcesConfigCmd)
cmds = append(cmds, m.spinner.Tick)
if os.Getenv("CI") == "" {
cmds = append(cmds, m.spinner.Tick)
}
case askForAwsConfigMsg:
// load the config that was injected above. If it's not there, prompt the user.
aws_config := viper.GetString("aws-config")
Expand Down
4 changes: 3 additions & 1 deletion cmd/tea_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ func (m runPlanModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.taskModel.status = taskStatusRunning
// since the taskModel will not be shown while `terraform plan` is running,
// there's no need to actually kick off the spinner
// cmds = append(cmds, m.taskModel.spinner.Tick)
// if os.Getenv("CI") == "" {
// cmds = append(cmds, m.taskModel.spinner.Tick)
// }

// defer the actual command to give the view a chance to show the header
cmds = append(cmds, func() tea.Msg { return runPlanNowMsg{} })
Expand Down
5 changes: 4 additions & 1 deletion cmd/tea_revlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"os"
"time"

"connectrpc.com/connect"
Expand Down Expand Up @@ -58,7 +59,9 @@ func (m revlinkWarmupModel) Update(msg tea.Msg) (revlinkWarmupModel, tea.Cmd) {
case sourcesInitialisedMsg:
m.taskModel.status = taskStatusRunning
// start the spinner
cmds = append(cmds, m.taskModel.spinner.Tick)
if os.Getenv("CI") == "" {
cmds = append(cmds, m.taskModel.spinner.Tick)
}

// setup the watchdog infrastructure
ctx, cancel := context.WithCancel(m.ctx)
Expand Down
13 changes: 10 additions & 3 deletions cmd/tea_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"os"
"strings"

tea "github.com/charmbracelet/bubbletea"
Expand Down Expand Up @@ -58,7 +59,9 @@ func (m snapshotModel) Update(msg tea.Msg) (snapshotModel, tea.Cmd) {
return m, nil
}
m.overall.status = taskStatusRunning
cmds = append(cmds, m.overall.spinner.Tick)
if os.Getenv("CI") == "" {
cmds = append(cmds, m.overall.spinner.Tick)
}
case progressSnapshotMsg:
if m.overall.spinner.ID() != msg.id {
return m, nil
Expand All @@ -68,7 +71,9 @@ func (m snapshotModel) Update(msg tea.Msg) (snapshotModel, tea.Cmd) {
m.edges = msg.edges

m.discovering.status = taskStatusRunning
cmds = append(cmds, m.discovering.spinner.Tick)
if os.Getenv("CI") == "" {
cmds = append(cmds, m.discovering.spinner.Tick)
}
case savingSnapshotMsg:
if m.overall.spinner.ID() != msg.id {
return m, nil
Expand All @@ -77,7 +82,9 @@ func (m snapshotModel) Update(msg tea.Msg) (snapshotModel, tea.Cmd) {
m.discovering.status = taskStatusDone

m.saving.status = taskStatusRunning
cmds = append(cmds, m.saving.spinner.Tick)
if os.Getenv("CI") == "" {
cmds = append(cmds, m.saving.spinner.Tick)
}

case finishSnapshotMsg:
if m.overall.spinner.ID() != msg.id {
Expand Down
19 changes: 14 additions & 5 deletions cmd/tea_submitplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,17 @@ func (m submitPlanModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case submitPlanNowMsg:
cmds = append(cmds,
m.submitPlanCmd,
m.removingSecretsTask.spinner.Tick,
m.resourceExtractionTask.spinner.Tick,
m.uploadChangesTask.spinner.Tick,
m.waitForSubmitPlanActivity,
)

if os.Getenv("CI") == "" {
cmds = append(cmds,
m.removingSecretsTask.spinner.Tick,
m.resourceExtractionTask.spinner.Tick,
m.uploadChangesTask.spinner.Tick,
)
}

case submitPlanUpdateMsg:
// ensure that the wrapped message is submitted before we wait for the
// next update. This is still not perfect, but there's currently no
Expand Down Expand Up @@ -142,7 +147,9 @@ func (m submitPlanModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.riskMilestoneTasks[i].status = taskStatusDone
case sdp.RiskCalculationStatus_ProgressMilestone_STATUS_INPROGRESS:
m.riskMilestoneTasks[i].status = taskStatusRunning
cmds = append(cmds, m.riskMilestoneTasks[i].spinner.Tick)
if os.Getenv("CI") == "" {
cmds = append(cmds, m.riskMilestoneTasks[i].spinner.Tick)
}
case sdp.RiskCalculationStatus_ProgressMilestone_STATUS_SKIPPED:
m.riskMilestoneTasks[i].status = taskStatusSkipped
}
Expand All @@ -151,7 +158,9 @@ func (m submitPlanModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

if len(m.riskMilestones) > 0 {
m.riskTask.status = taskStatusRunning
cmds = append(cmds, m.riskTask.spinner.Tick)
if os.Getenv("CI") == "" {
cmds = append(cmds, m.riskTask.spinner.Tick)
}

var allSkipped = true
for _, ms := range m.riskMilestoneTasks {
Expand Down
3 changes: 2 additions & 1 deletion cmd/tea_taskmodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"os"

"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
Expand Down Expand Up @@ -58,7 +59,7 @@ func NewTaskModel(title string, width int) taskModel {
}

func (m taskModel) Init() tea.Cmd {
if m.status == taskStatusRunning {
if m.status == taskStatusRunning && os.Getenv("CI") == "" {
return m.spinner.Tick
}
return nil
Expand Down

0 comments on commit 673f76c

Please sign in to comment.