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

Adds Create Camel project to the welcome screen #1994

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

hdamarcelo
Copy link
Contributor

Adds Create Camel projecy to the welcome screen

  • Rename NewCamelProjectCommand class to reflect its abstract nature.
  • Create a 'generic' NewCamelProjectCommand that asks the user to select a runtime. Register the command with 'enablement = false' so that its does not show in the command palette.
  • Refactor other classes with the new project structure.

welcome

@hdamarcelo hdamarcelo self-assigned this Oct 31, 2024
package.json Outdated Show resolved Hide resolved
src/commands/NewCamelQuarkusProjectCommand.ts Show resolved Hide resolved
src/ui-test/tests/commands.projects.test.ts Outdated Show resolved Hide resolved
Changelog.md Outdated Show resolved Hide resolved
Copy link
Member

@apupier apupier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests are failing on Windows

@hdamarcelo hdamarcelo changed the title Adds Create Camel projecy to the welcome screen Adds Create Camel project to the welcome screen Nov 25, 2024
@hdamarcelo
Copy link
Contributor Author

hdamarcelo commented Nov 25, 2024

tests are failing on Windows

After some testing using a VM I was able to reproduce the error we can see in the test pipeline but unfortunately not solve it (the error is the same in PR1952)

Tests I made while trying to reproduce the error:

  1. Execute npm run ui-test inside vscode integrated terminal: The issue is that after the command execution (after the task that runs jbang camel export completes) no pom.xml file is created and because of that the test assertion fails. During the test execution I can see the following error in the terminal among other warning messages (they do not appear on linux)

ERR: [File Watcher (node.js)] Failed to watch c:<path-to-project>\camel-lsp-client-vscode\src\ui-test\resources\create-camel-project-workspace.vscode for changes using fs.watch() (Error: EPERM: operation not permitted, watch, undefined)", source: vscode-file://vscode-app/c://AppData/Local/Temp/test-resources/VSCode-win32-x64-archive/resources/app/out/vs/workbench/workbench.desktop.main.js (35)

  1. Execute npm run ui-test outside vscode: Same result as 1
  2. Execute npm run ui-test in windows bash: Same result as 1
  3. Execute npm run ui-test in windows powershell: Same result as 1
  4. Execute npm run ui-test changing camel.jbang.version to 4.8.0: Same result as 1
  5. Running the command "Create a Camel Project" after running the extension (hitting F5): jbang camel export fails due to a simultaneous lock in a NTUSER.DAT file inside .camel-jabng folder (file is deleted after command execution)
  6. Running the command "Create a Camel Project" after running the extension (hitting F5) as administrator: Same result as 6
  7. Running the command "Create a Camel Project" after installing the built vsix (without running the project in another vscode instance): pom.xml file is created as expected
  8. Running jbang camel export from the terminal works as exepected.
  9. Running jbang camel export with different output folders works as expected.

While adding pauses in each step of the ui-test execution it seems to me that the camel jbang process ends early and does not create the pom.xml file during the test suite execution.

I also tried executing camel jbang via a child process intead of using vscode's ShellExecution method but that also did not work.

@djelinek
Copy link
Member

@hdamarcelo at the moment I've found 2 separate problems from VS Code point of view

  1. existing opened workspace
  2. no workspace

for the 1. - it seems to be bug in upstream affecting mainly WINDOWS

  • I was able to reproduce on WIndows machine that if you are executing command at PATH (cwd) and specifying the output directory for export command which targeting same dir --directory='PATH' --> the output is not correct. It can be fixed by detecting CWD == PATH and than use --directory='.' OR in that case skip usage of --directory parameter and just specify correct CWD for VS Code Task execution. Note: The CWD for VS Code Tasks execution is always current workspace dir that is why it was failing in UI tests

INVALID EXPORT:
PS C:\mnt\testME> camel export --runtime=quarkus --gav=com.demo:test:1.0-SNAPSHOT --directory='C:\mnt\testME'

VALID EXPORT
PS C:\mnt\testME> camel export --runtime=quarkus --gav=com.demo:test:1.0-SNAPSHOT --directory='.'

also VALID
PS C:\mnt\testME> camel export --runtime=quarkus --gav=com.demo:test:1.0-SNAPSHOT --directory='C:\mnt\testME\test'


for the 2. - again affecting mainly WINDOWS (or more precisely there it causes errors but the behavior is probably same everywhere..)

  • when there is no workspace dir opened in VS Code, than it means for VS Code Tasks execution it is using as CWD the users HOME DIR and trying to copy all files during export (on windows it causes errors because files which cannot be copied - NTUSER.DAT) --> solution could be to specify the CWD same as target folder for export command when creating a new camel project without opened workspace

Hopefully it is understandable.. I know it is a bit confusing but it is kinda tricky tbh.. feel free to reach out to me in case of need and I can demo it to you 🙂

cc @apupier

@hdamarcelo hdamarcelo force-pushed the add-to-welcome-page branch 5 times, most recently from c4ac9a5 to b2341e3 Compare November 30, 2024 01:56
@hdamarcelo hdamarcelo marked this pull request as ready for review December 2, 2024 04:21
Copy link
Member

@apupier apupier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

side-tracked and wasn't able to test it locally yet but would like to provide the initial feedback

Changelog.md Outdated Show resolved Hide resolved
src/ui-test/tests/commands.projects.test.ts Outdated Show resolved Hide resolved
}
}

abstract getRuntime(): Promise<string|undefined>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to decalre it as async to have a better typing and ensure that await is called.
For instance, in camel.project.command.test.ts it is not. It is causing the title of the test to be incorrect Should validate Create a Camel Project command GAV validation of [object Promise], see https://github.com/camel-tooling/camel-lsp-client-vscode/actions/runs/12173733325/job/33963279530?pr=1994#step:13:123

- Rename NewCamelProjectCommand class to reflect its abstract nature.
- Create a 'generic' NewCamelProjectCommand that asks the user to select
  a runtime. Register the command with 'enablement = false' so that its
  does not show in the command palette.
- Refactor other classes with the new project structure.

Signed-off-by: Marcelo Henrique Diniz de Araujo <[email protected]>
Copy link

sonarcloud bot commented Dec 6, 2024

@hdamarcelo hdamarcelo merged commit fee6fef into camel-tooling:main Dec 9, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants