ci: gofmt/vet/race/vendor checks via Makefile; release reuses CI

- Makefile targets: build, test, race, fmt-check, vet, vendor-check, lint, ci
- ci.yml runs fmt-check, vet, vendor-check, build and race tests; also on
  rework/** branches and callable from release.yml
- gofmt the three files that were not formatted

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-10-31 23:02:31 +03:00
parent 1f6f400276
commit 829b1237b2
7 changed files with 98 additions and 36 deletions

View file

@ -4,7 +4,9 @@ on:
push: push:
branches: branches:
- main - main
- "rework/**"
pull_request: pull_request:
workflow_call:
jobs: jobs:
test: test:
@ -19,14 +21,17 @@ jobs:
go-version-file: go.mod go-version-file: go.mod
cache: true cache: true
- name: Vendor Go modules - name: gofmt
run: go mod vendor run: make fmt-check
- name: go vet
run: make vet
- name: vendor is up to date
run: make vendor-check
- name: Build - name: Build
run: GOFLAGS=-mod=vendor go build ./... run: make build
- name: Vet - name: Test (race)
run: GOFLAGS=-mod=vendor go vet ./... run: make race
- name: Test
run: GOFLAGS=-mod=vendor go test ./...

View file

@ -13,19 +13,7 @@ env:
jobs: jobs:
test: test:
runs-on: ubuntu-latest uses: ./.github/workflows/ci.yml
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Run tests
run: GOFLAGS=-mod=vendor go test ./...
release: release:
needs: test needs: test

47
Makefile Normal file
View file

@ -0,0 +1,47 @@
# Developer and CI entry points. CI (.github/workflows/*.yml) calls these
# targets so local runs and CI stay identical.
GO ?= go
GOFLAGS ?= -mod=vendor
export GOFLAGS
# Go sources we own (vendor/ is third-party and not reformatted).
GOFILES = $(shell git ls-files '*.go' | grep -v '^vendor/')
# Targets mutate vendor/ (vendor-check) and then build from it: never run them
# concurrently, even under `make -j`.
.NOTPARALLEL:
.PHONY: all build test race lint fmt-check vet vendor-check ci fmt
all: build
build:
$(GO) build ./...
test:
$(GO) test -count=1 ./...
race:
$(GO) test -race -count=1 ./...
fmt:
gofmt -w $(GOFILES)
fmt-check:
@out="$$(gofmt -l $(GOFILES) $$(git ls-files --others --exclude-standard '*.go' | grep -v '^vendor/'))"; \
if [ -n "$$out" ]; then echo "gofmt needed for:"; echo "$$out"; exit 1; fi
vet:
$(GO) vet ./...
# go mod vendor must be a no-op: go.mod, go.sum and vendor/ are committed.
vendor-check:
GOFLAGS= $(GO) mod vendor
git diff --exit-code -- vendor go.mod go.sum
@untracked="$$(git ls-files --others --exclude-standard vendor)"; \
if [ -n "$$untracked" ]; then echo "untracked files in vendor/:"; echo "$$untracked"; exit 1; fi
lint: fmt-check vet vendor-check
ci: lint build race

View file

@ -12,9 +12,9 @@ import (
// SessionState stores the UI state that should be restored on next launch. // SessionState stores the UI state that should be restored on next launch.
type SessionState struct { type SessionState struct {
ActivePane string `toml:"active_pane"` ActivePane string `toml:"active_pane"`
Left PaneSession `toml:"left"` Left PaneSession `toml:"left"`
Right PaneSession `toml:"right"` Right PaneSession `toml:"right"`
} }
// PaneSession stores per-pane session state (path and selected entry name). // PaneSession stores per-pane session state (path and selected entry name).

View file

@ -94,10 +94,10 @@ func CopyPathWithProgressContext(ctx context.Context, srcPath string, dstDir str
progress = func(CopyProgress) {} progress = func(CopyProgress) {}
} }
tracker := copyProgressState{ tracker := copyProgressState{
ctx: ctx, ctx: ctx,
stats: stats, stats: stats,
callback: progress, callback: progress,
stage: "Scanning files...", stage: "Scanning files...",
discover: stats.FilesTotal == 0, discover: stats.FilesTotal == 0,
} }
tracker.emit(srcPath, true) tracker.emit(srcPath, true)

View file

@ -237,10 +237,10 @@ type Model struct {
archiveProgress chan tea.Msg archiveProgress chan tea.Msg
archiveFormat string archiveFormat string
deleteKind string // "trash" or "permanent" — selected in delete modal deleteKind string // "trash" or "permanent" — selected in delete modal
ssh *sshState ssh *sshState
preSSHPath string // original path before entering SSH mode preSSHPath string // original path before entering SSH mode
themeSelector *themeSelectorState // nil when not in theme selector dialog themeSelector *themeSelectorState // nil when not in theme selector dialog
remoteImageTemp string // temp file of downloaded remote image, cleaned on change/quit remoteImageTemp string // temp file of downloaded remote image, cleaned on change/quit
} }
func NewModel(cfg config.Config, configPath string) (Model, error) { func NewModel(cfg config.Config, configPath string) (Model, error) {
@ -1693,8 +1693,6 @@ func (m *Model) refreshAllPanes(status string) (tea.Model, tea.Cmd) {
return m, m.loadPreviewCmd() return m, m.loadPreviewCmd()
} }
func (m *Model) moveCursor(delta int) { func (m *Model) moveCursor(delta int) {
// When a filter query is active on this pane, move through filtered entries // When a filter query is active on this pane, move through filtered entries
// only, so the cursor always lands on a matching item. // only, so the cursor always lands on a matching item.
@ -6187,8 +6185,12 @@ func (m *Model) startRemoteCopyJob(kind fileOpKind, sources []string, targetDir
} }
if info.IsDir() { if info.IsDir() {
err := srcClient.Walk(sourcePath, func(_ string, info os.FileInfo, err error) error { err := srcClient.Walk(sourcePath, func(_ string, info os.FileInfo, err error) error {
if err != nil { return err } if err != nil {
if !info.IsDir() { count++ } return err
}
if !info.IsDir() {
count++
}
return nil return nil
}) })
if err != nil { if err != nil {
@ -6242,7 +6244,7 @@ func (m *Model) startRemoteCopyJob(kind fileOpKind, sources []string, targetDir
var info os.FileInfo var info os.FileInfo
var err error var err error
serverSide := false // true if copy/move happened on server without streaming serverSide := false // true if copy/move happened on server without streaming
trackedProgress := false // true if per-file progress callback was used trackedProgress := false // true if per-file progress callback was used
// Get file info and perform copy depending on direction. // Get file info and perform copy depending on direction.

View file

@ -0,0 +1,20 @@
# 04. Журнал разработчика: отклонения от плана
Короткие записи о местах, где план (`03-tasks.md`) пришлось уточнить или поменять.
## Этап 0
- **0.1 `sshtest`.** Сверх API из §11.2 добавлены: `Options.AuthorizedKeys` (pubkey-auth для будущих тестов
`ssh/conn`), `Server.ClientConfig/Dial/DropConnections/Port`, `Proxy.Sent/Close/Port`, `WriteRandom`.
`Options.Chroot` реализован как рабочий каталог SFTP (`sftp.WithServerWorkingDirectory`) и cwd для exec:
относительные пути разрешаются внутри, но абсолютные выходят наружу — это не граница безопасности (настоящий
chroot для `pkg/sftp` потребовал бы своих request-handlers; для тестов не нужен). `CutAfter(n)` считает
n байт client→server **от момента вызова**, срабатывает один раз и рвёт все текущие соединения; новые
соединения после обрыва принимаются (нужно для тестов reconnect). Задержка `SetDelay` — односторонняя, в обе
стороны (RTT ≈ 2·d).
- **0.4 CI.** `gofmt -l .` из плана задел бы `vendor/` (там 10 неотформатированных файлов сторонних модулей),
поэтому проверяются только наши файлы (`git ls-files '*.go' | grep -v ^vendor/` + неотслеживаемые).
Три файла (`config/session.go`, `fs/ops.go`, `ui/model.go`) были неотформатированы — отформатированы в коммите
0.4. В `Makefile` стоит `.NOTPARALLEL`, потому что `vendor-check` перезаписывает `vendor/`, а `make -j`
(у разработчика `make` — алиас на `make -j24`) запускал сборку параллельно с этим. `release.yml` вызывает
`ci.yml` через `workflow_call` вместо копии шагов.