Skip to content

Conversation

madflojo
Copy link
Member

@madflojo madflojo commented Jun 14, 2025

This commit introduces support for using NATS as a key-value store via the Hord library.

NATS configuration and testing align with established patterns within the Tarmac project. The NATS test case in TestFullService is treated consistently with other integration tests. Unnecessary inline comments added during development have been removed.

Changes include:

  • NATS configuration parameters are fetched directly (e.g., nats_urls) in pkg/app/app.go.
  • The pkg/config/config.go file no longer contains NATS-specific structures.
  • Documentation in docs/running-tarmac/configuration.md has been updated for the corrected configuration keys.
  • NATS testing is integrated into the TestFullService function in pkg/app/server_test.go.
  • The import alias for the NATS hord driver is now nats.
  • Unnecessary inline comments related to NATS have been removed from pkg/app/app.go, pkg/app/app_test.go, and pkg/app/server_test.go.
  • The CI configuration in .github/workflows/build.yml includes a job for NATS tests, running a NATS server.

Summary by CodeRabbit

  • New Features
    • Added support for using NATS as a key-value store backend.
    • Updated configuration options and documentation to include NATS setup and environment variables.
  • Documentation
    • Expanded documentation to describe NATS as a supported key-value datastore and detailed its configuration.
  • Tests
    • Introduced new test cases for NATS backend, including both full service and invalid configuration scenarios.
  • Chores
    • Enhanced CI workflow to run tests against a local NATS server.

This commit introduces support for using NATS as a key-value store
via the Hord library.

NATS configuration and testing align with established patterns within
the Tarmac project. The NATS test case in TestFullService is treated
consistently with other integration tests. Unnecessary inline comments
added during development have been removed.

Changes include:
- NATS configuration parameters are fetched directly (e.g., `nats_urls`)
  in `pkg/app/app.go`.
- The `pkg/config/config.go` file no longer contains NATS-specific
  structures.
- Documentation in `docs/running-tarmac/configuration.md` has been
  updated for the corrected configuration keys.
- NATS testing is integrated into the `TestFullService` function in
  `pkg/app/server_test.go`.
- The import alias for the NATS hord driver is now `nats`.
- Unnecessary inline comments related to NATS have been removed from
  `pkg/app/app.go`, `pkg/app/app_test.go`, and
  `pkg/app/server_test.go`.
- The CI configuration in `.github/workflows/build.yml` includes a
  job for NATS tests, running a NATS server.
Copy link
Contributor

coderabbitai bot commented Jun 14, 2025

Walkthrough

Support for using NATS as a key-value store backend has been added to the application. This includes updates to documentation, configuration handling, and automated tests, as well as a new GitHub Actions workflow job that runs tests against a local NATS service. No changes were made to exported or public entity declarations.

Changes

File(s) Change Summary
.github/workflows/build.yml Added a new nats job to CI: runs tests against a NATS container and uploads coverage.
docs/running-tarmac/configuration.md Documented new nats KV store type and its related environment variables.
docs/running-tarmac/kvstore.md Added "NATS" as a supported key-value datastore with description.
pkg/app/app.go Added logic to initialize and connect to a NATS KV store backend based on configuration.
pkg/app/app_test.go Added a test case for invalid NATS configuration to bad configs tests.
pkg/app/server_test.go Added a full-service test case using NATS as the key-value backend.
Makefile Added tests-nats target to run NATS-related tests using Docker Compose.
dev-compose.yml Added nats and tests-nats-runner services for NATS testing environment.
go.mod Added direct dependency on github.com/tarmac-project/hord/drivers/nats and upgraded related modules.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Server
    participant NATS

    User->>Server: Start with kvstore_type = "nats"
    Server->>NATS: Connect using config (servers, user, password)
    alt Connection successful
        Server->>User: Server runs with NATS as KV store
    else Connection fails
        Server->>User: Error: failed to connect to NATS kvstore
    end
Loading

Poem

In the warren, news hops fast and free,
Now NATS joins our key-value spree!
Docs and tests, all up to date,
CI checks NATS—how great!
With every hop and every store,
Tarmac’s ready to do much more.
🥕


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1b39b5 and 177367c.

📒 Files selected for processing (5)
  • docs/running-tarmac/configuration.md (1 hunks)
  • docs/running-tarmac/kvstore.md (1 hunks)
  • pkg/app/app.go (3 hunks)
  • pkg/app/app_test.go (1 hunks)
  • pkg/app/server_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • docs/running-tarmac/kvstore.md
  • docs/running-tarmac/configuration.md
  • pkg/app/app_test.go
  • pkg/app/app.go
  • pkg/app/server_test.go
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: golangci
  • GitHub Check: nats
  • GitHub Check: mysql
  • GitHub Check: postgres
  • GitHub Check: boltdb
  • GitHub Check: in-memory
  • GitHub Check: build
  • GitHub Check: tests
  • GitHub Check: redis
  • GitHub Check: cassandra
  • GitHub Check: Analyze (go)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (6)
docs/running-tarmac/kvstore.md (1)

22-23: Row ordering is inconsistent with the existing alphabetical pattern

Previous rows are roughly ordered alphabetically by the Type option (boltdb, cassandra, in-memory, redis).
Adding nats after cassandra breaks that pattern and makes scanning harder.

-| Cassandra | `cassandra` | Cassandra including TLS connectivity | Eventual Consistency, Persistent Storage, Large sets of data |
-| NATS | `nats` | NATS Server including JetStream for KV | Flexible, Cloud-Native Messaging and KV, Eventual Consistency |
+| Cassandra | `cassandra` | Cassandra including TLS connectivity | Eventual Consistency, Persistent Storage, Large sets of data |
+| NATS | `nats` | NATS Server including JetStream for KV | Flexible, Cloud-Native Messaging and KV, Eventual Consistency |
+| Redis | `redis` | Redis including Sentinel and Enterprise capabilities | Strong Consistency, Fast Reads and Writes, Non-Persistent storage |

(Re-ordering only—content unchanged.)

docs/running-tarmac/configuration.md (1)

33-36: Missing defaults / validation guidance for new NATS vars

For every other backend we document whether a variable is required or has a default.
Consider explicitly stating:

  • default value when kvstore_type != nats (empty string?)
  • behaviour when APP_NATS_USER/PASSWORD are omitted but the server requires auth.

This keeps the docs self-contained and avoids guessing.

pkg/app/app.go (1)

31-32: Import alias shadows common package name

Using the bare identifier nats for the driver means later code refers to nats.Dial, which can be confused with the upstream github.com/nats-io/nats.go.
To avoid ambiguity, import with an alias:

-	"github.com/tarmac-project/hord/drivers/nats"
+	natsdrv "github.com/tarmac-project/hord/drivers/nats"

And update the call-site accordingly.

pkg/app/app_test.go (1)

89-97: Test name nit & missing negative assertion

Nice addition.
Minor: all other keys are lower-case (“invalid kvstore address”), but this one is titled “invalid NATS Address”. Consider consistent casing.

Optional: assert that the returned error string contains “nats” to ensure we’re failing for the expected reason, not something unrelated (e.g. port clash).

pkg/app/server_test.go (1)

222-230: Port reuse may cause flaky tests

Every full-service sub-test binds to localhost:9001.
If the previous server hasn’t released the socket yet, the NATS case (or vice-versa) can fail with “address already in use”, especially on CI with slower teardown.

Recommend allocating a unique free port per test:

port, _ := freeport.Get()
cfg.Set("listen_addr", fmt.Sprintf("localhost:%d", port))

(Or bump to 0 and read back srv.httpServer.Addr after Listen).

.github/workflows/build.yml (1)

1-2: Lock down GITHUB_TOKEN permissions
Define an explicit, minimal permissions block to follow least privilege.

Apply this diff:

 name: build
+permissions:
+  contents: read
 on:
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3469d3 and c706975.

📒 Files selected for processing (6)
  • .github/workflows/build.yml (1 hunks)
  • docs/running-tarmac/configuration.md (1 hunks)
  • docs/running-tarmac/kvstore.md (1 hunks)
  • pkg/app/app.go (2 hunks)
  • pkg/app/app_test.go (1 hunks)
  • pkg/app/server_test.go (1 hunks)
🧰 Additional context used
🪛 GitHub Check: CodeQL
.github/workflows/build.yml

[warning] 123-142: Workflow does not contain permissions
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{contents: read}}

🪛 YAMLlint (1.37.1)
.github/workflows/build.yml

[warning] 130-130: wrong indentation: expected 6 but found 4

(indentation)

⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: nats
  • GitHub Check: postgres
  • GitHub Check: boltdb
  • GitHub Check: mysql
  • GitHub Check: in-memory
  • GitHub Check: redis
  • GitHub Check: cassandra
  • GitHub Check: tests
  • GitHub Check: build
  • GitHub Check: golangci
  • GitHub Check: Analyze (go)
🔇 Additional comments (2)
.github/workflows/build.yml (2)

121-142: Add NATS integration tests job
The new nats job mirrors existing KV-store jobs, setting up the NATS service container and invoking make build tests-nats.

🧰 Tools
🪛 GitHub Check: CodeQL

[warning] 123-142: Workflow does not contain permissions
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{contents: read}}

🪛 YAMLlint (1.37.1)

[warning] 130-130: wrong indentation: expected 6 but found 4

(indentation)


130-130: Ignore YAMLlint indentation warning
The 4-space indent for - uses: is consistent with existing jobs; you can safely disregard this lint alert.

🧰 Tools
🪛 YAMLlint (1.37.1)

[warning] 130-130: wrong indentation: expected 6 but found 4

(indentation)

pkg/app/app.go Outdated
Comment on lines 325 to 333
case "nats":
srv.kv, err = nats.Dial(nats.Config{
Servers: srv.cfg.GetString("nats_urls"),
User: srv.cfg.GetString("nats_user"),
Password: srv.cfg.GetString("nats_password"),
})
if err != nil {
return fmt.Errorf("could not establish nats kvstore connection - %w", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

No empty-config guard & multi-URL handling for NATS connection

  1. The code proceeds to dial even when nats_urls is empty, returning a generic “unknown host” later.
  2. Docs say the value is “comma-separated list”, but the field is forwarded verbatim; if nats.Dial expects a slice you’ll only ever use the first URL.
-		case "nats":
-			srv.kv, err = nats.Dial(nats.Config{
-				Servers:  srv.cfg.GetString("nats_urls"),
-				User:     srv.cfg.GetString("nats_user"),
-				Password: srv.cfg.GetString("nats_password"),
-			})
+		case "nats":
+			rawURLs := strings.TrimSpace(srv.cfg.GetString("nats_urls"))
+			if rawURLs == "" {
+				return fmt.Errorf("nats_urls must be provided when kvstore_type is nats")
+			}
+
+			urls := strings.Split(rawURLs, ",")
+
+			srv.kv, err = natsdrv.Dial(natsdrv.Config{
+				Servers:  urls,
+				User:     srv.cfg.GetString("nats_user"),
+				Password: srv.cfg.GetString("nats_password"),
+			})

Also remember to import "strings" and to use the alias suggested above.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In pkg/app/app.go around lines 325 to 333, add a guard to check if the
"nats_urls" config value is empty before attempting to dial, returning an error
early if so. Then, split the "nats_urls" string by commas into a slice to handle
multiple URLs properly, and pass this slice to the nats.Dial configuration
instead of the raw string. Also, ensure the "strings" package is imported and
use the suggested alias for it in the file.

Comment on lines 121 to 142

nats:
runs-on: ubuntu-latest
services:
nats:
image: nats:latest
ports:
- 4222:4222
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Execute Tests
env:
NATS_URLS: nats://localhost:4222 # Ensure test uses this if it becomes configurable
run: make build tests-nats # Assuming a make target 'tests-nats' will be created
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify Makefile target for NATS tests
Ensure the tests-nats make target exists to avoid failures when this workflow runs.


🏁 Script executed:

#!/bin/bash
# Check for tests-nats target in Makefile
grep -R "^tests-nats:" -n Makefile

Length of output: 36


I’ll check the entire repo for any tests-nats references and locate all Makefile files to ensure we’re not missing a secondary Makefile.


🏁 Script executed:

#!/bin/bash
# Search for any definition or usage of tests-nats
grep -R "tests-nats" -n .

# List all Makefile variants in the repo
find . -type f \( -iname "Makefile" -o -iname "makefile" -o -iname "GNUmakefile" \)

Length of output: 638


Add missing tests-nats Makefile target
The workflow invokes make build tests-nats but no such target exists in the root Makefile, causing CI failures.

Points to address:

  • .github/workflows/build.yml (lines ~136–142) calls make build tests-nats
  • Root Makefile is missing a tests-nats: definition

Suggested fix:
In your root Makefile, add something like:

tests-nats:
    go test ./... -tags nats

Or update the workflow to call an existing test target instead of tests-nats.

🧰 Tools
🪛 GitHub Check: CodeQL

[warning] 123-142: Workflow does not contain permissions
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{contents: read}}

🪛 YAMLlint (1.37.1)

[warning] 130-130: wrong indentation: expected 6 but found 4

(indentation)

🤖 Prompt for AI Agents
In .github/workflows/build.yml around lines 121 to 142, the workflow runs `make
build tests-nats` but the root Makefile lacks a `tests-nats` target, causing CI
failures. To fix this, add a `tests-nats` target in the root Makefile that runs
the NATS-specific tests, for example by adding a target that executes `go test
./... -tags nats`. Alternatively, update the workflow to call an existing test
target if appropriate.

…in permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
.github/workflows/build.yml (1)

127-128: Pin NATS service container to a fixed version
Using nats:latest in CI can lead to non-deterministic builds as upstream images change. Consider specifying a known version tag, e.g., nats:2.11.4.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c706975 and 9ee8865.

📒 Files selected for processing (1)
  • .github/workflows/build.yml (2 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/build.yml

[warning] 132-132: wrong indentation: expected 6 but found 4

(indentation)

⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Analyze (go)
  • GitHub Check: mysql
  • GitHub Check: postgres
  • GitHub Check: nats
  • GitHub Check: in-memory
  • GitHub Check: tests
  • GitHub Check: cassandra
  • GitHub Check: boltdb
  • GitHub Check: redis
  • GitHub Check: build
🔇 Additional comments (1)
.github/workflows/build.yml (1)

11-12: Add minimal permissions for GITHUB_TOKEN
Good to see permissions: contents: read added to restrict default token access.

Comment on lines 137 to 140
- name: Execute Tests
env:
NATS_URLS: nats://localhost:4222 # Ensure test uses this if it becomes configurable
run: make build tests-nats # Assuming a make target 'tests-nats' will be created
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Ensure tests-nats make target exists
The workflow runs make build tests-nats but the root Makefile currently doesn't define a tests-nats target, which will cause CI failures. Please add a target like:

tests-nats:
    go test ./... -tags nats

or update the workflow to call an existing test target.

🤖 Prompt for AI Agents
In .github/workflows/build.yml around lines 137 to 140, the workflow runs `make
build tests-nats` but the Makefile lacks a `tests-nats` target, causing CI
failures. To fix this, add a `tests-nats` target in the root Makefile that runs
the tests with the nats build tag, for example: `tests-nats: go test ./... -tags
nats`. Alternatively, update the workflow to use an existing test target if
appropriate.

Comment on lines +131 to +132
steps:
- uses: actions/checkout@v4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix YAML indentation for steps list in the nats job
List items under steps: must be indented two spaces further (6 spaces total) to be valid YAML.
Apply this diff to correct the indentation:

-    steps:
-    - uses: actions/checkout@v4
+    steps:
+      - uses: actions/checkout@v4

And similarly adjust the indent for all subsequent - name entries.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
steps:
- uses: actions/checkout@v4
steps:
- uses: actions/checkout@v4
🧰 Tools
🪛 YAMLlint (1.37.1)

[warning] 132-132: wrong indentation: expected 6 but found 4

(indentation)

🤖 Prompt for AI Agents
In .github/workflows/build.yml at lines 131 to 132, the list items under the
steps key in the nats job are not indented correctly. Fix the YAML by indenting
all list items under steps by two additional spaces (total of 6 spaces) to
ensure valid YAML syntax. Apply this indentation adjustment consistently to all
subsequent - name entries within the steps list.

This commit introduces support for using NATS as a key-value store
via the Hord library.

NATS configuration and testing align with established patterns within
the Tarmac project. Integration tests for NATS are managed via
Docker Compose, consistent with other services. The explicit sleep
in the Makefile for NATS tests has been removed.

Key changes include:
- NATS configuration parameters are fetched directly (e.g., `nats_urls`)
  in `pkg/app/app.go`.
- `pkg/config/config.go` no longer contains NATS-specific structures.
- Documentation in `docs/running-tarmac/configuration.md` updated.
- NATS testing integrated into `TestFullService` in
  `pkg/app/server_test.go`.
- Import alias for NATS hord driver is now `nats`.
- Unnecessary inline comments removed from relevant Go files.
- NATS service added to `dev-compose.yml`.
- `tests-nats` Makefile target updated to use Docker Compose for starting
  NATS and running tests via a dedicated test runner service; explicit
  sleep removed.
- NATS service definition removed from `.github/workflows/build.yml`;
  CI now relies on the `make tests-nats` target.
- `go.mod` and `go.sum` files are up to date.
Comment on lines +123 to +135
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Execute Tests
run: make build tests-nats
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 3 months ago

To fix the issue, we will add a permissions block at the root of the workflow file. This block will apply to all jobs in the workflow unless overridden by job-specific permissions blocks. Based on the workflow's tasks (e.g., checking out code, running tests, and uploading coverage), the minimal required permissions are contents: read and actions: write (for uploading coverage). This ensures that the workflow has only the access it needs.


Suggested changeset 1
.github/workflows/build.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -10,2 +10,5 @@
   pull_request:
+permissions:
+    contents: read
+    actions: write
 jobs:
EOF
@@ -10,2 +10,5 @@
pull_request:
permissions:
contents: read
actions: write
jobs:
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
.github/workflows/build.yml (1)

122-135: ⚠️ Potential issue

Add explicit permissions for the nats job.

CodeQL flagged that the job does not limit GITHUB_TOKEN permissions. Add a minimal permissions block under nats: (or globally) to restrict scope.

  nats:
+   permissions:
+     contents: read
    runs-on: ubuntu-latest
    steps:
🧰 Tools
🪛 GitHub Check: CodeQL

[warning] 123-135: Workflow does not contain permissions
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{contents: read}}

🪛 YAMLlint (1.37.1)

[warning] 125-125: wrong indentation: expected 6 but found 4

(indentation)

🧹 Nitpick comments (4)
.github/workflows/build.yml (1)

124-126: Fix YAML indentation for steps list.

List items under steps: must be indented two additional spaces (6 spaces total) to be valid YAML.

-    steps:
-    - uses: actions/checkout@v4
+    steps:
+      - uses: actions/checkout@v4

…and adjust all subsequent - name / - run entries accordingly.

🧰 Tools
🪛 YAMLlint (1.37.1)

[warning] 125-125: wrong indentation: expected 6 but found 4

(indentation)

dev-compose.yml (3)

258-262: Prefer using expose for internal-only ports.

Since NATS is only consumed by other services in the Compose network, switch from ports to expose to match the style of other internal services.

-  nats:
-    image: nats:latest
-    ports:
-      - "4222:4222"
+  nats:
+    image: nats:latest
+    expose:
+      - "4222"

263-271: Align test-runner -run pattern with other services.

Other test runners append .* to match all relevant subtests. Add the wildcard for consistency.

-    entrypoint: go test -v -race -covermode=atomic -coverprofile=/tmp/coverage/coverage.out -run "TestFullService/NATS KV Full Service" ./...
+    entrypoint: go test -v -race -covermode=atomic -coverprofile=/tmp/coverage/coverage.out -run "TestFullService/NATS KV Full Service.*" ./...

272-278: Remove redundant inline comments in environment.

Inline comments after each env var are unnecessary and clutter the YAML. Removing them improves readability.

-      - "APP_ENABLE_TLS=false" # Common in other test services
+      - "APP_ENABLE_TLS=false"

…and apply the same cleanup to the other entries under environment.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9ee8865 and f1b39b5.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • .github/workflows/build.yml (1 hunks)
  • Makefile (1 hunks)
  • dev-compose.yml (1 hunks)
  • go.mod (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • go.mod
🧰 Additional context used
🪛 GitHub Check: CodeQL
.github/workflows/build.yml

[warning] 123-135: Workflow does not contain permissions
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {{contents: read}}

🪛 YAMLlint (1.37.1)
.github/workflows/build.yml

[warning] 125-125: wrong indentation: expected 6 but found 4

(indentation)

⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: postgres
  • GitHub Check: in-memory
  • GitHub Check: mysql
  • GitHub Check: nats
  • GitHub Check: cassandra
  • GitHub Check: boltdb
  • GitHub Check: tests
  • GitHub Check: redis
  • GitHub Check: build
  • GitHub Check: golangci
  • GitHub Check: Analyze (go)
🔇 Additional comments (1)
Makefile (1)

60-65: Makefile target for tests-nats is correctly defined.

The new tests-nats target mirrors existing patterns: detaching core services, invoking the test runner, and bringing services down.

This commit introduces support for using NATS as a key-value store
via the Hord library.

NATS configuration and testing align with established patterns within
the Tarmac project. Integration tests for NATS are now managed via
Docker Compose, consistent with other services.

Key changes include:
- NATS configuration parameters are fetched directly (e.g., `nats_urls`)
  in `pkg/app/app.go`.
- `pkg/config/config.go` no longer contains NATS-specific structures.
- Documentation in `docs/running-tarmac/configuration.md` updated.
- NATS testing integrated into `TestFullService` in
  `pkg/app/server_test.go`.
- Import alias for NATS hord driver is now `nats`.
- Unnecessary inline comments removed from relevant Go files.
- NATS service added to `dev-compose.yml`.
- `tests-nats` Makefile target updated to use Docker Compose for starting
  NATS and running tests via a dedicated test runner service.
- NATS service definition removed from `.github/workflows/build.yml`.
- `go.mod` and `go.sum` files are up to date.
@madflojo madflojo changed the title feat: Add NATS Hord driver support feat: add nats hord driver support Jun 15, 2025
This commit corrects the NATS Hord driver integration to use a single
`nats_url` configuration parameter, aligning with the driver's primary
connection method and simplifying setup for the most common use case.
Previous implementations incorrectly focused on a list of servers.

Key changes:
- Modified `pkg/app/app.go` to use `srv.cfg.GetString("nats_url")` and
  populate the `URL` field of `nats.Config`. Logic for parsing
  comma-separated URLs into `Servers` has been removed.
- Updated documentation in `docs/running-tarmac/configuration.md` to
  reflect `nats_url` (singular) and `APP_NATS_URL` (singular),
  removing references to `nats_urls` (plural).
- Test configurations in `pkg/app/server_test.go` and
  `pkg/app/app_test.go` updated to use `nats_url` (singular).
- `go.mod` and `go.sum` files are confirmed to be up-to-date.
- All other aspects of the NATS integration (bucket requirement,
  testing via Docker Compose, Makefile targets, CI workflow) remain
  as established in previous refinements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant