Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Your feedback on beta of nx-go 3 #107

Closed
utarwyn opened this issue Feb 21, 2024 · 25 comments
Closed

Your feedback on beta of nx-go 3 #107

utarwyn opened this issue Feb 21, 2024 · 25 comments

Comments

@utarwyn
Copy link
Member

utarwyn commented Feb 21, 2024

🚀 nx-go v3 enters beta phase

Would you like to help us prepare for this major step in the project? Need to test integration with Nx 17/18 right now? Or simply tell us about your experience using the plugin? You've come to the right place!

Please comment here or create a new ticket with the various problems encountered, mainly on the following items:

  • New generators (init, preset, convert-to-go-mod)
  • Project graph performance
  • Migration V2 -> V3

Things to change already reported :

If needed, you can use the updated playground located in https://github.com/nx-go/nx-go-playground

Note

This version aims to offer similar features to v2. We will process all tickets proposing additions in versions 3.x.


This issue is a follow-up to the work carried out in #103. I plan to release a stable version during Q1 2024.
We'd like to thank you in advance for all your feedback, which will help make the plugin more stable.

@markhughes
Copy link

Will you be releasing @nx-go/nx-go@beta? happy to help test this one!

@necmettindev
Copy link

Everything looks great, well done!

@utarwyn
Copy link
Member Author

utarwyn commented Feb 22, 2024

Sorry for the misunderstanding, I prepared this post in anticipation of releasing the beta. It is available now!
But thanks for the early feedback 🤝

@phillipCouto
Copy link
Contributor

Will definitely give it a shot on some of our projects to see if there are any compatibility issues!

Thanks for all the effort!

@kaje94
Copy link

kaje94 commented Feb 24, 2024

Tested 3.0.0-beta.0 with nx:18.0.4 and everything seems to work as expected.

Thanks @utarwyn!

@phillipCouto
Copy link
Contributor

@utarwyn with the change to the linter args type from a string to string[] should there be a migration to update the existing configurations to split the original argument by space?

In my projects we have a value like "-config ./revive.toml" which will now need to be converted to ["-config", "./revive.toml"]. Its not a big deal but I wanted to raise it in case it is something you want to smooth out for other users.

@utarwyn
Copy link
Member Author

utarwyn commented Feb 24, 2024

@utarwyn with the change to the linter args type from a string to string[] should there be a migration to update the existing configurations to split the original argument by space?

Yes, that's a great idea! I hadn't thought about this migration, so I'll add it to the to-do list.

@abbudao
Copy link

abbudao commented Feb 26, 2024

Aside from the abovementioned schema change to string[], I have had no issue upgrading so far! Great job!
I'm looking forward to the actual release!

@rodentskie
Copy link

Hi @utarwyn , still learning go and I use this package for my personal project. Thanks for the hardwork.
Just a question, the previous version do have a single go.mod file in the root of the project and dependencies are listed in that file. Now, each project have each go.mod file. Where should I run the go get command? In the root dir or inside the project?

@utarwyn
Copy link
Member Author

utarwyn commented Mar 13, 2024

Hi @utarwyn , still learning go and I use this package for my personal project. Thanks for the hardwork. Just a question, the previous version do have a single go.mod file in the root of the project and dependencies are listed in that file. Now, each project have each go.mod file. Where should I run the go get command? In the root dir or inside the project?

Hello @rodentskie, thanks for the kind words!

Version 3 of nx-go uses a multi-module Go workspace by default. This explains why each project has its own go.mod file. Currently, as explained in the Go documentation, the go get command must be executed for each module (so, in each project).

It might be interesting to have an executor in nx-go to run this command in all projects at once 👍

Note: you can revert to the old approach by deleting the go.work file and keeping a single go.mod file at the root of your project

@llucasshenrique
Copy link

No issues until now! Just need more executors, for tidy and get.
I'm adding some custom executors to each project.json file, so I can run nx commands to tidy and get the go modules.
Even though it is not a big deal, it would be nice to have it on the plugin.
The 'get' i'm not using that much as the vscode plugin auto imports the packages, but the tidy is a must have.

usage:
nx affected -t tidy
nx get myapp needed/package
nx myapp:get needed/package

{
  // ...
  "targets": {
    // ...
    "tidy": {
      "executor": "nx:run-commands",
      "options": {
        "cwd": "{projectRoot}",
        "command": "go mod tidy"
      }
    },
    "get": {
      "executor": "nx:run-commands",
      "options": {
        "cwd": "{projectRoot}",
        "command": "go get"
      }
    }
  }
}

@utarwyn
Copy link
Member Author

utarwyn commented Mar 13, 2024

@llucasshenrique
No issues until now! Just need more executors, for tidy and get.

Thank you for the feedback! Much appreciated 👍
I fully agree with you about adding these executors. We'll be able to do this in version 3.1, can you create a ticket about it?

@rodentskie
Copy link

Hi @utarwyn , still learning go and I use this package for my personal project. Thanks for the hardwork. Just a question, the previous version do have a single go.mod file in the root of the project and dependencies are listed in that file. Now, each project have each go.mod file. Where should I run the go get command? In the root dir or inside the project?

Hello @rodentskie, thanks for the kind words!

Version 3 of nx-go uses a multi-module Go workspace by default. This explains why each project has its own go.mod file. Currently, as explained in the Go documentation, the go get command must be executed for each module (so, in each project).

It might be interesting to have an executor in nx-go to run this command in all projects at once 👍

Note: you can revert to the old approach by deleting the go.work file and keeping a single go.mod file at the root of your project

Thanks for the reply. Also, what I did was I created a custom executor exactly what @llucasshenrique did too. Hoping for it to be added in the next release.

@rodentskie
Copy link

"install": {
    "executor": "nx:run-commands",
    "options": {
      "cwd": "{projectRoot}",
      "command": "go get {args.package}"
    }
  },

Sample usage:

nx install api --package=github.com/pulumi/pulumi-aws-apigateway/sdk

Added this one too.

@rodentskie

This comment was marked as off-topic.

@eliellis
Copy link

eliellis commented Mar 16, 2024

Definitely interested in something like #94 for nx-go 3.x. My use case would be goreleaser for multi-platform builds. While generators for goreleaser config would be nice too, I understand that this sort of thing might be outside the scope of the project, so I'll just leave it at a mention. I feel like simply supporting an arbitrary cmd input to the build executor would be enough for the core project and folks could just add their own generators within their personal workspaces to take care of the configuration plumbing required.

@rodentskie
Copy link

rodentskie commented Mar 19, 2024

Hi @utarwyn , just an update my usage of the project.

"tidy": {
  "executor": "nx:run-commands",
  "options": {
    "cwd": "{projectRoot}",
    "command": "go mod tidy"
  }
},
"download": {
  "executor": "nx:run-commands",
  "options": {
    "cwd": "{projectRoot}",
    "command": "go mod download"
  }
},
"install": {
  "executor": "nx:run-commands",
  "options": {
    "cwd": "{projectRoot}",
    "command": "go get {args.package}"
  }
},

These are the three custom rule I made in all of my apps and libraries.

The reason I added download rule is because the setup for go in github action has a built-in caching but somehow with multiple jobs in the workflow caching isn't working.

Combined nx affected, I only download packages on the affected projects and cache the path ~/go/pkg/mod and to be restored in proceeding jobs.

Edit

After some debug, I have a working caching for the go setup.

@utarwyn
Copy link
Member Author

utarwyn commented Mar 19, 2024

@rodentskie
Hi utarwyn , just an update my usage of the project.

Thank you for the follow-up! These executors can be integrated into future versions of nx-go, of course 👍

@utarwyn
Copy link
Member Author

utarwyn commented Mar 19, 2024

Hello! I have just published v3.0.0-beta.1 with following improvements:

If you want to try it out, use this command:

nx migrate @nx-go/nx-go@beta

If all goes well, I propose to release the stable version by the end of the month! 🚀

@rodentskie

This comment was marked as off-topic.

@phillipCouto
Copy link
Contributor

Hi team, it is my first time to implement CICD workflow with go (always with node). The go test really takes a lot of time, even though it only run ~7 seconds in my local machine.

I've tried the following:

* npm run test

* Use of my `affected` script

* Running `go test ./...` inside the project working directory.

Everything I've tried has almost the same time of test. Is it because of the monorepo setup? I've watched in the youtube videos, their tests run and exits right away.

Here is the actual CI of my project.

Edit

Additonal info, my tests are just dummy and no go routine implemented thoughout my project.

Sample

package handlers

import "testing"

func TestIndexRequestHandler(t *testing.T) {
	t.Logf("Running minimal example test")
	if false {
		t.Errorf("This should not fail")
	}
}

This seems more appropriate for a discussion board than as a comment on this issue. Maybe @utarwyn it would be a good idea to setup the commuity feature on the repo or a discussion forum for these types of usage questions.

@utarwyn
Copy link
Member Author

utarwyn commented Mar 20, 2024

Hello, thank you for the suggestion! I've just opened the discussions forum of the repository.

Please use it to ask more general questions about Golang or your personal installation 👍
And you can still create a ticket for a plugin related issue. I propose to talk only about the beta here

@pitakill
Copy link

pitakill commented Mar 21, 2024

Hi @utarwyn thank you for your time and effort with this project.

I'm new to nx and the last week has been a eye opener time with the project, and as I'm also a Go developer I came to this project.

I'm running the 3.0.0-beta.1 version and if I try to pass env vars to the build target I got the error:

** NX   Cannot convert undefined or null to object


TypeError: Cannot convert undefined or null to object
   at Function.keys (<anonymous>)
   at /Users/leopoldocaballero/Projects/yaydoo/node_modules/nx/src/utils/params.js:194:24
   at Array.find (<anonymous>)
   at validateObject (/Users/leopoldocaballero/Projects/yaydoo/node_modules/nx/src/utils/params.js:193:27)
   at validateProperty (/Users/leopoldocaballero/Projects/yaydoo/node_modules/nx/src/utils/params.js:346:9)
   at /Users/leopoldocaballero/Projects/yaydoo/node_modules/nx/src/utils/params.js:210:9
   at Array.forEach (<anonymous>)
   at validateObject (/Users/leopoldocaballero/Projects/yaydoo/node_modules/nx/src/utils/params.js:209:23)
   at validateOptsAgainstSchema (/Users/leopoldocaballero/Projects/yaydoo/node_modules/nx/src/utils/params.js:144:5)
   at combineOptionsForExecutor (/Users/leopoldocaballero/Projects/yaydoo/node_modules/nx/src/utils/params.js:432:5)**

I'm working with the [email protected]

Edit

Digging a little bit I think the problem occurs here: https://github.com/nx-go/nx-go/blob/main/packages/nx-go/src/utils/execute-command.ts#L34

because if I run this in a process in node I get:

Welcome to Node.js v20.11.1.
Type ".help" for more information.
> Object.assign(undefined, {'test': 'value'})
Uncaught TypeError: Cannot convert undefined or null to object

@utarwyn
Copy link
Member Author

utarwyn commented Mar 23, 2024

Hello @pitakill, thank you for the feedback about the beta!
I can reproduce it too. In the error stack you share with us, there's no mention of the nx-go code: it's actually an Nx bug that concerns "object" type executor properties, which is the case of the "env" property of the build executor in nx-go.

You can follow the issue here: nrwl/nx#22349
This should be fixed in nx 18.2.0!

@utarwyn
Copy link
Member Author

utarwyn commented Apr 3, 2024

Hello! I'm excited to announce that the stable version is now out! Check the complete changelog here.

If you have any problems, please create new issues. Many thanks for your feedback!
I'm now going to start integrating new features for v3.1. Moving forward together 🤝

@utarwyn utarwyn closed this as completed Apr 3, 2024
@utarwyn utarwyn unpinned this issue Apr 3, 2024
@nx-go nx-go locked as resolved and limited conversation to collaborators Apr 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants