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
18 changes: 17 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
branches:
- main
- dev
- 'feature/*'
pull_request:

jobs:
Expand All @@ -21,3 +20,20 @@ jobs:
go-version: 1.26.x
- name: Test code
run: go test ./...

lint:
name: Run golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: 1.26.x
- name: Check formatting
run: go tool gofumpt -l -extra .
- name: lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.12
79 changes: 79 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
version: "2"

run:
# Set to 0 to disable
# Default: 0
timeout: 5m
go: "1.26"

issues:
# Maximum issues count per one linter.
# Set to 0 to disable.
# Default: 3
max-same-issues: 50

linters:
enable:
- copyloopvar
- errorlint
- goconst
- importas
- intrange
- makezero
- misspell
- prealloc
- revive
- tparallel
- unparam
- unused
- wastedassign

settings:
copyloopvar:
check-alias: true

goconst:
find-duplicates: true

misspell:
locale: UK
ignore-rules:
- Color
mode: default

revive:
rules:
- name: comment-spacings
- name: error-naming
- name: error-return
- name: indent-error-flow
- name: package-comments
- name: range
- name: unhandled-error
- name: var-declaration

unused:
exported-fields-are-used: false
parameters-are-used: false
local-variables-are-used: false

exclusions:
presets:
- comments
- std-error-handling
- common-false-positives
- legacy

formatters:
enable:
- gofumpt
- goimports

settings:
gofumpt:
module-path: github.com/thecentinol/tuwi
extra-rules: true

goimports:
local-prefixes:
- github.com/thecentinol/tuwi
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ PREFIX ?= /usr
BINDIR := $(PREFIX)/bin

.PHONY: install-deps build install install-local uninstall \
run-dev run-debug run unit-test fuzz test clean help
run-dev run-debug run unit-test fuzz test lint format-check \
format-write clean help

install-deps:
@go mod download
Expand Down Expand Up @@ -34,10 +35,19 @@ unit-test:
@go test ./... -short

fuzz:
go test -fuzz=FuzzDetermineSecurityType -fuzztime=30s -v ./internal/networkmanager/...
@go test -fuzz=FuzzDetermineSecurityType -fuzztime=30s -v ./internal/networkmanager/...

test: unit-test

lint:
@golangci-lint run

format-check:
@gofumpt -l -extra .

format-write:
@gofumpt -l -extra -w .

clean:
@go clean
@rm -rf ./dist
Expand All @@ -52,9 +62,12 @@ help:
@echo " Local development:"
@echo " make run-dev — Run from source code"
@echo " make run-debug — Run with debug"
@echo " make test — Run full test suite"
@echo " make unit-test — Run short unit tests"
@echo " make fuzz — Run fuzz tests"
@echo " make test — Run full test suite"
@echo " make lint — Run linter"
@echo " make format-check — Check the codebases formatting"
@echo " make format-write — Fix formatting issues"
@echo ""
@echo " Builds:"
@echo " make build — Compile the binary into repo root"
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ require (
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/mod v0.35.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/tools v0.44.0 // indirect
mvdan.cc/gofumpt v0.10.0 // indirect
)

tool mvdan.cc/gofumpt
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavM
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
mvdan.cc/gofumpt v0.10.0 h1:yGGpRS2pBN2OQIi7b21IXknJna7faPkFaVfHLrN6Euo=
mvdan.cc/gofumpt v0.10.0/go.mod h1:sU2ElXHzOEmvoPqfutYG7uunlueR4K2T1JFml40SzP4=
1 change: 1 addition & 0 deletions internal/dbus/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dbus

import (
"fmt"

"github.com/godbus/dbus/v5"
)

Expand Down
6 changes: 4 additions & 2 deletions internal/events/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package events

import tea "charm.land/bubbletea/v2"

type ShowErrorMsg struct{ Err error }
type DismissErrorMsg struct{}
type (
ShowErrorMsg struct{ Err error }
DismissErrorMsg struct{}
)

func ShowError(err error) tea.Cmd {
return func() tea.Msg {
Expand Down
69 changes: 42 additions & 27 deletions internal/keybindings/keybindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,43 @@
"charm.land/bubbles/v2/key"
)

const (
// ViewNames's
wifiSavedView = "wifi-saved"
wifiAvailableView = "wifi-available"
errModalView = "error-modal"
passwordView = "password-modal"

// Groups
globalGroup = "global"
wifiGroup = "wifi"
tableGroup = "table"
errModalGroup = "error"
passwordGroup = "password"
)

func DefaultKeybindings() Keybindings {
return Keybindings{
// Global
FocusedWifiSaved: Binding{
ViewName: "",
Group: "global",
Group: globalGroup,
Keys: []string{"1"},
HelpKey: "",
HelpDescription: "",
Description: "Switch focus to saved wifi connections pane",
},
FocusedWifiAvailable: Binding{
ViewName: "",
Group: "global",
Group: globalGroup,
Keys: []string{"2"},
HelpKey: "",
HelpDescription: "",
Description: "Switch focus to available wifi networks pane",
},
Quit: Binding{
ViewName: "",
Group: "global",
Group: globalGroup,
Keys: []string{"q", "ctrl+c"},
HelpKey: "q",
HelpDescription: "quit",
Expand All @@ -34,48 +49,48 @@

// WiFi
WifiConnectSaved: Binding{
ViewName: "wifi-saved",
Group: "wifi",
ViewName: wifiSavedView,
Group: wifiGroup,
Keys: []string{"enter"},

Check failure on line 54 in internal/keybindings/keybindings.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

string `enter` has 6 occurrences, make it a constant (goconst)
HelpKey: "Enter",
HelpDescription: "connect",
Description: "Connect to a saved wifi connection",
},
WifiDisconnect: Binding{
ViewName: "wifi-saved",
Group: "wifi",
ViewName: wifiSavedView,
Group: wifiGroup,
Keys: []string{"d"},
HelpKey: "d",
HelpDescription: "diconnect",
Description: "Disconnect from current wifi network",
},
WifiForget: Binding{
ViewName: "wifi-saved",
Group: "wifi",
ViewName: wifiSavedView,
Group: wifiGroup,
Keys: []string{"f"},
HelpKey: "f",
HelpDescription: "forget",
Description: "Remove the selected wifi connection",
},
WifiAutoConnect: Binding{
ViewName: "wifi-saved",
Group: "wifi",
ViewName: wifiSavedView,
Group: wifiGroup,
Keys: []string{"a"},
HelpKey: "a",
HelpDescription: "toggle auto-connect",
Description: "Toggle auto-connect state for the selected wifi connection",
},
WifiScan: Binding{
ViewName: "wifi-available",
Group: "wifi",
ViewName: wifiAvailableView,
Group: wifiGroup,
Keys: []string{"s"},
HelpKey: "s",
HelpDescription: "Scan",
Description: "Scan for nearby wifi networks",
},
WifiConnectAvailable: Binding{
ViewName: "wifi-available",
Group: "wifi",
ViewName: wifiAvailableView,
Group: wifiGroup,
Keys: []string{"enter"},
HelpKey: "enter",
HelpDescription: "connect",
Expand All @@ -85,28 +100,28 @@
// table navigation
// ViewName is left nil because multiple models will use a table.
LineUp: Binding{
Group: "table",
Group: tableGroup,
Keys: []string{"k", "up"},
HelpKey: "↑",
HelpDescription: "move up",
Description: "Move up by one line",
},
LineDown: Binding{
Group: "table",
Group: tableGroup,
Keys: []string{"j", "down"},
HelpKey: "",
HelpDescription: "move down",
Description: "Move down by one line",
},
GotoTop: Binding{
Group: "table",
Group: tableGroup,
Keys: []string{"t"},
HelpKey: "t",
HelpDescription: "move to top",
Description: "Go to the top of the table",
},
GotoBottom: Binding{
Group: "table",
Group: tableGroup,
Keys: []string{"b"},
HelpKey: "b",
HelpDescription: "move to bottom",
Expand All @@ -115,34 +130,34 @@

// Error modal
ErrorDismiss: Binding{
ViewName: "error-modal",
Group: "error",
ViewName: errModalView,
Group: errModalGroup,
Keys: []string{"esc", "enter"},
HelpKey: "esc",

Check failure on line 136 in internal/keybindings/keybindings.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

string `esc` has 4 occurrences, make it a constant (goconst)
HelpDescription: "dismiss",
Description: "Dismiss the error modal",
},

// Password modal
PasswordVisibility: Binding{
ViewName: "password-modal",
Group: "password",
ViewName: passwordView,
Group: passwordGroup,
Keys: []string{"ctrl+t"},
HelpKey: "ctrl+t",
HelpDescription: "hide/show password",
Description: "Toggle the password inputs hidden state",
},
PasswordSubmit: Binding{
ViewName: "password-modal",
Group: "password",
ViewName: passwordView,
Group: passwordGroup,
Keys: []string{"enter"},
HelpKey: "enter",
HelpDescription: "submit",
Description: "Submit password",
},
PasswordCancel: Binding{
ViewName: "password-modal",
Group: "password",
ViewName: passwordView,
Group: passwordGroup,
Keys: []string{"esc"},
HelpKey: "esc",
HelpDescription: "cancel",
Expand Down
1 change: 1 addition & 0 deletions internal/networkmanager/active_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package networkmanager

import (
"fmt"

godbus "github.com/godbus/dbus/v5"

"github.com/thecentinol/tuwi/internal/dbus"
Expand Down
Loading
Loading