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

feat(worker): support workers to run natively on windows [WIP] #4446

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

alpetric
Copy link
Contributor

@alpetric alpetric commented Sep 25, 2024

The goal was to be able to build and run workers on windows without the need of docker or WSL.

As a first step the worker should support:

  • python
  • powershell
  • typescript (bun)

Trying to keep code changes to a minimum but includes some minor automatic rustfmt

Notes:


Important

Add Windows support for workers by updating executors and environment configurations for compatibility.

  • Windows Support:
    • Add Windows-specific configurations in ansible_executor.rs, bash_executor.rs, bun_executor.rs, go_executor.rs, python_executor.rs, and rust_executor.rs.
    • Use cfg(windows) to conditionally compile Windows-specific code.
    • Set SystemRoot and other environment variables for Windows in executors.
  • Executors:
    • Modify handle_powershell_job() in bash_executor.rs to support Windows paths and environment.
    • Update handle_bun_job() in bun_executor.rs to handle Windows-specific paths and environment variables.
    • Adjust handle_python_job() in python_executor.rs for Windows compatibility.
    • Update handle_rust_job() in rust_executor.rs to set Windows-specific environment variables.
  • Miscellaneous:
    • Minor formatting changes and cleanup in various files.
    • Add SYSTEM_ROOT constant for Windows in worker.rs.
    • Introduce build_windows_worker.yml GitHub Actions workflow for building Windows workers.

This description was created by Ellipsis for 2f80ba1. It will automatically update as commits are pushed.

Copy link

cloudflare-workers-and-pages bot commented Sep 25, 2024

Deploying windmill with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2f80ba1
Status: ✅  Deploy successful!
Preview URL: https://0a4ad7a6.windmill.pages.dev
Branch Preview URL: https://alp-build-windows.windmill.pages.dev

View logs

@alpetric alpetric marked this pull request as ready for review September 26, 2024 16:18
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to e81555a in 1 minute and 0 seconds

More details
  • Looked at 1134 lines of code in 13 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. backend/windmill-worker/src/rust_executor.rs:325
  • Draft comment:
    On Windows, std::os::windows::fs::symlink_dir is used for creating symlinks, but this is intended for directories. If bin_path is a file, consider using std::os::windows::fs::symlink_file instead.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_In6YX0ACdBVkNh5t


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

backend/windmill-worker/src/go_executor.rs Outdated Show resolved Hide resolved
.stdout(Stdio::piped())
.stderr(Stdio::piped());

build_rust_cmd.args(vec!["build", "--release"]);
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like it could be kept above but not important

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on fb81321 in 49 seconds

More details
  • Looked at 326 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. backend/windmill-worker/src/go_executor.rs:231
  • Draft comment:
    On Windows, use std::os::windows::fs::symlink_file instead of symlink_dir for file symlinks.
        let symlink = std::os::windows::fs::symlink_file(&bin_path, &target);
  • Reason this comment was not posted:
    Marked as duplicate.
2. backend/windmill-worker/src/rust_executor.rs:322
  • Draft comment:
    On Windows, use std::os::windows::fs::symlink_file instead of symlink_dir for file symlinks.
        let symlink = std::os::windows::fs::symlink_file(&bin_path, &target);
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_fG6vWInrj6hnlau8


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

#[cfg(windows)]
{
target = format!("{job_dir}\\main.js");
symlink = std::os::windows::fs::symlink_dir(&local_path, &target);
Copy link
Contributor

Choose a reason for hiding this comment

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

On Windows, use std::os::windows::fs::symlink_file instead of symlink_dir for file symlinks.

Suggested change
symlink = std::os::windows::fs::symlink_dir(&local_path, &target);
symlink = std::os::windows::fs::symlink_file(&local_path, &target);

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on ceb221a in 39 seconds

More details
  • Looked at 54 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. .github/workflows/build_windows_worker.yml:1
  • Draft comment:
    Consider renaming the workflow to something more descriptive, like 'Build Windows Worker', to better reflect its purpose.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The workflow is named 'Backend only integration tests', but it seems to be focused on building for Windows. The name should reflect its purpose more accurately.
2. .github/workflows/build_windows_worker.yml:18
  • Draft comment:
    Verify if 'ubicloud-standard-8' is the intended runner. If not, consider using a standard GitHub runner like 'windows-latest'.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The 'runs-on' key specifies 'ubicloud-standard-8', which is not a standard GitHub runner. This might be a custom runner, but it's worth verifying if this is intentional.
3. .github/workflows/build_windows_worker.yml:44
  • Draft comment:
    Verify if 'mkdir frontend/build' is necessary for the backend build process. If not, consider removing it.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The 'cargo build windows' step uses 'mkdir frontend/build', but this seems unrelated to the backend build process. Verify if this is necessary.

Workflow ID: wflow_JsucE3BSawNqEpzR


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

types: [opened, synchronize, reopened]
paths:
- "backend/**"
- ".github/workflows/backend-test.yml"
Copy link
Contributor

Choose a reason for hiding this comment

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

The path should be '.github/workflows/build_windows_worker.yml' to match the file name.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on b6f8d46 in 26 seconds

More details
  • Looked at 18 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. .github/workflows/build_windows_worker.yml:44
  • Draft comment:
    The workflow uses a Linux-based container image (ghcr.io/windmill-labs/backend-tests). Consider using a Windows-based image for building Windows workers.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_53WrywaplBKfzOBz


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on 3b02fbb in 30 seconds

More details
  • Looked at 14 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_XzhGeFehRGtTL66W


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

timeout-minutes: 15
run:
mkdir frontend/build && cd backend && touch
windmill-api/openapi-deref.yaml && apt-get install gcc-mingw-w64 && rustup target add x86_64-pc-windows-gnu &&
Copy link
Contributor

Choose a reason for hiding this comment

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

The use of apt-get install is incorrect here for a Windows build. Consider using a Windows-compatible package manager like choco or ensure the environment is set up correctly for Windows builds.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on b3dad9e in 38 seconds

More details
  • Looked at 22 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_8Bv0W8yypIAb6tcK


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

- ".github/workflows/backend-test.yml"

jobs:
cargo_build_windos:
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a typo in the job name cargo_build_windos. It should be cargo_build_windows.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 9b84cb9 in 26 seconds

More details
  • Looked at 22 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. .github/workflows/build_windows_worker.yml:17
  • Draft comment:
    The job name contains a typo. It should be cargo_build_windows instead of cargo_build_windos.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment points out a typo that has already been corrected in the diff. Since the change has been made, the comment is no longer necessary. The comment is about a change that has already been resolved.
    I might be missing the context of whether the comment was made before or after the change. However, the diff clearly shows the correction, indicating the comment is outdated.
    The diff provides clear evidence that the typo has been corrected, so the comment is no longer relevant.
    The comment should be deleted because the typo it points out has already been corrected in the diff.

Workflow ID: wflow_K6Izc4zjA008dJBu


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 11e8ca7 in 24 seconds

More details
  • Looked at 12 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. .github/workflows/build_windows_worker.yml:45
  • Draft comment:
    Using apt-get install in a Windows build workflow might not be appropriate. Consider using a Windows-compatible package manager or ensure the container supports this command.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_SqQQLrEsLgSeImXE


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 5102e0a in 20 seconds

More details
  • Looked at 45 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. backend/windmill-worker/src/bash_executor.rs:456
  • Draft comment:
    The default value for TMP should be a Windows-style path, such as C:\Temp, instead of /tmp. This issue is also present in handle_bash_job.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_Z4GvrsKCA9OIlYpW


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 01d7c27 in 19 seconds

More details
  • Looked at 57 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. .github/workflows/build_windows_worker.yml:26
  • Draft comment:
    The container key is not supported on Windows runners in GitHub Actions. Consider removing it or using a different approach for Windows builds.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_SnUEFK4EKp3NlnFK


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on e49ba39 in 17 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. .github/workflows/build_windows_worker.yml:23
  • Draft comment:
    The removal of the container section is appropriate for running natively on Windows.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The removal of the container section is correct since the goal is to run natively on Windows without Docker.

Workflow ID: wflow_6b4xvv0OaOmX04fO


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on d5f3e75 in 19 seconds

More details
  • Looked at 21 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. .github/workflows/build_windows_worker.yml:23
  • Draft comment:
    The DATABASE_URL environment variable references a PostgreSQL service that has been removed from the workflow. Ensure this variable is necessary for the build process or update it accordingly.
  • Reason this comment was not posted:
    Comment did not seem useful.

Workflow ID: wflow_3LcQCQjOMoAL6U3j


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on d1b5abd in 17 seconds

More details
  • Looked at 14 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. .github/workflows/build_windows_worker.yml:30
  • Draft comment:
    Ensure type NUL > windmill-api/openapi-deref.yaml is intended for Windows environments only, as it is a Windows-specific command.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The command to create a file using type NUL is a Windows-specific command. Ensure that this is intended for Windows environments only.

Workflow ID: wflow_4itKqPDQx9KtNWl6


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 2f80ba1 in 16 seconds

More details
  • Looked at 11 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. .github/workflows/build_windows_worker.yml:30
  • Draft comment:
    Ensure the directory exists before creating the file to avoid errors. Consider using New-Item -ItemType Directory -Force for the directory.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The use of New-Item in the PowerShell command is correct for creating a file, but the command should ensure the directory exists before creating the file.

Workflow ID: wflow_oncwQWEWXvqXBYdr


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

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