Cammisuli / monodon

39 stars 17 forks source link

Can't release version of rust binary with independent release group #62

Open nesimer opened 1 month ago

nesimer commented 1 month ago

Hi @Cammisuli,

I've recently been using my rust binaries in a monorepo NX context via monodon. My current project contains โ€œclassicโ€ JS/TS applications with associated โ€œe2eโ€ apps.

Since each of my apps is independent of the others, releases are made with this configuration:

๐Ÿ“‚ nx.json

{
// ... rest of configuration
"release": {
    "projects": ["!*-e2e"],
    "projectsRelationship": "independent"
  },
}

But as soon as I want to make an nx release --project=[my_rust_bin] patch, I get this console output:

console output after nx release --verbose --project=[my_rust_bin] patch

npx nx release --verbose --projects=myapp patch

 NX   Your filter "myapp" matched the following projects:

- myapp

 NX   Running release version for project: myapp

myapp ๐Ÿ” Reading data for crate "acme_myapp" from apps/myapp/Cargo.toml
myapp ๐Ÿ“„ Resolved the current version as 0.1.0 from apps/myapp/Cargo.toml
myapp ๐Ÿ“„ Using the provided version specifier "patch".
Error: ENOENT: no such file or directory, open '/home/nremise/projects/test-nx/acme/apps/my-new-app-e2e/Cargo.toml'
    at Object.openSync (node:fs:573:18)
    at readFileSync (node:fs:452:35)
    at FsTree.fsReadFile (/home/nremise/projects/test-nx/acme/node_modules/nx/src/generators/tree.js:242:43)
    at FsTree.read (/home/nremise/projects/test-nx/acme/node_modules/nx/src/generators/tree.js:33:32)
    at parseCargoTomlWithTree (/home/nremise/projects/test-nx/acme/node_modules/@monodon/rust/src/utils/toml.js:12:34)
    at resolveLocalPackageDependencies (/home/nremise/projects/test-nx/acme/node_modules/@monodon/rust/src/generators/release-version/release-version.js:405:65)
    at releaseVersionGenerator (/home/nremise/projects/test-nx/acme/node_modules/@monodon/rust/src/generators/release-version/release-version.js:203:46)
    at runVersionOnProjects (/home/nremise/projects/test-nx/acme/node_modules/nx/src/command-line/release/version.js:339:34)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async releaseVersion (/home/nremise/projects/test-nx/acme/node_modules/nx/src/command-line/release/version.js:130:47)
Cannot find a Cargo.toml file in the my-new-app-e2e

 NX   

Error
    at parseCargoTomlWithTree (/home/nremise/projects/test-nx/acme/node_modules/@monodon/rust/src/utils/toml.js:15:15)
    at resolveLocalPackageDependencies (/home/nremise/projects/test-nx/acme/node_modules/@monodon/rust/src/generators/release-version/release-version.js:405:65)
    at releaseVersionGenerator (/home/nremise/projects/test-nx/acme/node_modules/@monodon/rust/src/generators/release-version/release-version.js:203:46)
    at runVersionOnProjects (/home/nremise/projects/test-nx/acme/node_modules/nx/src/command-line/release/version.js:339:34)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async releaseVersion (/home/nremise/projects/test-nx/acme/node_modules/nx/src/command-line/release/version.js:130:47)
    at async release (/home/nremise/projects/test-nx/acme/node_modules/nx/src/command-line/release/release.js:75:31)
    at async handleErrors (/home/nremise/projects/test-nx/acme/node_modules/nx/src/utils/handle-errors.js:9:24)
    at async Object.handler (/home/nremise/projects/test-nx/acme/node_modules/nx/src/command-line/release/command-object.js:98:24)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

After a little research, it seems to me that it would come from here:

๐Ÿ“‚ packages/rust/src/generators/release-version/release-version.js (line 203)

//... rest of file
const localPackageDependencies = resolveLocalPackageDependencies(tree, options.projectGraph, projects, projectNameToPackageRootMap, resolvePackageRoot, 
// includeAll when the release group is independent, as we may be filtering to a specific subset of projects, but we still want to update their dependents
options.releaseGroup.projectsRelationship === 'independent');

When I set false instead of options.releaseGroup.projectsRelationship === 'independent', my release goes โ€œfineโ€.

This โ€œhackโ€ is temporary and not complete, but shouldn't we dig deeper and allow the proper use of the release command in a case like mine (with โ€œindependentโ€) because it is relatively blocking?

Thanks

lewsmith commented 1 month ago

Same issue, the change mentioned above does allow everything to work as it should.

nesimer commented 1 month ago

@Cammisuli do you have an opinion about this? โ˜บ๏ธ

Cammisuli commented 1 month ago

Hmm.. I'd have to go over the code and see whats up. From what was described, it makes sense, but I just want to make sure its safe.

nesimer commented 3 weeks ago

@Cammisuli, have you had a chance to think about it ๐Ÿ™‚ ?

I can also take a closer look for myself and see about a safe fixif you don't have time ๐Ÿ™‚

Cammisuli commented 1 week ago

If we can confirm that these instructions are still good, then I say its fine: https://nx.dev/recipes/nx-release/publish-rust-crates