-
Notifications
You must be signed in to change notification settings - Fork 0
Improve testkit robustness and release readiness #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2ecf314
Improve testkit robustness and release readiness.
bschellenberger2600 0273a41
Expand user and contributor documentation.
bschellenberger2600 3d216ef
Fix remote URL parsing for paths with spaces.
bschellenberger2600 58fe7d0
feat: add USB fixture helpers for target-volume testing
bschellenberger2600 53832d7
Harden snapshot restore root and add security regressions
cursoragent e8663de
Address CodeRabbit review on PR #1
bschellenberger2600 929834e
fix(testutil): harden USB fixtures per review feedback
bschellenberger2600 c2b6dc4
fix(testutil): stricter .git-fire parsing and layout validation tests
bschellenberger2600 e3d6168
Merge origin/chore/repo-quality-hardening into fix/getremotes-space-p…
bschellenberger2600 d088c08
Fix snapshot name normalization for dot-dot paths
cursoragent 4b81b77
Merge pull request #2 from git-fire/fix/getremotes-space-paths
bschellenberger2600 628a737
test: add coverage for AssertGitDirAt helper
cursoragent d0c6cb2
Fix traversal checks and USB config unquoting
cursoragent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| go-version: ["1.22.x", "stable"] | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: ${{ matrix.go-version }} | ||
|
|
||
| - name: Run vet | ||
| run: go vet ./... | ||
|
|
||
| - name: Run tests | ||
| run: go test ./... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| # Developer Guide | ||
|
|
||
| This guide covers how to use `git-testkit`, contribute safely, run checks locally, and maintain releases. | ||
|
|
||
| ## Audience | ||
|
|
||
| - **Users** writing tests that need real git repositories. | ||
| - **Contributors** making code/docs changes. | ||
| - **Maintainers/admins** preparing releases and keeping CI healthy. | ||
|
|
||
| ## Local setup | ||
|
|
||
| Requirements: | ||
|
|
||
| - Go 1.22+ | ||
| - `git` on `PATH` | ||
|
|
||
| Clone and verify: | ||
|
|
||
| ```bash | ||
| # HTTPS (no SSH keys required) | ||
| git clone https://github.com/git-fire/git-testkit.git | ||
|
|
||
| # or SSH | ||
| # git clone git@github.com:git-fire/git-testkit.git | ||
|
|
||
| cd git-testkit | ||
| go test ./... | ||
| ``` | ||
|
|
||
| ## Project structure | ||
|
|
||
| - `fixtures.go`: base repo creation and command helpers. | ||
| - `scenarios.go`: fluent scenario builder and predefined multi-repo scenarios. | ||
| - `snapshots.go`: snapshot/restore utilities for expensive test setup reuse. | ||
| - `fixtures_test.go`: external package tests (`testutil_test`) that validate public API usage. | ||
| - `scenarios_test.go`: package-internal tests for scenario/snapshot behavior. | ||
|
|
||
| ## Design principles | ||
|
|
||
| - Prefer real git commands over mocks for behavior confidence. | ||
| - Keep helper APIs composable and minimal. | ||
| - Fail fast in setup helpers (`t.Fatalf`) so fixture errors are obvious. | ||
| - Keep tests isolated using `t.TempDir()`. | ||
|
|
||
| ## Testing and quality checks | ||
|
|
||
| Run before opening a PR: | ||
|
|
||
| ```bash | ||
| gofmt -w *.go | ||
| go vet ./... | ||
| go test ./... | ||
| ``` | ||
|
|
||
| Optional: | ||
|
|
||
| ```bash | ||
| go test -short ./... | ||
| ``` | ||
|
|
||
| CI mirrors the required checks (`go vet` and `go test`) on pull requests. | ||
|
|
||
| ## Usage guidance for library consumers | ||
|
|
||
| - Prefer scenario builders for integration-style tests with remotes/worktrees. | ||
| - Prefer base fixtures for small unit/integration tests that only need one repo. | ||
| - Keep assertions close to setup; helper failures already include command output. | ||
| - Use snapshots for expensive setups that are reused across subtests. | ||
|
|
||
| Common usage split: | ||
|
|
||
| - `CreateTestRepo`: fast setup for single-repo state. | ||
| - `NewScenario`: multi-repo topologies and fluent setup. | ||
| - `SnapshotRepo`/`RestoreSnapshot`: performance optimization for repeated expensive setups. | ||
|
|
||
| ## Adding new helpers | ||
|
|
||
| When adding new exported helpers: | ||
|
|
||
| - Add or update tests in `fixtures_test.go` and/or `scenarios_test.go`. | ||
| - Add usage notes/examples to `README.md` when the helper is user-facing. | ||
| - Keep function names explicit and test-focused (avoid generic utility names). | ||
|
|
||
| ## Snapshot safety expectations | ||
|
|
||
| - Snapshot restore must never write outside the restore root. | ||
| - Avoid introducing behavior that can restore unsupported file types silently. | ||
| - Keep snapshot behavior deterministic for repeatable tests. | ||
|
|
||
| ## Pull request guidance | ||
|
|
||
| - Keep PRs focused and small when possible. | ||
| - Include a clear "why" in the commit/PR description. | ||
| - Include a short test plan with commands you ran locally. | ||
| - Prefer additive, backward-compatible changes for existing exported helpers. | ||
|
|
||
| Suggested PR checklist: | ||
|
|
||
| - [ ] public API changes documented in `README.md` | ||
| - [ ] tests added/updated for behavior changes | ||
| - [ ] `gofmt`, `go vet`, and `go test` all pass locally | ||
| - [ ] no unrelated refactors mixed into functional changes | ||
|
|
||
| ## Maintainer/admin workflow | ||
|
|
||
| ### Branch and PR flow | ||
|
|
||
| 1. Create a feature branch from `main`. | ||
| 2. Commit focused changes with clear commit messages. | ||
| 3. Open a PR with summary and test plan. | ||
| 4. Merge only after CI is green. | ||
|
|
||
| ### Release flow | ||
|
|
||
| 1. Verify `main` has passed CI. | ||
| 2. Confirm `README.md` and this guide reflect current API/behavior. | ||
| 3. Pull release notes from merged PRs (user-visible changes first). | ||
| 4. Create and push a version tag. | ||
| 5. Publish a GitHub release with: | ||
| - notable changes | ||
| - compatibility notes (for example, minimum Go version) | ||
| - migration notes when behavior changed | ||
|
|
||
| ## Release notes checklist | ||
|
|
||
| Before cutting a release: | ||
|
|
||
| - Ensure CI is green on `main`. | ||
| - Summarize user-visible changes (new helpers, behavior changes, compatibility notes). | ||
| - Call out any minimum Go version changes. | ||
| - Verify examples in `README.md` still compile conceptually with current API. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.