nhost / cli

Nhost CLI
https://docs.nhost.io/development/cli/overview
MIT License
77 stars 28 forks source link

feat: added support for nodejs 20 alongside nodejs 18 #889

Closed dbarrosop closed 5 months ago

dbarrosop commented 5 months ago

PR Type

Enhancement, Bug fix


Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
example.go
Add `Autoscaler` field to configurations in example command

cmd/config/example.go
  • Added Autoscaler field with nil value in multiple configurations.
  • +4/-0     
    config_example.go
    Add `Autoscaler` field to configuration in run command     

    cmd/run/config_example.go - Added `Autoscaler` field with `nil` value in configuration.
    +2/-1     
    compose.go
    Update image version format in Docker Compose functions   

    dockercompose/compose.go - Updated image version format to include Node.js version.
    +1/-1     
    main_test.go
    Add `Autoscaler` field to configurations in main test       

    dockercompose/main_test.go
  • Added Autoscaler field with nil value in multiple configurations.
  • +4/-0     
    run_test.go
    Add `Autoscaler` field to configuration in run test           

    dockercompose/run_test.go - Added `Autoscaler` field with `nil` value in configuration.
    +2/-1     
    nhost.toml
    Update Node.js version to 20 in example project                   

    examples/myproject/nhost/nhost.toml - Updated Node.js version from 18 to 20.
    +1/-1     
    Dependencies
    go.mod
    Update Go version and dependencies in go.mod                         

    go.mod
  • Updated Go version from 1.22.3 to 1.22.4.
  • Updated github.com/nhost/be dependency version.
  • +2/-2     
    go.sum
    Update checksums for dependencies in go.sum                           

    go.sum - Added new checksums for updated `github.com/nhost/be` dependency.
    +2/-0     

    ๐Ÿ’ก PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    codiumai-pr-agent-pro[bot] commented 5 months ago

    PR Reviewer Guide ๐Ÿ”

    (Review updated until commit https://github.com/nhost/cli/commit/ebdbb0cf079cfd6ba26d2fda28ac7f09a0ea6fa8)

    โฑ๏ธ Estimated effort to review [1-5] 3
    ๐Ÿงช Relevant tests No
    ๐Ÿ”’ Security concerns No
    โšก Key issues to review Possible Bug:
    The addition of Autoscaler: nil in multiple configurations across various files seems redundant if not accompanied by logic to utilize this field. This could lead to confusion or future bugs if other developers expect this field to be operational.
    Code Consistency:
    The formatting of the Replicas field in cmd/run/config_example.go and dockercompose/run_test.go has been changed inconsistently (adding spaces before the colon). This does not align with the existing code style and could lead to maintainability issues.
    codiumai-pr-agent-pro[bot] commented 5 months ago

    PR Code Suggestions โœจ

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add validation for the Version field to ensure it is a positive integer before formatting it into the image string ___ **To ensure that the Version field is properly formatted as an integer, consider adding a
    check to handle potential errors or invalid values before using it in the fmt.Sprintf
    function.** [dockercompose/compose.go [348]](https://github.com/nhost/cli/pull/889/files#diff-67d473eea1a53a8257f907983067eaabe35308b83d3a28d7f7705e7dfa396c40R348-R348) ```diff -Image: fmt.Sprintf("nhost/functions:%d-1.2.0", *cfg.GetFunctions().GetNode().Version), +version := *cfg.GetFunctions().GetNode().Version +if version <= 0 { + return nil, fmt.Errorf("invalid node version: %d", version) +} +Image: fmt.Sprintf("nhost/functions:%d-1.2.0", version), ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 8 Why: The suggestion correctly identifies a potential issue with unvalidated input being used in a critical string format operation, which could lead to runtime errors.
    8
    Enhancement
    Make the Node.js version configurable via an environment variable ___ **Consider making the Node.js version configurable through an environment variable to allow
    more flexibility in different environments.** [examples/myproject/nhost/nhost.toml [26]](https://github.com/nhost/cli/pull/889/files#diff-ce9635d2304c2ca0ee06fd0e9d02f1b18238aa11c98c49aec9f58821031f1c44R26-R26) ```diff -version = 20 +version = "${NODE_VERSION}" ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 6 Why: The suggestion is valid for enhancing flexibility in deployment environments, though it's not a critical issue.
    6
    Best practice
    Verify that the specified Go version is compatible with all dependencies ___ **Ensure that the Go version specified in the go.mod file is compatible with all
    dependencies and the project's requirements.** [go.mod [3]](https://github.com/nhost/cli/pull/889/files#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6R3-R3) ```diff go 1.22.4 +// Ensure compatibility with all dependencies and project requirements ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 5 Why: The suggestion is a best practice reminder, but it does not directly address any specific issue in the PR code, nor does it make a concrete change.
    5
    codiumai-pr-agent-pro[bot] commented 5 months ago

    CI Failure Feedback ๐Ÿง

    (Checks updated until commit https://github.com/nhost/cli/commit/7f869e4c434ad6858e38c5e19fcee75ba1b48b68)

    **Action:** tests / tests
    **Failed stage:** [Run checks](https://github.com/nhost/cli/actions/runs/9664274098/job/26658523566) [โŒ]
    **Failure summary:** The action failed because the golangci-lint tool detected a missing field Autoscaler in the struct
    model.ConfigRunServiceResources in the file dockercompose/run_test.go at line 62. This caused the
    build process to exit with code 1, leading to the overall failure of the action.
    Relevant error logs: ```yaml 1: ##[group]Operating System 2: Ubuntu ... 1051: gotests> ./dockercompose/compose.go: OK 1052: gotests> ./dockercompose/url.go: OK 1053: gotests> ./dockercompose/ai.go: OK 1054: gotests> ./dockercompose/dockercompose.go: OK 1055: gotests> ./dockercompose/auth_test.go: OK 1056: gotests> ./dockercompose/ingress.go: OK 1057: gotests> ./dockercompose/storage.go: OK 1058: gotests> ./get_access_token.sh: OK 1059: gotests> โžœ Running code formatters, if there are changes, fail ... 1064: gotests> This scan also found 0 vulnerabilities in packages you import and 1 1065: gotests> vulnerability in modules you require, but your code doesn't appear to call these 1066: gotests> vulnerabilities. 1067: gotests> Use '-show verbose' for more details. 1068: gotests> โžœ Running golangci-lint 1069: gotests> dockercompose/run_test.go:62:18: model.ConfigRunServiceResources is missing field Autoscaler (exhaustruct) 1070: gotests> Resources: &model.ConfigRunServiceResources{ 1071: gotests> ^ 1072: error: builder for '/nix/store/6vz2pg592jg15g31mziz82jc6zf73vyl-gotests.drv' failed with exit code 1 1073: make: *** [Makefile:21: check] Error 100 1074: ##[error]Process completed with exit code 2. ```

    โœจ CI feedback usage guide:
    The CI feedback tool (`/checks)` automatically triggers when a PR has a failed check. The tool analyzes the failed checks and provides several feedbacks: - Failed stage - Failed test name - Failure summary - Relevant error logs In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR: ``` /checks "https://github.com/{repo_name}/actions/runs/{run_number}/job/{job_number}" ``` where `{repo_name}` is the name of the repository, `{run_number}` is the run number of the failed check, and `{job_number}` is the job number of the failed check. #### Configuration options - `enable_auto_checks_feedback` - if set to true, the tool will automatically provide feedback when a check is failed. Default is true. - `excluded_checks_list` - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list. - `enable_help_text` - if set to true, the tool will provide a help message with the feedback. Default is true. - `persistent_comment` - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true. - `final_update_message` - if `persistent_comment` is true and updating a previous checks message, the tool will also create a new message: "Persistent checks updated to latest commit". Default is true. See more information about the `checks` tool in the [docs](https://pr-agent-docs.codium.ai/tools/ci_feedback/).