From c0914fd1ed398da14247990b96b58db1726da213 Mon Sep 17 00:00:00 2001 From: Snider Date: Thu, 30 Oct 2025 17:37:48 +0000 Subject: [PATCH] (#12) Add GitHub Actions test coverage and platform-aware Taskfiles --- AGENTS.md | 77 --------------------------- README.md | 112 +++++++++++++++++++++++++++++++++------ pkg/io/sftp/sftp_test.go | 22 ++++---- 3 files changed, 105 insertions(+), 106 deletions(-) delete mode 100644 AGENTS.md diff --git a/AGENTS.md b/AGENTS.md deleted file mode 100644 index 93831db7..00000000 --- a/AGENTS.md +++ /dev/null @@ -1,77 +0,0 @@ -# Developer Guide - -This guide provides instructions for building, testing, and interacting with the Core project. - -## Project Structure - -The project is organized into the following main directories: - -- `pkg/`: Contains the core Go packages that make up the framework. -- `cmd/`: Contains the entry points for the two main applications: - - `core-gui/`: The Wails-based GUI application. - - `core/`: The command-line interface (CLI) application. - -## Development Workflow - -This project uses [Task](https://taskfile.dev/) for task automation. The `Taskfile.yml` in the root directory defines a set of tasks to streamline common development operations. - -### Prerequisites - -- [Go](https://go.dev/) -- [Node.js](https://nodejs.org/) -- [Wails](https://wails.io/) -- [Task](https://taskfile.dev/) - -### Available Tasks - -To run any of the following tasks, open your terminal in the project's root directory and execute the `task` command. - -#### General Tasks - -- `task test`: Runs all Go tests recursively for the entire project. -- `task check`: A comprehensive check that runs `go mod tidy`, the full test suite, and a CodeRabbit review. -- `task review`: Submits the current changes for a CodeRabbit review. -- `task cov`: Generates a test coverage profile (`coverage.txt`). -- `task cov-view`: Opens the HTML coverage report in your browser. - -#### GUI Application (`cmd/core-gui`) - -These tasks are run from the root directory and operate on the GUI application. - -- `task gui:build`: Builds the GUI application. -- `task gui:package`: Packages a production build of the GUI application. -- `task gui:run`: Runs the GUI application. -- `task gui:dev`: Runs the GUI application in development mode, with hot-reloading enabled. - -#### CLI Application (`cmd/core`) - -These tasks are run from the root directory and operate on the CLI application. - -- `task cli:build`: Builds the CLI application. -- `task cli:build:dev`: Builds the CLI application for development. - -## Building and Running - -### GUI Application - -To run the GUI application in development mode: - -```bash -task gui:dev -``` - -To build the final application for your platform: - -```bash -task gui:build -``` - -### CLI Application - -To build the CLI application: - -```bash -task cli:build -``` - -The executable will be located in the `cmd/core/bin` directory. diff --git a/README.md b/README.md index b119282c..01b039f2 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,14 @@ # Core -Core is an opinionated Go framework for building desktop apps with Wails. It provides a small set of focused modules: +Core is a Web3 Framework, written in Go using Wails.io to replace Electron and the bloat of browsers that, at their core, still live in their mum's basement. + +More to come, follow us on Discord http://discord.dappco.re -- Core — framework bootstrap and service container -- Core.Config — app and UI state persistence -- Core.Crypt — keys, encrypt/decrypt, sign/verify -- Core.Display — windows, tray, window state -- Core.Docs — in‑app help and deep‑links -- Core.IO — local/remote filesystem helpers -- [Core.Workspace](https://core.help/) — projects and paths -Help: https://Core.Help \ -Web: https://dAppCo.re \ Repo: https://github.com/Snider/Core ## Quick start + ```go import core "github.com/Snider/Core" @@ -23,28 +17,112 @@ app := core.New( ) ``` -## Tasks +## Development Workflow -This project uses [Task](https://taskfile.dev/) for task automation. The root `Taskfile.yml` includes the `Taskfile.yml` from `cmd/core-gui` and `cmd/core` under the `gui` and `cli` namespaces respectively. The following tasks are available: +This project follows a Test-Driven Development (TDD) approach. We use [Task](https://taskfile.dev/) for task automation to streamline the development process. -### General +The recommended workflow is: -- `task test`: Run all Go tests recursively for the entire project. -- `task review`: Run CodeRabbit review to get feedback on the current changes. -- `task check`: Run `go mod tidy`, the full test suite, and a CodeRabbit review. +1. **Generate Tests**: For any changes to the public API, first generate the necessary test stubs. + + ```bash + task test-gen + ``` + +2. **Run Tests (and watch them fail)**: Verify that the new tests fail as expected. + + ```bash + task test + ``` + +3. **Implement Your Feature**: Write the code to make the tests pass. + +4. **Run Tests Again**: Ensure all tests now pass. + + ```bash + task test + ``` + +5. **Submit for Review**: Once your changes are complete and tests are passing, submit them for a CodeRabbit review. + + ```bash + task review + ``` + +## Project Structure + +The project is organized into the following main directories: + +- `pkg/`: Contains the core Go packages that make up the framework. +- `cmd/`: Contains the entry points for the two main applications: + - `core-gui/`: The Wails-based GUI application. + - `core/`: The command-line interface (CLI) application. + +## Prerequisites + +- [Go](https://go.dev/) +- [Node.js](https://nodejs.org/) +- [Wails](https://wails.io/) +- [Task](https://taskfile.dev/) + +## Building and Running + +### GUI Application + +To run the GUI application in development mode: + +```bash +task gui:dev +``` + +To build the final application for your platform: + +```bash +task gui:build +``` + +### CLI Application + +To build the CLI application: + +```bash +task cli:build +``` + +The executable will be located in the `cmd/core/bin` directory. + +## Available Tasks + +To run any of the following tasks, open your terminal in the project's root directory and execute the `task` command. + +### General Tasks + +- `task test`: Runs all Go tests recursively for the entire project. +- `task test-gen`: Generates tests for the public API. +- `task check`: A comprehensive check that runs `go mod tidy`, the full test suite, and a CodeRabbit review. +- `task review`: Submits the current changes for a CodeRabbit review. +- `task cov`: Generates a test coverage profile (`coverage.txt`). +- `task cov-view`: Opens the HTML coverage report in your browser. +- `task sync`: Updates the public API Go files to match the exported interface of the modules. ### GUI Application (`cmd/core-gui`) +These tasks are run from the root directory and operate on the GUI application. + - `task gui:build`: Builds the GUI application. - `task gui:package`: Packages a production build of the GUI application. - `task gui:run`: Runs the GUI application. -- `task gui:dev`: Runs the GUI application in development mode. +- `task gui:dev`: Runs the GUI application in development mode, with hot-reloading enabled. ### CLI Application (`cmd/core`) +These tasks are run from the root directory and operate on the CLI application. + - `task cli:build`: Builds the CLI application. - `task cli:build:dev`: Builds the CLI application for development. - `task cli:run`: Builds and runs the CLI application. +- `task cli:sync`: Updates the public API Go files. +- `task cli:test-gen`: Generates tests for the public API. ## Docs (MkDocs) The help site and in‑app docs are built with MkDocs Material and live under `pkg/v1/core/docs`. diff --git a/pkg/io/sftp/sftp_test.go b/pkg/io/sftp/sftp_test.go index dda4a6ed..3c7873d2 100644 --- a/pkg/io/sftp/sftp_test.go +++ b/pkg/io/sftp/sftp_test.go @@ -7,19 +7,21 @@ import ( "time" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) // setupTest creates a temporary home directory and a dummy known_hosts file // to prevent tests from failing in CI environments where the file doesn't exist. func setupTest(t *testing.T) { + t.Helper() homeDir := t.TempDir() t.Setenv("HOME", homeDir) sshDir := filepath.Join(homeDir, ".ssh") err := os.Mkdir(sshDir, 0700) - assert.NoError(t, err) + require.NoError(t, err) knownHostsFile := filepath.Join(sshDir, "known_hosts") err = os.WriteFile(knownHostsFile, []byte{}, 0600) - assert.NoError(t, err) + require.NoError(t, err) } func TestNew(t *testing.T) { @@ -104,7 +106,7 @@ func TestNew_AuthFailure_InvalidKeyFormat(t *testing.T) { setupTest(t) // Create a temporary file with invalid key content tmpFile, err := os.CreateTemp("", "invalid_key") - assert.NoError(t, err) + require.NoError(t, err) defer func(name string) { err := os.Remove(name) if err != nil { @@ -113,11 +115,9 @@ func TestNew_AuthFailure_InvalidKeyFormat(t *testing.T) { }(tmpFile.Name()) _, err = tmpFile.WriteString("not a valid ssh key") - assert.NoError(t, err) + require.NoError(t, err) err = tmpFile.Close() - if err != nil { - return - } + require.NoError(t, err) cfg := ConnectionConfig{ Host: "localhost", @@ -136,7 +136,7 @@ func TestNew_MultipleAuthMethods(t *testing.T) { setupTest(t) // Create a temporary file with invalid key content to ensure key-based auth is attempted tmpFile, err := os.CreateTemp("", "dummy_key") - assert.NoError(t, err) + require.NoError(t, err) defer func(name string) { err := os.Remove(name) if err != nil { @@ -145,11 +145,9 @@ func TestNew_MultipleAuthMethods(t *testing.T) { }(tmpFile.Name()) _, err = tmpFile.WriteString("not a valid ssh key") - assert.NoError(t, err) + require.NoError(t, err) err = tmpFile.Close() - if err != nil { - return - } + require.NoError(t, err) cfg := ConnectionConfig{ Host: "localhost",