Skip to content

tests: make first_run.v work with current V and on Windows#291

Open
medvednikov wants to merge 1 commit into
masterfrom
ci/windows-first-run
Open

tests: make first_run.v work with current V and on Windows#291
medvednikov wants to merge 1 commit into
masterfrom
ci/windows-first-run

Conversation

@medvednikov

Copy link
Copy Markdown
Member

What

Makes tests/first_run.v compile with the current V compiler and run on Windows (in addition to macOS/Linux), so it can be used as an end-to-end "gitly serves the expected HTML" test — including from vlang/v's Windows CI.

Why

The test had bit-rotted and no longer ran:

  • It used the generic json.decode[T](body) or { … } form, but imported json (vlib/json, whose API is json.decode(T, s)). With current V this fails to compile. Fixed by import x.json2 as json (the convention already used elsewhere in gitly: github.v, webhook.v).
  • It compiled gitly without -d sqlite, so gitly used its default PostgreSQL backend and panicked at startup (Connection to a PG database failed). Fixed by compiling with -d sqlite (embedded DB, no external service needed).
  • It started gitly with os.execute('./gitly.exe &') and stopped it with pkill -9 — both Unix-only. On Windows the server never backgrounded/stopped, and after() then failed to delete the still-locked sqlite file. Fixed by using os.new_process for a cross-platform start + signal_kill/wait stop (DB/repos are removed only after the process exits).
  • -d use_libbacktrace / -d use_openssl are skipped on Windows (libbacktrace isn't available there; the native schannel https backend is used instead).

Reliability knob

GITLY_TEST_SKIP_REMOTE_REPO=1 skips the tests that clone a remote GitHub repo (network + outbound git/https heavy — the flakiest part). With it set, only the pure HTML/serving checks run (index, register, user page, login, static CSS, oauth, local repo creation). Default behavior (full test) is unchanged.

Testing

Validated locally on macOS with the current vlang/v:

  • GITLY_TEST_SKIP_REMOTE_REPO=1 v -g run tests/first_run.vall tests passed, clean shutdown, no leftover process/port.
  • Full run reaches and passes every HTML/serving assertion; only the remote-clone step depends on the environment.

Paired with a new Windows job in vlang/v that runs this (smoke mode) to verify gitly (which serves via veb → fasthttp) works on Windows.

- Use x.json2 (import x.json2 as json), so the generic json.decode[T](...) or {}
  calls compile with the current V compiler (vlib/json expects json.decode(T, s)).
- Compile gitly with -d sqlite, so the test uses the embedded sqlite backend
  instead of the default PostgreSQL one and needs no external database.
- Start/stop gitly via os.new_process instead of a Unix-only './gitly.exe &'
  plus 'pkill', so the test works on Windows, macOS and Linux, and reliably
  shuts the server down (releasing the sqlite file before it is removed).
- Skip -d use_libbacktrace/-d use_openssl on Windows (libbacktrace is not
  available there; the native schannel https backend is used instead).
- Add GITLY_TEST_SKIP_REMOTE_REPO to skip the network/git-heavy tests that
  clone a remote GitHub repo, so the pure 'serves the expected HTML' checks
  can run as a fast, reliable smoke test (e.g. in vlang/v's Windows CI).
@medvednikov medvednikov force-pushed the ci/windows-first-run branch from 4bcc206 to 8d5b688 Compare July 11, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant