Skip to content

Commit

Permalink
Merge pull request #3 from fumeapp/ci-disable-progress
Browse files Browse the repository at this point in the history
💚 kill progress bars for actions
  • Loading branch information
acidjazz committed May 8, 2024
2 parents 616ead4 + 4963fb7 commit 446700b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 3 additions & 4 deletions mvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"os"
)

func (r *Runners) Init() tea.Cmd {
Expand Down Expand Up @@ -32,7 +31,7 @@ func (r *Runners) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
for i := range *r {

if (*r)[i].State == Running || (*r)[i].State == NotStarted {
if os.Getenv("CI") == "" {
if !IsCI() {
newSpinner, cmd := (*r)[i].Spinner.Update(msg)
(*r)[i].Spinner = &newSpinner
cmds = append(cmds, cmd)
Expand All @@ -41,7 +40,7 @@ func (r *Runners) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

for j := range (*r)[i].Children {
if (*r)[i].Children[j].State == Running || (*r)[i].Children[j].State == NotStarted {
if os.Getenv("CI") == "" {
if !IsCI() {
newSpinner, cmd := (*r)[i].Children[j].Spinner.Update(msg)
(*r)[i].Children[j].Spinner = &newSpinner
cmds = append(cmds, cmd)
Expand Down Expand Up @@ -85,7 +84,7 @@ func (r *Runners) View() string {
var view string

// check if CI is set, if it is then don't return the view until all tasks are completed or one has failed
if os.Getenv("CI") != "" {
if IsCI() {
allDone, _ := r.checkTasksState()
if !allDone {
return ""
Expand Down
9 changes: 8 additions & 1 deletion taskin.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func NewRunner(task Task, cfg Config) Runner {

var spinr *spinner.Model

if os.Getenv("CI") == "" {
if !IsCI() {
spinnerModel := spinner.New(spinner.WithSpinner(cfg.Spinner)) // Initialize with a spinner model
spinnerModel.Style = lipgloss.NewStyle().Foreground(cfg.Colors.Spinner) // Styling spinner
spinr = &spinnerModel
Expand All @@ -36,6 +36,9 @@ func NewRunner(task Task, cfg Config) Runner {
}

func (task *Task) Progress(current, total int) {
if IsCI() {
return
}
task.ShowProgress = TaskProgress{Current: current, Total: total}
if !task.Bar.IsAnimating() {
task.Bar = progress.New(task.Config.ProgressOptions...)
Expand Down Expand Up @@ -110,3 +113,7 @@ func New(tasks Tasks, cfg Config) Runners {
}()
return runners
}

func IsCI() bool {
return os.Getenv("CI") != ""
}

0 comments on commit 446700b

Please sign in to comment.