Skip to content

chore: switch under nix/just#43

Merged
gfyrag merged 2 commits into
mainfrom
chore/switch-nix-just
Apr 2, 2025
Merged

chore: switch under nix/just#43
gfyrag merged 2 commits into
mainfrom
chore/switch-nix-just

Conversation

@gfyrag
Copy link
Copy Markdown
Contributor

@gfyrag gfyrag commented Apr 2, 2025

Fixes AUT-1

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 2, 2025

Walkthrough

The pull request introduces several new configuration and build management files and updates an existing test file. A new .envrc file sets up the environment using flake and dotenv. The Earthfile has been simplified by removing testing, linting, pre-commit, and tidy sections, while the Justfile adds several management commands for a Go project. Additionally, a new Nix flake configuration (flake.nix) establishes a multi-architecture development environment and a test file update in pkg/api/clients_test.go enhances error checking after a database operation.

Changes

Files Change Summary
.envrc, Justfile, flake.nix New configuration files added: .envrc sets up flake and dotenv, Justfile defines various Go project commands (generate, tidy, lint, tests, and releases), and flake.nix provides a multi-architecture dev env.
Earthfile Removed sections related to tests, lint, pre-commit, and tidy; modified the openapi section to reposition the artifact saving command.
pkg/api/clients_test.go Added an error check (require.NoError(t, err)) immediately after a database query in the TestUpdateClient function, enhancing test error handling.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Justfile as Task Runner
    participant Generator as go generate
    participant Tidy as go mod tidy
    participant Linter as golangci-lint

    User->>Justfile: Execute pre-commit
    Justfile->>Generator: Run generate
    Generator-->>Justfile: Generation complete
    Justfile->>Tidy: Run tidy
    Tidy-->>Justfile: Tidy complete
    Justfile->>Linter: Run lint
    Linter-->>Justfile: Lint complete
    Justfile-->>User: Pre-commit process finished
Loading

Assessment against linked issues

Objective Addressed Explanation
Switch to nix/just (AUT-1)

Possibly related PRs

Suggested reviewers

  • flemzord

Poem

Hop along, my fellow coder, in fields of code so bright,
With new files and commands, everything feels just right!
Environment set with flake and dotenv in the air,
Tasks and tests now prance smoothly with flair!
I’m a clever bunny, leaping over bugs in flight—
Code and carrots make every day a delight!


📜 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 ba65a64 and 2af6056.

⛔ Files ignored due to path filters (2)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (1)
  • pkg/oidc/oidc_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/oidc/oidc_test.go

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@gfyrag gfyrag force-pushed the chore/switch-nix-just branch 2 times, most recently from 081d831 to 3d7697e Compare April 2, 2025 08:28
Copy link
Copy Markdown

@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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🧹 Nitpick comments (6)
Justfile (6)

9-10: Consider documenting the build tags usage.

The lint command looks good, but it would be helpful to document why the --build-tags it flag is needed. This would help new contributors understand what these tags are used for.

 lint:
+  # Run linter with integration test tags to catch issues in test code as well
   @golangci-lint run --fix --build-tags it --timeout 5m

18-22: Consider adding a comment about the test tags.

Similar to the lint command, it would be helpful to document why the -tags it flag is needed for tests.

 tests:
+  # Run tests with race detection and coverage, including integration tests
   @go test -race -covermode=atomic \
     -coverprofile coverage.txt \
     -tags it \
     ./...

24-25: Document OpenAPI specification source.

This command assumes the existence of an openapi.yaml file. Consider adding a comment about where this file should be located or how it should be generated.

 generate-client:
+  # Generate Go client SDK from the OpenAPI specification
   @speakeasy generate sdk -s openapi.yaml -o ./pkg/client -l go

27-32: Clarify the distinction between release commands.

Having three different release commands (release-local, release-ci, and release) might be confusing for new contributors. Consider adding comments to explain when each should be used.

 release-local:
+  # For local testing of releases without publishing
   @goreleaser release --nightly --skip=publish --clean

 release-ci:
+  # For CI builds to create nightly releases
   @goreleaser release --nightly --clean

33-35: Add a newline at the end of the file.

The file doesn't end with a newline, which is a best practice in Unix/Linux environments and can cause warnings with some tools.

 release:
   @goreleaser release --clean
-
+

1-35: Consider adding tool validation.

The Justfile assumes several tools are available (golangci-lint, go, speakeasy, and goreleaser). Consider adding a command to check if these dependencies are installed.

You could add a command like this:

check-deps:
  @echo "Checking dependencies..."
  @command -v go >/dev/null 2>&1 || echo "go is not installed"
  @command -v golangci-lint >/dev/null 2>&1 || echo "golangci-lint is not installed"
  @command -v speakeasy >/dev/null 2>&1 || echo "speakeasy is not installed"
  @command -v goreleaser >/dev/null 2>&1 || echo "goreleaser is not installed"

And then make other commands depend on it:

pre-commit: check-deps generate tidy lint
🛑 Comments failed to post (1)
flake.nix (1)

15-15: 💡 Verification agent

🧩 Analysis chain

Verify Go version compatibility.

goVersion = 23 seems to reference Go 1.23, which might be a future version. Please verify this is intentional.


🌐 Web query:

What is the latest stable version of Go as of April 2024?

💡 Result:

The latest stable version of Go as of April 2024 was Go 1.22.2, released on April 3, 2024[7]. This release included security fixes for the net/http package and bug fixes across multiple components like the compiler and linker[7].

Key details:

  • Versioning Scheme: Go uses go1.[major].[patch], where even minor numbers (like 22 in go1.22) represent stable releases[1][4].
  • Support Policy: Each major release receives updates until two newer versions exist. Go 1.22.x was supported through February 2025[5][6].
  • Features in 1.22:
    • Loop variable per-iteration initialization to prevent accidental sharing[10]
    • Integer range loops (for i := range 10)[10]
    • New math/rand/v2 package[10]

Earlier patches in the 1.22 series (1.22.0 and 1.22.1) were released in February and March 2024 respectively[7][10]. The 1.23.x series began development in August 2024[5][10].

Citations:


Action Required: Verify or Update Go Version in flake.nix

It appears that the code sets:

      goVersion = 23;

This would imply using Go 1.23, yet as of April 2024 the latest stable release is Go 1.22.2. Please confirm whether you intended to target the upcoming Go 1.23 release (e.g., for testing future features) or if this is an oversight that should be corrected to match the stable version.

Copy link
Copy Markdown

@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: 1

🧹 Nitpick comments (5)
README.md (3)

5-7: Specify language for fenced code block in "Generate client code" section.

The fenced code block starting at line 5 does not specify a language. To comply with markdownlint (MD040) and improve syntax highlighting, consider updating it to include a language identifier (e.g., sh if these are shell commands).

-```
+```sh
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

5-5: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


11-13: Add language identifier for "Tests" fenced code block.

The code block containing the just tests command lacks an explicit language specifier. Adding one (such as sh) can enhance readability and satisfy markdownlint recommendations.

-```
+```sh
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

11-11: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


17-19: Include language tag for "Lint" fenced code block.

Similar to the previous blocks, please specify a language (e.g., sh) for the fenced block that contains the just lint command, to meet markdownlint MD040 guidelines.

-```
+```sh
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

17-17: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

flake.nix (2)

73-73: Remove debugging statement

The ls -al command appears to be a debugging statement that should be removed before merging to production.

- ls -al

87-101: Consider documenting proprietary software usage

The development shell includes goreleaser-pro from NUR, which is likely proprietary software (explaining the allowUnfree = true setting). Consider adding a comment about this to inform users why allowUnfree is needed.

 devShells = forEachSupportedSystem ({ pkgs, system }:
   {
     default = pkgs.mkShell {
+      # Note: allowUnfree is enabled for goreleaser-pro
       packages = with pkgs; [
         go
         gotools
         golangci-lint
         ginkgo
         pkgs.nur.repos.goreleaser.goreleaser-pro
         self.packages.${system}.speakeasy
         just
       ];
     };
   }
 );
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 081d831 and 3d7697e.

⛔ Files ignored due to path filters (3)
  • .github/workflows/main.yml is excluded by !**/*.yml
  • .github/workflows/releases.yml is excluded by !**/*.yml
  • flake.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (6)
  • .envrc (1 hunks)
  • Earthfile (1 hunks)
  • Justfile (1 hunks)
  • README.md (1 hunks)
  • flake.nix (1 hunks)
  • pkg/api/clients_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • pkg/api/clients_test.go
  • .envrc
  • Earthfile
  • Justfile
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md

11-11: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


17-17: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

🔇 Additional comments (2)
flake.nix (2)

58-78: LGTM on Speakeasy package derivation

The Speakeasy package derivation is well-structured with proper version handling, platform-specific configurations, and hash verification for security.


1-103: Overall well-structured flake configuration

The flake configuration is well-organized with clear separation of inputs, outputs, package definitions, and development shell configuration. It properly handles multi-architecture support and includes all necessary development tools for the project.

Comment thread flake.nix

outputs = { self, nixpkgs, nur }:
let
goVersion = 23;
Copy link
Copy Markdown

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 Go version 23

The Go version is set to 23, which seems unusually high. As of April 2024, the latest stable version of Go was 1.22.x. Please verify if this is intentional or if it should be a lower number.


🌐 Web query:

What is the latest stable version of Go as of April 2024?

💡 Result:

The latest stable version of Go as of April 2024 was Go 1.22, specifically 1.22.2 released on April 3, 2024[7][9]. This release included security fixes for the net/http package and various bug fixes across compiler components, the linker, and standard libraries like encoding/gob[7].

Key points about the release timeline:

  • Go 1.22.0 initially launched on February 6, 2024, introducing features like range-over-function integers and workspace vendoring support[9].
  • The language maintained backward compatibility through minor updates like 1.22.1 (March 5, 2024) and 1.22.2 (April 3, 2024), addressing security vulnerabilities and runtime issues[7].

By April 2024, Go 1.23 and 1.24 had not yet been released (they arrived in August 2024 and February 2025 respectively)[5][7]. The standard support policy ensured Go 1.22 remained actively maintained until two subsequent major versions were released[5][6].

Citations:


Attention: Incorrect Go Version Detected

The flake.nix file sets goVersion = 23;, which appears inconsistent with the latest stable Go release. As of April 2024, the stable version was Go 1.22 (specifically 1.22.2). Please verify whether the version "23" is intentional (for example, if it signifies a custom internal versioning system) or if it should be updated to reflect the latest stable Go version.

  • File: flake.nix
  • Line: 15

@gfyrag gfyrag force-pushed the chore/switch-nix-just branch from 3d7697e to b19e9db Compare April 2, 2025 08:37
Copy link
Copy Markdown

@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

🧹 Nitpick comments (1)
README.md (1)

17-19: LGTM: Command updated to use 'just' and missing language specifier

This change aligns with the PR objective, but the code blocks should have a language specified.

-```
-just lint
-```
+```bash
+just lint
+```

Also, apply the same language specifier to the other code blocks:

-```
-just generate-client
-```
+```bash
+just generate-client
+```
-```
-just tests
-```
+```bash
+just tests
+```
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

17-17: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3d7697e and b19e9db.

⛔ Files ignored due to path filters (3)
  • .github/workflows/main.yml is excluded by !**/*.yml
  • .github/workflows/releases.yml is excluded by !**/*.yml
  • flake.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (6)
  • .envrc (1 hunks)
  • Earthfile (1 hunks)
  • Justfile (1 hunks)
  • README.md (1 hunks)
  • flake.nix (1 hunks)
  • pkg/api/clients_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • pkg/api/clients_test.go
  • .envrc
  • Justfile
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
README.md

11-11: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


17-17: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

🔇 Additional comments (5)
README.md (2)

5-7: LGTM: Command updated to use 'just'

This change aligns with the PR objective of switching to using 'just' for task management.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

5-5: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


11-13: LGTM: Command updated to use 'just'

This change aligns with the PR objective of switching to using 'just' for task management.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

11-11: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

Earthfile (1)

39-44: LGTM: Simplified openapi section

The openapi section has been simplified to only save the artifact, which aligns with the PR objective of moving functionality to just/nix. I assume the functionality previously provided by the removed sections (tests, lint, pre-commit, and tidy) has been migrated to the Justfile.

flake.nix (2)

15-15: Verify the Go version setting

The Go version is set to 23, which seems unusually high. As of April 2024, the latest stable version of Go was 1.22.x. Please verify if this is intentional or if it should be a lower number.


1-103: Overall LGTM: Good development environment setup

This Nix flake configuration provides a comprehensive multi-architecture development environment with all the necessary tools for the project. The inclusion of the just package in the development shell aligns with the PR objective of switching to nix/just for command running.

@gfyrag gfyrag force-pushed the chore/switch-nix-just branch from 41ed0a6 to ba65a64 Compare April 2, 2025 13:19
@gfyrag gfyrag force-pushed the chore/switch-nix-just branch from ba65a64 to 2af6056 Compare April 2, 2025 13:21
@gfyrag gfyrag merged commit d59fd31 into main Apr 2, 2025
7 checks passed
@gfyrag gfyrag deleted the chore/switch-nix-just branch April 2, 2025 14:33
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.

2 participants