Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5.3.0
with:
go-version: 'stable'
go-version: '1.25.0'

- name: Build
run: ./tools/build.sh
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5.3.0
with:
go-version: 'stable'
go-version: '1.25.0'

- name: Test
run: go test -race ./...
Expand All @@ -44,12 +44,29 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5.3.0
with:
go-version: 'stable'
go-version: '1.25.0'
- name: golangci-lint
uses: golangci/golangci-lint-action@v7.0.0
with:
version: v2.4.0
verify: false
# This linter works based on the file modification when running under github actions because it's
# not given full access to the git history and therefore gets the wrong date for all files.
args: --disable goheader
args: --disable goheader

fieldalignment:
name: fieldalignment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5.3.0
with:
go-version: '1.25.0'

- name: install fieldalignment
run: go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest

- name: check for diff
run: $GITHUB_WORKSPACE/tools/fieldalignment-lint.sh
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ linters:
disable:
- cyclop
- durationcheck
- embeddedstructfieldcheck # we use [fieldalignment] instead
- errname
- exhaustruct
- forbidigo
Expand Down
2 changes: 1 addition & 1 deletion cmd/subcommands/acci-ping/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

type GUI struct {
listeningChars map[rune]terminal.ConditionalListener
fallbacks []terminal.Listener
GUIState *gui.GUIState
fallbacks []terminal.Listener
}

func newGUIState() *GUI {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tab_completion/tab_completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const debug = false
const AutoCompleteString = "b2827fc8fc8c8267cb15f5a925de7e4712aa04ef2fbd43458326b595d66a36d9" // sha256 of `autoCompleteString`

type Command struct {
Cmd string
Fs *tabflags.FlagSet
Cmd string
}

// Run will for a given command line input, write to stdout the autocomplete suggestion for the input [base]
Expand Down
13 changes: 6 additions & 7 deletions cmd/tab_completion/tabflags/tabflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,26 @@ import (
)

type AutoComplete struct {
FileExt string
Choices []string
WantsFile bool
FileExt string
}

type Flag struct {
// Name is the actual name as it appears on the CLI without the dash.
Name string
// AutoComplete specifies if the flag has any auto complete options.
AutoComplete *AutoComplete
// Name is the actual name as it appears on the CLI without the dash.
Name string
}

// FlagSet is an extension of [flag.FlagSet] that enables auto completion providers for a command.
type FlagSet struct {
*flag.FlagSet

flags []Flag
nameToAc map[string]*AutoComplete

wantsFile bool
nameToAc map[string]*AutoComplete
fileExt string
flags []Flag
wantsFile bool
}

// NewAutoCompleteFlagSet wraps a [flag.FlagSet] with autocomplete configuration, if [wantsFile] is set then
Expand Down
4 changes: 2 additions & 2 deletions graph/data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (
)

type Data struct {
URL string
Header *Header
Network *Network
Runs *Runs
URL string
InsertOrder []DataIndexes
Blocks []*Block
TotalCount int64
Runs *Runs
PingsMeta version
}

Expand Down
11 changes: 5 additions & 6 deletions graph/data/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,15 @@ type BlockTest struct {
}

type DataTestCase struct {
Values []ping.PingResults
BlockSize int
ExpectedRuns data.Runs
BlockTest *BlockTest
ExpectedGraphSpan data.TimeSpan
ExpectedSummary string
Values []ping.PingResults
ExpectedGraphStats data.Stats
BlockSize int
ExpectedPacketLoss float64
ExpectedTotalCount int
ExpectedRuns data.Runs
BlockTest *BlockTest

ExpectedSummary string
}

// A fixed time stamp to make all testing relative too
Expand Down
2 changes: 1 addition & 1 deletion graph/data/serialisation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ func testCompacter(t th.T, start, empty data.Compact) {
}

type FileTest struct {
tz *time.Location
FileName string
ExpectedSummary string
tz *time.Location
}

func (ft FileTest) Run(t *testing.T) {
Expand Down
7 changes: 3 additions & 4 deletions graph/draw_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ const (
)

type label struct {
symbol string
text string
coords

symbol string
text string
leftJustify bool
colour colour
leftJustify bool
}

type colour int
Expand Down
2 changes: 1 addition & 1 deletion graph/drawing.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ func translate(p ping.PingDataPoint, x *XAxisSpanInfo, y drawingYAxis, s termina
}

type gradientState struct {
lastGoodSpan *XAxisSpanInfo
lastGoodIndex int64
lastGoodTerminalWidth int
lastGoodTerminalHeight int
lastGoodSpan *XAxisSpanInfo
}

func (g gradientState) set(i int64, x, y int, s *XAxisSpanInfo) gradientState {
Expand Down
58 changes: 24 additions & 34 deletions graph/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,18 @@ import (
)

type Graph struct {
Term *terminal.Terminal

ui gui.GUI

debugStrict bool

sinkAlive bool
dataChannel <-chan ping.PingResults

initial ping.PingsPerMinute

data *graphdata.GraphData

frameMutex *sync.Mutex
lastFrame frame

drawingBuffer *draw.Buffer

ui gui.GUI
Term *terminal.Terminal
dataChannel <-chan ping.PingResults
data *graphdata.GraphData
frameMutex *sync.Mutex
drawingBuffer *draw.Buffer
presentation *controlState
controlChannel <-chan Control
lastFrame frame
initial ping.PingsPerMinute
debugStrict bool
sinkAlive bool
}

// Control is the signal type which changes the presentation of the graph.
Expand All @@ -54,8 +46,8 @@ type Control struct {
}

type Change[T any] struct {
DidChange bool
Value T
DidChange bool
}

// Presentation is the dynamic part of the graph, these only change the presentation of the graph when drawn
Expand All @@ -69,23 +61,22 @@ type Presentation struct {
}

type GraphConfiguration struct {
// Gui is the external GUI interface which the terminal will call [gui.Draw] on each frame if the gui
// component requires it.
Gui gui.GUI
// Input will be owned by the graph and represents the source of data for the graph to plot.
Input <-chan ping.PingResults
// Terminal is the underlying terminal the graph will draw to and perform all external I/O too. The graph
// takes ownership of the terminal.
Terminal *terminal.Terminal
// Gui is the external GUI interface which the terminal will call [gui.Draw] on each frame if the gui
// component requires it.
Gui gui.GUI
PingsPerMinute ping.PingsPerMinute
Terminal *terminal.Terminal
DrawingBuffer *draw.Buffer
ControlPlane <-chan Control
// Optional (can be nil)
Data *data.Data
URL string
DrawingBuffer *draw.Buffer
PingsPerMinute ping.PingsPerMinute
Presentation Presentation
ControlPlane <-chan Control
DebugStrict bool

// Optionals:
Data *data.Data
}

func StartUp() {
Expand Down Expand Up @@ -288,13 +279,13 @@ func (g *Graph) checkf(shouldBeTrue bool, format string, a ...any) {
}

type frame struct {
PacketCount int64
yAxis drawingYAxis
xAxis drawingXAxis
spinnerData spinner
framePainter func(io.Writer) error
framePainterNoGui func(io.Writer) error
spinnerData spinner
yAxis drawingYAxis
cfg computeFrameConfig
PacketCount int64
}

func (f frame) Match(s terminal.Size, cfg computeFrameConfig) bool {
Expand All @@ -307,7 +298,6 @@ func (f frame) Size() terminal.Size {
}

type controlState struct {
Presentation

m *sync.Mutex
Presentation
}
4 changes: 2 additions & 2 deletions graph/graph_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ const (
)

type FileTest struct {
TimeZoneOfFile *time.Location
FileName string
Sizes []terminal.Size
OnlyDoLinear bool
TimeZoneOfFile *time.Location
TerminalWrapping th.TerminalWrapping
OnlyDoLinear bool
}

var StandardTestSizes = []terminal.Size{
Expand Down
4 changes: 2 additions & 2 deletions graph/graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ func TestThousandsDrawing(t *testing.T) {
}

type DrawingTest struct {
Size terminal.Size
Values []ping.PingDataPoint
ExpectedFile string
Values []ping.PingDataPoint
Size terminal.Size
}

//nolint:unused
Expand Down
4 changes: 2 additions & 2 deletions graph/graphdata/graphdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (

type GraphData struct {
data *data.Data
m *sync.Mutex
spans []*SpanInfo
spanIndex int
m *sync.Mutex
}

func NewGraphData(d *data.Data) *GraphData {
Expand Down Expand Up @@ -106,9 +106,9 @@ func (gd *GraphData) LockFreeIter(followLatestSpan bool) *Iter {
}

type Iter struct {
Total int64
d *data.Data
spans Spans
Total int64
offset int64
}

Expand Down
2 changes: 1 addition & 1 deletion graph/graphdata/graphdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ func (test TimeSpanTest) Run(t *testing.T) {

type TimeSpanFileTest struct {
File string
ExpectedSpanCount int
ExpectedSpans []*data.TimeSpan
ExpectedSpanCount int
}

func (test TimeSpanFileTest) Run(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion graph/spinner.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ var spinnerArray = [...]string{
}

type spinner struct {
spinnerIndex int
timestampLastDrawn time.Time
spinnerIndex int
}

func (s *spinner) spinner(size terminal.Size) string {
Expand Down
6 changes: 3 additions & 3 deletions graph/xAxis.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ import (
)

type XAxisSpanInfo struct {
spans []*graphdata.SpanInfo
spanStats *data.Stats
pingStats *data.Stats
timeSpan *data.TimeSpan
spans []*graphdata.SpanInfo
startX int
endX int
width int
}

type drawingXAxis struct {
size int
spans []*XAxisSpanInfo
overallSpan *data.TimeSpan
spans []*XAxisSpanInfo
size int
}

type xAxisIter struct {
Expand Down
2 changes: 1 addition & 1 deletion graph/yAxis.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
)

type drawingYAxis struct {
size int
stats *data.Stats
size int
labelSize int
scale YAxisScale
}
Expand Down
Loading
Loading