Cammisuli / monodon

38 stars 17 forks source link

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

Open nesimer opened 1 week ago

nesimer commented 1 week 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 2 days ago

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

nesimer commented 14 hours ago

@Cammisuli do you have an opinion about this? ☺️