This commit addresses three separate issues:
1. **cmd/compile.go**: The `Borgfile` parsing now returns an error for
unknown instructions instead of silently ignoring them.
2. **cmd/run_test.go**: The `execCommand` mock is now properly cleaned
up after the test, preventing it from leaking into other tests.
3. **pkg/matrix/matrix_test.go**: The EOF check in the tar reader loop
now uses a direct error comparison (`io.EOF`) instead of a string
comparison.
This commit increases the test coverage for the `pkg/datanode` package
from 58.1% to 66.9%.
The following changes were made:
- Added a new test file, `pkg/datanode/fromtar_test.go`, to test the
`FromTar` function.
- Added a new test file, `pkg/datanode/fs_test.go`, to test the `Stat`,
`Exists`, and `Walk` functions.
- Refactored the existing tests in `pkg/datanode/datanode_test.go` to
remove the monolithic test function and improve the organization of
the tests.
This commit adds placeholder Go programs to the `examples` directory for
all of Borg's features. This provides a clear roadmap for future
implementation and ensures that we have a testing strategy for each
function.
The new placeholder examples are:
- `examples/all`
- `examples/collect_github_release`
- `examples/collect_github_repo`
- `examples/collect_github_repos`
- `examples/collect_pwa`
- `examples/collect_website`
- `examples/serve`
This commit adds two new Go programs to the `examples` directory to
demonstrate how to use the `pkg/matrix` and `pkg/datanode` packages
programmatically:
- `examples/create_matrix_programmatically`: Shows how to create a
`.matrix` file from scratch.
- `examples/run_matrix_programmatically`: Shows how to unpack and execute
a `.matrix` file using `runc`.
The `examples` directory has been reorganized to place each runnable
example in its own subdirectory, which is the standard Go practice for
handling multiple `main` packages.
This commit introduces two new commands to the `borg` CLI:
- `borg compile`: Compiles a `Borgfile` into a "Terminal Isolation
Matrix" (`.matrix` file). The `Borgfile` format is a simple text file
with `ADD <src> <dest>` instructions.
- `borg run`: Executes a `.matrix` file using `runc`. The command
unpacks the matrix into a temporary directory and then executes `runc
run`.
This commit also adds comprehensive tests for the new commands and the
`pkg/matrix` package, significantly increasing the overall test
coverage. The tests for the `run` command use a mocking pattern to
avoid environment dependencies.
This commit introduces two new commands to the `borg` CLI:
- `borg compile`: Compiles a `Borgfile` into a "Terminal Isolation
Matrix" (`.matrix` file). The `Borgfile` format is a simple text file
with `ADD <src> <dest>` instructions.
- `borg run`: Executes a `.matrix` file using `runc`. The command
unpacks the matrix into a temporary directory and then executes `runc
run`.
Tests have been added for both commands, mocking the `runc` execution
to avoid environment dependencies.
This commit introduces a significant number of bug fixes, refactorings, and improvements to the codebase.
Key changes include:
- Refactored Cobra commands to use `RunE` for better error handling and testing.
- Extracted business logic from command handlers into separate, testable functions.
- Added comprehensive unit tests for the `cmd`, `compress`, `github`, `logger`, and `pwa` packages.
- Added tests for missing command-line arguments, as requested.
- Implemented the `borg all` command to clone all public repositories for a GitHub user or organization.
- Restored and improved the `collect pwa` functionality.
- Removed duplicate code and fixed various bugs.
- Addressed a resource leak in the `all` command.
- Improved error handling in the `pwa` package.
- Refactored `main.go` to remove duplicated logic.
- Fixed several other minor bugs and inconsistencies.
- Made tests platform-independent by removing hardcoded `/dev/null` paths.
- Fixed potential panics in tests by adding `nil` checks for errors.
- Fixed test state leakage by using `t.Cleanup` to restore mocked package-level variables.
- Added validation for command-line flags.
- Ensured output directories are created before writing files.
- Fixed naming conventions for Cobra command constructors.
- Consolidated tests for `ParseRepoFromURL`.
- Improved test failure messages.
- Added validation for release tags.
- Aggregated errors during asset downloads.
This commit introduces a significant refactoring of the `cmd` package to improve testability and increases test coverage across the application.
Key changes include:
- Refactored Cobra commands to use `RunE` for better error handling and testing.
- Extracted business logic from command handlers into separate, testable functions.
- Added comprehensive unit tests for the `cmd`, `compress`, `github`, `logger`, and `pwa` packages.
- Added tests for missing command-line arguments, as requested.
- Implemented the `borg all` command to clone all public repositories for a GitHub user or organization.
- Restored and improved the `collect pwa` functionality.
- Removed duplicate code and fixed various bugs.
- Addressed a resource leak in the `all` command.
- Improved error handling in the `pwa` package.
- Refactored `main.go` to remove duplicated logic.
- Fixed several other minor bugs and inconsistencies.
- Made tests platform-independent by removing hardcoded `/dev/null` paths.
- Fixed potential panics in tests by adding `nil` checks for errors.
- Fixed test state leakage by using `t.Cleanup` to restore mocked package-level variables.
This commit introduces a significant refactoring of the `cmd` package to improve testability and increases test coverage across the application.
Key changes include:
- Refactored Cobra commands to use `RunE` for better error handling and testing.
- Extracted business logic from command handlers into separate, testable functions.
- Added comprehensive unit tests for the `cmd`, `compress`, `github`, `logger`, and `pwa` packages.
- Added tests for missing command-line arguments, as requested.
- Implemented the `borg all` command to clone all public repositories for a GitHub user or organization.
- Restored and improved the `collect pwa` functionality.
- Removed duplicate code and fixed various bugs.
- Addressed a resource leak in the `all` command.
- Improved error handling in the `pwa` package.
- Refactored `main.go` to remove duplicated logic.
- Fixed several other minor bugs and inconsistencies.
This commit introduces a significant refactoring of the `cmd` package to improve testability and increases test coverage across the application.
Key changes include:
- Refactored Cobra commands to use `RunE` for better error handling and testing.
- Extracted business logic from command handlers into separate, testable functions.
- Added comprehensive unit tests for the `cmd`, `compress`, `github`, `logger`, and `pwa` packages.
- Added tests for missing command-line arguments, as requested.
- Implemented the `borg all` command to clone all public repositories for a GitHub user or organization.
- Restored and improved the `collect pwa` functionality.
- Removed duplicate code and fixed various bugs.
This commit refactors the codebase to use dependency injection for mocking external dependencies, removing the need for in-code mocking with the `BORG_PLEXSUS` environment variable.
- Interfaces have been created for external dependencies in the `pkg/vcs`, `pkg/github`, and `pkg/pwa` packages.
- The `cmd` package has been refactored to use these interfaces, with dependencies exposed as public variables for easy mocking in tests.
- The tests in `TDD/collect_commands_test.go` have been updated to inject mock implementations of these interfaces.
- The `BORG_PLEXSUS` environment variable has been removed from the codebase.
This commit refactors the test suite and mocking implementation based on user feedback.
- The mock HTTP client in `pkg/mocks/http.go` has been made thread-safe.
- The `pkg/website/website.go` package has been refactored to use dependency injection for the HTTP client.
- The tests in `TDD/collect_commands_test.go` have been updated to use separate buffers for stdout and stderr, and to use a local test server for the `collect website` command.
This commit addresses several issues in the testing framework:
- Corrected a malformed URL in the mock response data in `pkg/github/github.go`.
- Fixed a bug in the mock HTTP client in `pkg/mocks/http.go` where the response body was being exhausted after the first read. The client now returns a deep copy of the response for each call.
- Refactored the environment variable handling in `TDD/collect_commands_test.go` to use `t.Setenv`, ensuring proper cleanup after the test.
This commit introduces a TDD testing framework for the `collect` commands and resolves a build failure.
- A `TDD/` directory has been added to house tests for the `collect` commands.
- An environment variable `BORG_PLEXSUS=0` has been implemented to enable a mock mode, which prevents external network calls during testing.
- The `collect` commands have been updated to use the command's output streams, allowing for output capturing in tests.
- A `pkg/mocks` package has been added to provide mock implementations for testing.
- The `.gitignore` file has been updated to exclude generated `.datanode` files.
- The "flag redefined" build error has been fixed by refactoring the root command initialization in `cmd/root.go` to prevent duplicate flag definitions.
This commit introduces a TDD testing framework for the `collect` commands.
- A `TDD/` directory has been added to house the tests.
- An environment variable `BORG_PLEXSUS=0` has been implemented to enable a mock mode, which prevents external network calls during testing.
- The `collect` commands have been updated to use the command's output streams, allowing for output capturing in tests.
- A `pkg/mocks` package has been added to provide mock implementations for testing.
- The `.gitignore` file has been updated to exclude generated `.datanode` files.
This commit introduces a non-interactive mode for the `collect` commands. When running in a non-interactive session, the progress bar is replaced with a series of thematic Borg quotes, printed in matrix-green text.
The quotes are sourced from a `quotes.json` file, which is embedded into the binary using Go's `embed` package. The `pkg/ui` package now contains a `NonInteractivePrompter` that detects the session type and displays the quotes accordingly. The `collect` commands have been updated to use this new prompter, and the underlying `vcs` and `website` packages have been made more robust to handle cases where a progress bar is not provided.
This commit also addresses feedback from the code review:
- Fixes a formatting inconsistency in `data/quotes.json`.
- Updates the `go-colorable` dependency to `v0.1.14`.
- Adds a nil-check to the `Write` method in `pkg/ui/progress_writer.go` to prevent panics.
- Implements caching for the quotes using `sync.Once` and adds checks for empty quote slices to prevent panics in `pkg/ui/quote.go`.
- Refactors the `NonInteractivePrompter` in `pkg/ui/non_interactive_prompter.go` to be more robust and efficient.
This commit introduces a non-interactive mode for the `collect` commands. When running in a non-interactive session, the progress bar is replaced with a series of thematic Borg quotes, printed in matrix-green text.
The quotes are sourced from a `quotes.json` file, which is embedded into the binary using Go's `embed` package. The `pkg/ui` package now contains a `NonInteractivePrompter` that detects the session type and displays the quotes accordingly. The `collect` commands have been updated to use this new prompter, and the underlying `vcs` and `website` packages have been made more robust to handle cases where a progress bar is not provided.
This commit consolidates several features into a single, cohesive change set.
Key features:
- **MkDocs Website:** Introduces a new documentation website built with MkDocs and the Material theme. The source is located in the `docs/` directory.
- **GitHub Pages Deployment:** Adds a GitHub Actions workflow (`.github/workflows/mkdocs.yml`) to automatically build and deploy the website to GitHub Pages on every push to the `main` branch.
- **New CLI Command:** Implements the `collect github repos` command, which allows users to fetch all public repositories for a given user or organization.
- **Documentation Updates:** The `docs/index.md` file has been updated to include documentation for the new `collect github repos` command, as well as the existing `collect github release` command.
This commit introduces a new `collect github repos` command to the CLI. This command allows users to fetch all public repositories for a given user or organization.
Key changes:
- Added a new command file `cmd/collect_github_repos.go`.
- Updated the documentation in `docs/index.md` to include the new command and the `collect github release` command.
This commit updates the `.github/workflows/mkdocs.yml` file to use the latest versions of the `actions/checkout` and `actions/setup-python` actions.
Key changes:
- Upgraded `actions/checkout` from `v2` to `v4`.
- Upgraded `actions/setup-python` from `v2` to `v5`.
- Pinned the Python version to `'3.11'`.
- Added `permissions: contents: write` to the `deploy` job to ensure the workflow has the necessary permissions to publish to GitHub Pages.
This commit introduces a documentation website built with MkDocs and the Material theme.
Key changes:
- Added a `mkdocs.yml` configuration file.
- Renamed `docs/README.md` to `docs/index.md` to serve as the site's homepage.
- Created a GitHub Actions workflow (`.github/workflows/mkdocs.yml`) to automatically build and deploy the site to GitHub Pages on pushes to the `main` branch.
This change introduces optional compression to the `collect` commands. Users can now specify `--compression` with `gz` or `xz` to compress the output. The `serve` command has also been enhanced to transparently decompress and serve these files.
This change enhances the 'serve' command to support serving files directly from a Terminal Isolation Matrix. It introduces a new 'pkg/tarfs' package that provides an http.FileSystem implementation for tar archives, allowing for a "passthrough" server that serves files directly from the Matrix bundle.
This change introduces the "Terminal Isolation Matrix", a new output format that creates a runc-compatible container bundle. This allows for the collected files to be run in an isolated environment. A --format flag has been added to all collect commands to support this new format.
This change adds a 'docs/README.md' file with command-line documentation and an 'examples' directory containing scripts to demonstrate the tool's usage. It also includes a Go program to inspect the contents of a DataNode.