Commit Graph

47 Commits

Author SHA1 Message Date
jbrechtel 9bca886629 converge: auto-commit at 2026-05-14 22:46:10 from zendo.brechtel
Build / build (push) Failing after 1m45s
2026-05-14 22:46:10 -04:00
jbrechtel edc6d5acf3 Ignores arch package files etc 2026-05-14 22:32:35 -04:00
jbrechtel 4473dc9164 Fixes contact and name
Build / build (push) Successful in 1m22s
2026-05-14 22:20:46 -04:00
jbrechtel 29a984934d converge: auto-commit at 2026-05-14 22:15:21 from zendo.brechtel
Build / build (push) Successful in 1m4s
2026-05-14 22:15:21 -04:00
jbrechtel ef49f30c88 Add Arch Linux PKGBUILD and package build step
Build / build (push) Successful in 58s
- PKGBUILD: builds converge package, uses pre-built binary from
  build/converge when available (from scripts/build), falls back to
  stack build from source. Installs binary, systemd user service,
  example config, and README.
- scripts/build: added final step to run makepkg -f on the host
  (conditional, skipped if makepkg not found). Produces .pkg.tar.zst
  alongside the binary.
- scripts/makepkg: convenience wrapper for standalone makepkg runs.
2026-05-14 19:03:07 -04:00
jbrechtel 89e7729f2c converge: disable response timeout on relay SSE connection
Build / build (push) Successful in 48s
tlsManagerSettings defaults to a 30s response timeout, which kills
long-lived SSE connections between push events. Set it to
responseTimeoutNone so the relay watcher waits indefinitely.
2026-05-14 18:10:02 -04:00
jbrechtel 1ad993b9d1 Fix: downgrade upload-artifact to v3 (Gitea/GHES compat)
Build / build (push) Successful in 12m2s
2026-05-14 16:10:42 -04:00
jbrechtel 27f4e1fd2c Fix: use absolute path for STACK_ROOT (Stack 3 requirement)
Build / build (push) Failing after 15m57s
2026-05-14 15:51:00 -04:00
jbrechtel 657855bd41 Fix CI: remove Docker-in-Docker, install Stack directly
Build / build (push) Failing after 9s
The ./hs Docker wrapper runs docker inside the Gitea runner container.
Since project paths inside the runner container don't exist on the Docker
host, the volume mount creates an empty /work directory, and Stack finds
no packages (error S-8506).

Fix: install Stack directly via get.haskellstack.org, use STACK_ROOT for
caching, and build with stack directly (no Docker-in-Docker).

Also add symlink for gitea-actions.sh convenience script.
2026-05-14 15:50:09 -04:00
jbrechtel bdd9e663b9 chore: apply fourmolu formatting
Build / build (push) Failing after 7s
2026-05-14 14:50:23 -04:00
jbrechtel 662854a977 tests: SSE parsing + relay event handling, update AGENTS.md
- New test module test/RelaySpec.hs (20 tests):
  - extractLines: line splitting, CRLF, partial lines, empty input
  - foldLines: single/two push events, non-push ignored, comments, no-space colon,
    partial state carry-over across batches
  - parseEvent: valid push, non-push, malformed JSON, multi-line data
  - handleSSEEvent: pull on matching repo, ignore wrong gitea_repo/branch,
    skip pull when merge/rebase/operation in progress
- Exported PushEvent(..), extractLines, foldLines, parseEvent, handleSSEEvent
- Fixed data line order (append instead of prepend+reverse) and event ordering
- Updated AGENTS.md: relay architecture, Go component, new deps, file layout
2026-05-14 14:40:47 -04:00
jbrechtel 7feff5abfa converge: phase 2 — SSE relay client for realtime pull on push
- RepoConfig gains rcGiteaRepo :: Maybe Text for relay matching
- Options gains optRelayUrl :: Maybe Text (--relay-url CLI, relay_url config)
- connectRelay connects to converge-relay SSE endpoint, parses push events,
  triggers gitPull on matching repos (by gitea_repo + branch)
- Exponential backoff reconnection (1s .. 60s) on disconnect/error
- Skips pull if repo is mid-operation (merge/rebase/etc.)
- Dependencies: http-client, http-client-tls, http-types, aeson, bytestring
- SSE parser handles event:/data: fields, blank-line delimiters, CRLF endings
- Updated SPEC.md, example config, and help text
2026-05-14 14:13:43 -04:00
jbrechtel 25881f3ff8 converge-relay: phase 1 — webhook-to-SSE relay server in Go
- Pub/sub broker with fan-out to SSE clients
- POST /webhook — receives Gitea push events, optional HMAC verification
- GET /events — SSE stream of push events
- GET /health — health check endpoint
- Zero external dependencies (stdlib only)
- Docker-based build via goctl wrapper (golang:1.26-alpine)
- systemd unit, README with deployment docs
- Tests: broker pub/sub, slow subscriber drop, ref parsing, signature verification
- 6.0M static binary
2026-05-14 13:54:26 -04:00
jbrechtel 4f79212c45 Removes permission settings in service - they break ssh pushing
Build / build (push) Failing after 6s
2026-05-14 13:28:34 -04:00
jbrechtel 74b148af20 Tidy: formatting and import order
Build / build (push) Failing after 6s
2026-05-14 11:40:54 -04:00
jbrechtel 477a86c18a Add --sync flag for one-shot sync-and-exit mode
Build / build (push) Failing after 6s
Useful for wake-from-sleep hooks: run 'converge --sync' to commit
any pending changes, pull from remotes, and push, then exit.
Shows 'Syncing N repo(s)' instead of 'Watching N repo(s)'.
2026-05-14 10:34:36 -04:00
jbrechtel 97078928fc Add per-repo notify_on_pull configuration
Build / build (push) Failing after 10s
- Add rcNotifyOnPull field to RepoConfig (default: False)
- notify_on_pull YAML config key per repository
- When enabled, sends a desktop notification whenever new commits
  are pulled from the remote (with commit count and summaries)
- Uses HEAD comparison to detect actual new commits, not just
  successful pull execution
- Updated example config and spec
2026-05-14 10:20:24 -04:00
jbrechtel f66dfcbccb Add configurable log levels and log file support
Build / build (push) Failing after 7s
- New LogLevel type: Debug, Info, Warn, Error with Ord instance
- Logger holds configured level and output handle (stderr or file)
- --log-level and --log-file CLI flags
- log_level and log_file YAML config fields
- Log messages assigned appropriate severity levels
- Test logger updated to new Logger structure
- All 17 tests passing
2026-05-14 10:13:36 -04:00
jbrechtel d22ea39cde Formats repo
Build / build (push) Failing after 11s
2026-05-13 23:02:04 -04:00
jbrechtel 25b8f24906 Fix two git operation bugs
- gitCommitAll: abort commit when staging (git add -A) fails, e.g.
  due to a stale .git/index.lock.  Previously the failure was ignored
  and commit proceeded on an empty or partial index.

- gitPull: remove explicit branch argument from git pull --rebase.
  Passing both remote and branch can conflict with the branch's
  configured tracking ref, causing 'Cannot rebase onto multiple
  branches'.  Now uses just --rebase <remote>, letting git resolve
  the tracking branch from config.

- Test: index.lock scenario verifies commit is aborted on staging
  failure.
2026-05-13 22:51:09 -04:00
jbrechtel 7d2a4b3a30 Mark all TODO items as done 2026-05-13 22:20:01 -04:00
jbrechtel 2f2cc16551 Log all git write operations with command, args, and exit code
- Add loggedGit helper that logs 'RUN: git -C <path> <args>' before
  execution and 'EXIT <code>' after (with stderr on failure)
- Refactor gitCommitAll, gitPull, and gitPush to use loggedGit
- Add Logger parameter to gitPull and gitPush
- Update test call sites and syncRepo to pass Logger
2026-05-13 22:19:44 -04:00
jbrechtel e0f986a5ee Formats repo 2026-05-13 22:15:55 -04:00
jbrechtel 63e034fd01 Commit and push uncommitted changes on startup
- watchRepo: call syncRepo at startup to commit any pre-existing
  uncommitted changes before entering the file watcher
- Add gitPush function for git push <remote> <branch>
- Add push step to syncRepo after successful pull (with failure
  notification via notifyUser)
- Export syncRepo and gitPush for testing
- Test: startup sync commits and pushes uncommitted changes
2026-05-13 22:10:30 -04:00
jbrechtel eb847c03f6 Notify on all git operation failures, not just merge conflicts
Generalize notifyConflict into notifyUser that accepts an arbitrary
title and body.  Call notify-send for commit failures and pull
failures in addition to the existing merge-conflict notification.
"Nothing to commit" is intentionally excluded — it is an expected
no-op, not a failure.
2026-05-13 22:05:26 -04:00
jbrechtel bcf43d5d83 updating documentation 2026-05-13 22:01:43 -04:00
jbrechtel ee8a4cb449 Add AGENTS.md — project guide for AI coding agents 2026-05-13 21:50:28 -04:00
jbrechtel 4bc23b5d7c Use --rebase instead of --no-edit in gitPull
git pull --no-edit fails with exit 128 on divergent branches because
fast-forward is impossible.  Using --rebase handles divergent histories
by rebasing local commits on top of fetched remote commits, producing
a linear history without merge commits.

- src/Converge.hs: Change gitPull from --no-edit to --rebase
- test/GitPullSpec.hs: Update rebase test to expect success and
  verify linear history (3 commits, no merge parents)
- test/*.hs: Clean up unused imports
2026-05-13 21:48:49 -04:00
jbrechtel 65bf75cdf2 Adds specs 2026-05-13 21:39:02 -04:00
jbrechtel 34c8232427 Avoids running commands during external git operations 2026-05-13 21:00:09 -04:00
jbrechtel a151cf26c4 Force checkout to workspace root with path: ., use ./hs for build
Build / build (push) Failing after 8s
2026-05-11 22:50:47 -04:00
jbrechtel 9521dee9c1 Run hpack before build, fix cache key, add container debug
Build / build (push) Failing after 6s
2026-05-11 22:46:57 -04:00
jbrechtel 8efdedc451 Use GITHUB_WORKSPACE for mount paths, add host-level debug
Build / build (push) Failing after 9s
2026-05-11 22:42:50 -04:00
jbrechtel 96a3c4e672 Fix checkout path: use explicit path: repo in Gitea workflow
Build / build (push) Failing after 10s
2026-05-11 22:37:41 -04:00
jbrechtel 9d7a09c85b Add debug step to diagnose Gitea build failure
Build / build (push) Failing after 12s
2026-05-11 22:30:23 -04:00
jbrechtel 3b785018ca Fix Gitea build: use ./hs wrapper, cache .stack-root, run upx on host
Build / build (push) Failing after 7s
2026-05-11 22:18:21 -04:00
jbrechtel 820c648521 Include hostname in auto-commit messages
Build / build (push) Failing after 7s
2026-05-11 22:14:17 -04:00
jbrechtel 68a518337d Adds systemd service example 2026-05-11 22:10:20 -04:00
jbrechtel 403ab6bd17 Fix Gitea Actions workflow: use docker run instead of container to avoid missing node
Build / build (push) Failing after 1m34s
2026-05-11 21:56:56 -04:00
jbrechtel 60c2a9a5f8 Adds gitea build and upx compression
Build / build (push) Failing after 20s
2026-05-11 21:37:55 -04:00
jbrechtel 266dd117c6 feat: add thread-safe logger and filter .git fs events
- Introduce Logger newtype (MVar-backed) to serialize stderr output
  across concurrent repo watchers, preventing interleaved log lines
- Thread Logger through runConverge → watchRepo → syncRepo → gitCommitAll
- Switch watchDir → watchTree with isGitPath filter to ignore events
  inside .git directories, reducing noise and potential feedback loops
- Extract logEvent as a standalone function
2026-05-11 20:53:23 -04:00
jbrechtel bd8e815134 Add detailed logging and fix event coalescing
- Add timestamped logging for events, commits, pulls, and conflicts
- Use MVar-based event coalescing so rapid changes trigger only one
  sync per debounce window (fixes missed changes from overlapping syncs)
- Handle 'nothing to commit' gracefully instead of treating it as error
- Log changed file list (git status --porcelain) during sync
- Log commit hash on success, pull output on success
- Remove unused imports
2026-05-11 10:25:22 -04:00
jbrechtel 97e129a855 Use XDG config directory as default config path
- Look for config at $XDG_CONFIG_HOME/converge/config.yaml by default
- --config still overrides to an explicit path
- Falls back to single-repo --repo mode if no config file found
- New defaultConfigPath and configFileExists helpers in Converge module
2026-05-11 10:11:34 -04:00
jbrechtel d6e15864f4 Remove accidentally committed fsnotify source; add to .gitignore 2026-05-11 10:05:06 -04:00
jbrechtel 77c6de303f Fix compilation errors
- Remove nonexistent confDebounce field from WatchConfig (fsnotify 0.4.4.0)
- Remove unused Generic deriving and GHC.Generics import
- Replace .!= with fromMaybe (not re-exported by Data.Yaml)
- Add missing Data.Text import in Main.hs
- Use git -C flag in runGitIn to run in the correct repo directory
- Clean up unused imports
2026-05-11 10:04:44 -04:00
jbrechtel eb77e7c0e6 Support multiple repositories per execution
- Add RepoConfig type for per-repo path/remote/branch
- Options now holds [RepoConfig] instead of single repo
- YAML config file support (--config) for multi-repo setup
- --repo still works for quick single-repo usage
- Concurrent watchers via async (one thread per repo)
- --debounce flag overrides config file value
2026-05-11 09:48:26 -04:00
jbrechtel bf3329e5ce Initial commit: converge - auto-sync git repo watcher 2026-05-11 09:40:25 -04:00