Skip to content

Commit

Permalink
Merge pull request #18 from evozon/FT-21
Browse files Browse the repository at this point in the history
[FT-21] Collect output and display it as a table
  • Loading branch information
calinpristavu authored Jul 9, 2023
2 parents 909ee93 + 923d84a commit 1cb80f5
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 13 deletions.
Binary file modified bin/future
Binary file not shown.
11 changes: 7 additions & 4 deletions ci/github/future-proofing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ jobs:
vendor/bin/future skip \\Rector\\CodingStyle\\Rector\\String_\\SymplifyQuoteEscapeRector::class
vendor/bin/future skip \\Rector\\CodingStyle\\Rector\\Catch_\\CatchExceptionNameMatchingTypeRector::class
vendor/bin/rector process src --no-progress-bar --no-diffs
vendor/bin/future run vendor/bin/rector process src --no-progress-bar --no-diffs
#run your project's test suite
#- name: Execute PHPUnit tests
# run: SYMFONY_DEPRECATIONS_HELPER=disabled vendor/bin/phpunit --no-interaction --colors=never
#run your project's test suite
#- name: Execute PHPUnit tests
# run: SYMFONY_DEPRECATIONS_HELPER=disabled vendor/bin/phpunit --no-interaction --colors=never
#last step is to shut down future and display the summary
vendor/bin/future shutdown
7 changes: 5 additions & 2 deletions ci/gitlab/future-proofing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ future-proofing:
- vendor/bin/future skip \\Rector\\CodingStyle\\Rector\\String_\\SymplifyQuoteEscapeRector::class
- vendor/bin/future skip \\Rector\\CodingStyle\\Rector\\Catch_\\CatchExceptionNameMatchingTypeRector::class

- vendor/bin/rector process src --no-progress-bar --no-diffs
- vendor/bin/future run vendor/bin/rector process src --no-progress-bar --no-diffs

#run your project's test suite
- SYMFONY_DEPRECATIONS_HELPER=disabled vendor/bin/phpunit --no-interaction --colors=never
- vendor/bin/future run SYMFONY_DEPRECATIONS_HELPER=disabled vendor/bin/phpunit --no-interaction --colors=never

#- vendor/bin/codeception
#- vendor/bin/behat

#last step is to shut down future and display the summary
- vendor/bin/future shutdown
34 changes: 27 additions & 7 deletions cmd/future/shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package future
import (
"fmt"
"log"
"sort"

"github.com/jedib0t/go-pretty/v6/table"
"github.com/spf13/cobra"

"future/internal/collector"
Expand All @@ -23,15 +25,33 @@ var Shutdown = &cobra.Command{
log.Fatalf("could not get the summary: %v\n", err)
}

for _, summaryData := range summaryResponse.GetSummary() {
result := "successful"
if summaryData.Status != 0 {
result = "failed"
}
summary := summaryResponse.GetSummary()

fmt.Printf("%s -> [%s] %s", summaryData.Command, result, summaryData.Output)
}
reorder(summary)
render(summary)

_, _ = client.Shutdown(cmd.Context(), &collector.ShutdownRequest{})
},
}

func render(summary []*collector.SummaryData) {
w := table.NewWriter()
w.AppendHeader(table.Row{"Command", "Status", "Output"})

for _, summaryData := range summary {
result := "successful"
if summaryData.Status != 0 {
result = "failed"
}

w.AppendRow(table.Row{summaryData.Command, result, summaryData.Output})
}

fmt.Println(w.Render())
}

func reorder(summary []*collector.SummaryData) {
sort.Slice(summary, func(i, j int) bool {
return summary[i].Status > summary[j].Status
})
}
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module future
go 1.19

require (
github.com/jedib0t/go-pretty/v6 v6.4.6
github.com/spf13/cobra v1.6.1
google.golang.org/grpc v1.55.0
google.golang.org/protobuf v1.30.0
Expand All @@ -11,6 +12,8 @@ require (
require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sys v0.6.0 // indirect
Expand Down
20 changes: 20 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jedib0t/go-pretty/v6 v6.4.6 h1:v6aG9h6Uby3IusSSEjHaZNXpHFhzqMmjXcPq1Rjl9Jw=
github.com/jedib0t/go-pretty/v6 v6.4.6/go.mod h1:Ndk3ase2CkQbXLLNf5QDHoYb6J9WtVfmHZu9n8rk2xs=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.4 h1:wZRexSlwd7ZXfKINDLsO4r7WBt3gTKONc6K/VesHvHM=
github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
Expand All @@ -27,4 +45,6 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 comments on commit 1cb80f5

Please sign in to comment.