grep -v без совпадений возвращает 1; в sh -e это роняло шаг. Добавлен || true.
55 lines
2.1 KiB
YAML
55 lines
2.1 KiB
YAML
name: ci
|
|
|
|
# Гейт качества на PR и push в main: vet, тесты с race-детектором, линт,
|
|
# gofmt, go mod tidy и карантин зависимостей тулкита.
|
|
#
|
|
# ВАЖНО: job-контейнер golang:1.27 не содержит Node.js, поэтому
|
|
# actions/checkout (Node-action) в нём не работает — checkout делается
|
|
# вручную через git.
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: backend
|
|
container: golang:1.27
|
|
steps:
|
|
- name: checkout
|
|
run: |
|
|
git clone "https://x-access-token:${{ github.token }}@git.totmin.ru/${{ github.repository }}.git" .
|
|
git checkout -q "${{ github.sha }}"
|
|
- name: vet
|
|
run: go vet ./...
|
|
- name: test (race)
|
|
run: go test -race ./... -count=1
|
|
|
|
lint:
|
|
runs-on: backend
|
|
container: golang:1.27
|
|
steps:
|
|
- name: checkout
|
|
run: |
|
|
git clone "https://x-access-token:${{ github.token }}@git.totmin.ru/${{ github.repository }}.git" .
|
|
git checkout -q "${{ github.sha }}"
|
|
- name: install golangci-lint
|
|
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.13.2
|
|
- name: lint
|
|
run: $(go env GOPATH)/bin/golangci-lint run ./...
|
|
- name: gofmt
|
|
run: |
|
|
unformatted=$(gofmt -l .)
|
|
[ -z "$unformatted" ] || { echo "gofmt: требуется форматирование: $unformatted"; exit 1; }
|
|
- name: go mod tidy check
|
|
run: go mod tidy -diff
|
|
- name: toolkit dependency quarantine
|
|
run: |
|
|
direct=$(go list -m -f '{{if not .Main}}{{if not .Indirect}}{{.Path}}{{end}}{{end}}' all)
|
|
allowed='^(github.com/modelcontextprotocol/go-sdk|gopkg.in/yaml.v3|github.com/BurntSushi/toml)$'
|
|
bad=$(echo "$direct" | grep -vE "$allowed" | grep -v '^$' || true)
|
|
if [ -n "$bad" ]; then
|
|
echo "недопустимые прямые зависимости:"; echo "$bad"; exit 1
|
|
fi
|
|
echo "toolkit-deps: ok"
|