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:
parent
1f6f400276
commit
829b1237b2
7 changed files with 98 additions and 36 deletions
21
.github/workflows/ci.yml
vendored
21
.github/workflows/ci.yml
vendored
|
|
@ -4,7 +4,9 @@ on:
|
|||
push:
|
||||
branches:
|
||||
- main
|
||||
- "rework/**"
|
||||
pull_request:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
|
|
@ -19,14 +21,17 @@ jobs:
|
|||
go-version-file: go.mod
|
||||
cache: true
|
||||
|
||||
- name: Vendor Go modules
|
||||
run: go mod vendor
|
||||
- name: gofmt
|
||||
run: make fmt-check
|
||||
|
||||
- name: go vet
|
||||
run: make vet
|
||||
|
||||
- name: vendor is up to date
|
||||
run: make vendor-check
|
||||
|
||||
- name: Build
|
||||
run: GOFLAGS=-mod=vendor go build ./...
|
||||
run: make build
|
||||
|
||||
- name: Vet
|
||||
run: GOFLAGS=-mod=vendor go vet ./...
|
||||
|
||||
- name: Test
|
||||
run: GOFLAGS=-mod=vendor go test ./...
|
||||
- name: Test (race)
|
||||
run: make race
|
||||
|
|
|
|||
14
.github/workflows/release.yml
vendored
14
.github/workflows/release.yml
vendored
|
|
@ -13,19 +13,7 @@ env:
|
|||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
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 ./...
|
||||
uses: ./.github/workflows/ci.yml
|
||||
|
||||
release:
|
||||
needs: test
|
||||
|
|
|
|||
47
Makefile
Normal file
47
Makefile
Normal 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
|
||||
|
|
@ -12,9 +12,9 @@ import (
|
|||
|
||||
// SessionState stores the UI state that should be restored on next launch.
|
||||
type SessionState struct {
|
||||
ActivePane string `toml:"active_pane"`
|
||||
Left PaneSession `toml:"left"`
|
||||
Right PaneSession `toml:"right"`
|
||||
ActivePane string `toml:"active_pane"`
|
||||
Left PaneSession `toml:"left"`
|
||||
Right PaneSession `toml:"right"`
|
||||
}
|
||||
|
||||
// PaneSession stores per-pane session state (path and selected entry name).
|
||||
|
|
|
|||
|
|
@ -94,10 +94,10 @@ func CopyPathWithProgressContext(ctx context.Context, srcPath string, dstDir str
|
|||
progress = func(CopyProgress) {}
|
||||
}
|
||||
tracker := copyProgressState{
|
||||
ctx: ctx,
|
||||
stats: stats,
|
||||
ctx: ctx,
|
||||
stats: stats,
|
||||
callback: progress,
|
||||
stage: "Scanning files...",
|
||||
stage: "Scanning files...",
|
||||
discover: stats.FilesTotal == 0,
|
||||
}
|
||||
tracker.emit(srcPath, true)
|
||||
|
|
|
|||
|
|
@ -237,10 +237,10 @@ type Model struct {
|
|||
archiveProgress chan tea.Msg
|
||||
archiveFormat string
|
||||
deleteKind string // "trash" or "permanent" — selected in delete modal
|
||||
ssh *sshState
|
||||
preSSHPath string // original path before entering SSH mode
|
||||
themeSelector *themeSelectorState // nil when not in theme selector dialog
|
||||
remoteImageTemp string // temp file of downloaded remote image, cleaned on change/quit
|
||||
ssh *sshState
|
||||
preSSHPath string // original path before entering SSH mode
|
||||
themeSelector *themeSelectorState // nil when not in theme selector dialog
|
||||
remoteImageTemp string // temp file of downloaded remote image, cleaned on change/quit
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (m *Model) moveCursor(delta int) {
|
||||
// When a filter query is active on this pane, move through filtered entries
|
||||
// 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() {
|
||||
err := srcClient.Walk(sourcePath, func(_ string, info os.FileInfo, err error) error {
|
||||
if err != nil { return err }
|
||||
if !info.IsDir() { count++ }
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !info.IsDir() {
|
||||
count++
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -6242,7 +6244,7 @@ func (m *Model) startRemoteCopyJob(kind fileOpKind, sources []string, targetDir
|
|||
|
||||
var info os.FileInfo
|
||||
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
|
||||
|
||||
// Get file info and perform copy depending on direction.
|
||||
|
|
|
|||
20
plans/rework/04-dev-log.md
Normal file
20
plans/rework/04-dev-log.md
Normal 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` вместо копии шагов.
|
||||
Loading…
Add table
Add a link
Reference in a new issue