From 572f39cb3e393c898bc387363c359d1628ebf12b Mon Sep 17 00:00:00 2001 From: Hermes Date: Sat, 15 Aug 2026 10:20:34 +0500 Subject: [PATCH] CI: Gitea Actions workflow (test+build+package), Makefile, config.yaml.example, .gitignore --- .gitea/workflows/ci.yaml | 79 ++++++++++++++++++++++++++++++++++++++++ .gitignore | 7 +++- Makefile | 38 +++++++++++++++++++ config.yaml.example | 20 ++++++++++ 4 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/ci.yaml create mode 100644 Makefile create mode 100644 config.yaml.example diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..0aca76a --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,79 @@ +name: CI + +on: + push: + branches: [ main ] + paths-ignore: + - '**.md' + - '.gitea/**' + - 'LICENSE' + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ gitea.workflow }}-${{ gitea.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: '1.23' + check-latest: true + + - name: Run tests + run: go test ./... -v -count=1 -timeout 120s 2>&1 + + - name: Vet + run: go vet ./... + + build: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: '1.23' + check-latest: true + + - name: Build binary + run: go build -ldflags="-s -w" -o ratatoskr ./cmd/ratatoskr/ + + - uses: actions/upload-artifact@v4 + with: + name: ratatoskr + path: ratatoskr + + package: + if: gitea.ref == 'refs/heads/main' + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + with: + name: ratatoskr + + - name: Upload to Gitea Packages (generic) + run: | + VERSION="commit-$(echo '${{ gitea.sha }}' | cut -c1-7)" + curl -sS -X PUT \ + -H "Authorization: token ${{ secrets.TC_GITEA_TOKEN }}" \ + -H "Content-Type: application/octet-stream" \ + "http://gitea.hal9000.home/api/packages/${{ gitea.actor }}/generic/ratatoskr/${VERSION}/linux-amd64/ratatoskr" \ + --data-binary @ratatoskr + echo "Uploaded ratatoskr version ${VERSION}" + + - name: Update latest tag + run: | + curl -sS -X PUT \ + -H "Authorization: token ${{ secrets.TC_GITEA_TOKEN }}" \ + -H "Content-Type: application/octet-stream" \ + "http://gitea.hal9000.home/api/packages/${{ gitea.actor }}/generic/ratatoskr/latest/linux-amd64/ratatoskr" \ + --data-binary @ratatoskr + echo "Updated 'latest' tag" \ No newline at end of file diff --git a/.gitignore b/.gitignore index caf5f4c..bacb527 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /bin/ *.exe *.out +ratatoskr # Go build/test artifacts /testbin/ @@ -13,6 +14,10 @@ !/.env.example secrets/ +# Local config (not tracked — use config.yaml.example) +config.yaml + # Local scratch .tmp/ -.db/ \ No newline at end of file +.db/ +.dbg/ \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d773755 --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +.PHONY: all build test vet clean run fmt + +APP := ratatoskr +CMD_DIR := ./cmd/ratatoskr +GO ?= go +GOPATH := $(shell $(GO) env GOPATH) +GOFLAGS ?= -ldflags="-s -w" + +all: test build + +build: + $(GO) build $(GOFLAGS) -o $(APP) $(CMD_DIR) + +test: + $(GO) test ./... -v -count=1 -timeout 120s + +vet: + $(GO) vet ./... + +fmt: + $(GO) fmt ./... + +run: build + ./$(APP) -config config.yaml + +clean: + rm -f $(APP) + rm -rf /tmp/ratatoskr-* + +.PHONY: bench +bench: + $(GO) test ./... -bench=. -benchmem -count=1 -timeout 120s + +.PHONY: cross +cross: + GOOS=linux GOARCH=amd64 $(GO) build $(GOFLAGS) -o $(APP)-linux-amd64 $(CMD_DIR) + GOOS=linux GOARCH=arm64 $(GO) build $(GOFLAGS) -o $(APP)-linux-arm64 $(CMD_DIR) + GOOS=darwin GOARCH=amd64 $(GO) build $(GOFLAGS) -o $(APP)-darwin-amd64 $(CMD_DIR) \ No newline at end of file diff --git a/config.yaml.example b/config.yaml.example new file mode 100644 index 0000000..57e39d1 --- /dev/null +++ b/config.yaml.example @@ -0,0 +1,20 @@ +# ratatoskr-go пример конфигурации +# Копировать в config.yaml и заполнить переменные. + +telegram: + token: "${TG_TOKEN}" # токен Telegram бота (обязательно) + chat_id: "${TG_CHAT_ID}" # ID чата, куда бот отвечает (обязательно) + +opencode: + bin: "opencode" # путь к opencode CLI + config: "${OPENCODE_CONFIG:-}" # путь к opencode config.json + hard_timeout: "20m" # максимальное время работы opencode + idle_timeout: "2m" # таймаут без вывода + db_path: "" # путь к opencode БД (пусто = авто) + +chat: + poll_interval: "30s" # частота long-poll Telegram + +paths: + worktree: "/opt/data/ratatoskr/worktrees" # рабочие директории субагентов + db: "/opt/data/ratatoskr/ratatoskr.db" # путь к SQLite-БД \ No newline at end of file