nektos / act

Run your GitHub Actions locally 🚀
https://nektosact.com
MIT License
53.89k stars 1.34k forks source link

Add support for `--no-container` to run windows/macos #97

Closed chenrui333 closed 1 year ago

chenrui333 commented 4 years ago

Thanks for creating this wonderful tool. It would be nice to have MacOS also supported as well.

cplee commented 4 years ago

All steps for act run in a docker container...not sure how to accomplish that with MacOS runner. Would you want it to NOT use a container and just run the commands directly on the mac that act is running on?

fwilhe commented 4 years ago

Kinda related: Sometime I think you really don't want to run stuff in containers, for example when act is invoked in a container itself which contains the required software already. Not sure if this is in scope, but it would be kind of nice if it had a --no-container flag which would do what it does now, except for using the locally installed tools..

How feasible would this be?

cplee commented 4 years ago

I like the idea @fwilhe - would like to see a flag --no-container that runs all the steps directly on your local workstation, and assumes the right tools are installed. This would enable both windows and macos environments.

albertofem commented 4 years ago

@cplee I have a rough but working implementation I'm using locally to test some macOS-based actions. It should also be easy enough to have it working in Windows. Please take a look here:

https://github.com/nektos/act/compare/master...albertofem:feature/running_on_host?expand=1

If you think this approach is good, I'll go ahead and make the PR once I have a better implementation and have tested extensively on both Mac and Windows.

cplee commented 4 years ago

@albertofem - this looks really promising! What do you think about also supporting --no-container to force the platform to be host?

jcansdale commented 4 years ago

@cplee,

I've been experimenting with running act inside GitHub Codespaces.

image

If there was a --no-container option to run actions on the host VM, that would be great!

Unfortunately the actions/setup-dotnet action is failing at the moment. I'm guessing this will be the same for many setup actions.

fwilhe commented 4 years ago

In my experience it is a viable workaround for failing setup actions to build a docker image that has everything your build needs. Provides you the same experience locally and in actions if you run your workflow in the image.

jcansdale commented 4 years ago

@fwilhe I did wonder about doing that. It's good to hear that it works well in practice!

Since you can optionally specify an image to use with Codespaces, this could be a good opportunity to sync-up build and development environments. 🤔

albertofem commented 4 years ago

@cplee Yes, I think the flag makes more sense for the general case rather than assuming non-supported hosts. I'm gonna rework my brach and come back as soon as I have something ready for review.

github-actions[bot] commented 4 years ago

Issue is stale and will be closed in 7 days unless there is new activity

fwilhe commented 4 years ago

Not stale. Any updates?

github-actions[bot] commented 4 years ago

Issue is stale and will be closed in 7 days unless there is new activity

jcansdale commented 3 years ago

Still watching and hoping. 🙂

github-actions[bot] commented 3 years ago

Issue is stale and will be closed in 7 days unless there is new activity

adnathanail commented 3 years ago

I still care!

jonioni commented 3 years ago

Still care +1. This may also solve certain scenarios as in #119 and #107 without having to download a 20GB image.

Segfaultd commented 3 years ago

Still care

vdo commented 3 years ago

I still care

catthehacker commented 3 years ago

Hi guys, can you please not spam/post unhelpful messages, it's creating unnecessary emails/notifications. Stalebot has been adjusted and it won't close the issue so fast like it did before so there is no need to bump all the time in such short period of time. as for the feature itself I'm working very slowly on implementing that in this (messy) branch: https://github.com/catthehacker/act-fork/tree/no-container

github-actions[bot] commented 3 years ago

Issue is stale and will be closed in 14 days unless there is new activity

catthehacker commented 3 years ago

Not stale. Just busy. 😔

honeyspoon commented 3 years ago

any way we could use this for macos on linux? https://github.com/sickcodes/Docker-OSX

catthehacker commented 3 years ago

@hnspn act currently doesn't support running workflows without Docker.

jacob-carlborg commented 3 years ago

Regarding the --no-container flag. I think it would best to run the non-linux runners in a VM instead of directly on the host. For Windows xhyve [1] can be used. It's a very lightweight hypervisor built on top of the Apple's Hypervisor framework. For macOS, there's another project called Anka [2] which also provides very lightweight VMs. I've used xhyve, but not for Windows guests. It's quite fast, a FreeBSD guest boots in around 10 seconds. I have not used Anka.

[1] https://github.com/machyve/xhyve [2] https://veertu.com/download-anka-develop

catthehacker commented 3 years ago

That's too much work for such little project especially since what you linked, those projects are not written in Go so it will be hard to make them work together. Docker supports Windows containers and that's something I want to implement but also give the ability to run actions directly on host. If you would like to run them in VM, run act in VM.

jacob-carlborg commented 3 years ago

Docker supports Windows containers

Isn't that only supported on Windows?

"Windows requires the host OS version to match the container OS version" [1] and:

$ uname
Darwin
$ docker run mcr.microsoft.com/windows/servercore:ltsc2019
Unable to find image 'mcr.microsoft.com/windows/servercore:ltsc2019' locally
ltsc2019: Pulling from windows/servercore
docker: no matching manifest for linux/amd64 in the manifest list entries.
See 'docker run --help'.

If you would like to run them in VM, run act in VM.

Yeah, that's a good point.

[1] https://hub.docker.com/_/microsoft-windows-base-os-images

jacob-carlborg commented 3 years ago

Xhyve only works on macOS, I didn't think that through. Anka also only works on macOS but you're only allowed to virtualize macOS on a native Mac.

catthehacker commented 3 years ago

Isn't that only supported on Windows?

Yes, you can't run Windows Docker containers on any other OS than Windows since those don't have Windows kernel. Just like Linux containers work only on Linux.

"Windows requires the host OS version to match the container OS version"

With Hyper-V isolation it's possible to run other versions of Windows OS containers.

$ uname
Darwin

Macs can't run anything on their own. Sorry.

catthehacker commented 3 years ago

Xhyve only works on macOS, I didn't think that through. Anka also only works on macOS but you're only allowed to virtualize macOS on a native Mac.

https://github.com/sickcodes/Docker-OSX This is what I'm using for bare testing of MacOS, it kinda works but to run Docker (inside MacOS VM) you need Intel CPU for nested virtualisation But I would like to not add any specific implementations for such weird hacks. All of that will work over SSH + DOCKER_HOST envvar.

jacob-carlborg commented 3 years ago

https://github.com/sickcodes/Docker-OSX This is what I'm using for bare testing of MacOS, it kinda works but to run Docker (inside MacOS VM) you need Intel CPU for nested virtualisation

I see.

catthehacker commented 3 years ago

Also, PSA: the issue is not stale. I didn't had much time to get back into drafting working PR (and because someone broke act on Windows which is my main dev machine, IntelliJ 🙏 please make proper SSH remote dev support like VSCode) but I've written quite a plan regarding this and other features and how to handle them properly so we don't get stuck with weird flags and implementations in future, just waiting for @cplee feedback if it looks all good and maybe later do something similar publicly to get feedback.

ogvalt commented 3 years ago

Hi everyone, Nice utility guys, really appreciate it. But I've faced similar issue as the guys above, trying to run github actions on my local linux environment for package are going to be built for windows and macos. So I've made little research and encountered Vagrant and Packer as kinda clues to how github actions could be mimiced fully locally. Windows examples: https://github.com/devopsjourney1/packer-windows Youtube explanation: https://www.youtube.com/watch?v=Cwk0ricWsiE

So, in the end of the day, I'd like to add my thoughts to this soup and I would be glad if they will help you and support for other platforms comes sooner. Hope if I'll be able to contribute in future :)

jamiehankins commented 3 years ago

On the README.md at the project root, it says "Below platforms are currently unsupported and won't work (see issue #97)", which of course, is a link to this issue.

I don't really care about "--no-container", I just want to be able to use the "windows-latest" Docker image because that's what our GitHub actions use. That, of course, is if I'm understanding this (from our yml file) correctly.

    # Even though we build for multiple platforms, we only need to run
    # on a single host operating system. This is because we utilize cross-
    # build functionality of the dotnet build system.
    runs-on: windows-latest

Is this issue really related to this?

catthehacker commented 3 years ago

@jamiehankins

Is this issue really related to this?

Not sure what you mean by that, but dotnet is not related at all to this project.

jamiehankins commented 3 years ago

Is this issue really related to this?

Not sure what you mean by that, but dotnet is not related at all to this project.

The README.md says "Below platforms are currently unsupported and won't work (see issue #97)". This is issue #97. One of the "(b)elow platforms" is "windows-latest".

I don't know what you mean by "dotnet is not related at all to this project." I'm not asking about dotnet. I'm asking how this issue is related to not being able to use the "windows-latest" Docker image, which is what my GitHub action needs.

catthehacker commented 3 years ago

Because running Windows docker containers is not implemented, that's why it says the platform is unsupported.

damian123 commented 3 years ago

I am getting Skipping unsupported platform 'windows-latest' can this be fixed?

catthehacker commented 3 years ago

I am getting Skipping unsupported platform 'windows-latest' can this be fixed?

No, please read my messages above

Vishesh-Gupta commented 3 years ago

I have read through the discussion above and making act run on windows-latest definitely seems complex, but an interesting thing would be allowing it to connect to an Azure VM at users' request by using their tokens and credentials and running it in a VM on their account where it syncs up if the user wants to use windows-latest as the image and can run the action in such a way.

The Azure SDK has a go version https://github.com/Azure/azure-sdk-for-go which can help in setting this up. Furthermore, the VM machine can either be allowed control by the user or can be managed by act through the SDK. Not sure if this is feasible or what makes this infeasible for the act. Would appreciate a response on either

catthehacker commented 3 years ago

There are multiple interesting ways of implementing this, each with pros & cons but all of them depend on being actually written/implemented first.

Not sure if this is feasible or what makes this infeasible for the act.

Most likely paying for the resources in Azure?

I have to get back on that but it's been so much more important (and easier) to fix current issues than to implement new features.

ChristopherHX commented 3 years ago

I started another atempt to implement something like --no-container as -P windows-latest=-self-hosted. As of now it seems to be fully functional if you have node in version 12 in your PATH, before running it. You cannot use any docker actions while using this self-hosted mode, this currently leads to undefined behavior. You may have to change the default shell manually to cmd / pwsh or powershell on windows, because act doesn't check if bash exists. actions/setup-node might alter the node version during a workflow run. Some parts now even work on freebsd and other platforms (with stubbed docker support) The self-hosted runner mode was tested by me on windows and freebsd. I had to replace hardcoded file paths with dynamic ones and fix a huge number of bugs which aren't even reported yet.

PS C:\Users\Christopher\Downloads\acttest> ..\act.exe -P windows-latest=-self-hosted
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git repo: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git revision: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git ref: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git repo: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git revision: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git ref: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git repo: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git revision: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git ref: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git repo: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git revision: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git ref: unable to find git repo"
[main.yml/windows] ⭐  Run actions/checkout@v2
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git repo: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git revision: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git ref: unable to find git repo"
[main.yml/windows]   ✅  Success - actions/checkout@v2
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git repo: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git revision: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git ref: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git repo: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git revision: unable to find git repo"
time="2021-06-30T22:38:58+02:00" level=warning msg="unable to get git ref: unable to find git repo"
[main.yml/windows] ⭐  Run echo Hello World3
| Hello World3
[main.yml/windows]   ✅  Success - echo Hello World3
time="2021-06-30T22:38:59+02:00" level=warning msg="unable to get git repo: unable to find git repo"
time="2021-06-30T22:38:59+02:00" level=warning msg="unable to get git revision: unable to find git repo"
time="2021-06-30T22:38:59+02:00" level=warning msg="unable to get git ref: unable to find git repo"
time="2021-06-30T22:38:59+02:00" level=warning msg="unable to get git repo: unable to find git repo"
time="2021-06-30T22:38:59+02:00" level=warning msg="unable to get git revision: unable to find git repo"
time="2021-06-30T22:38:59+02:00" level=warning msg="unable to get git ref: unable to find git repo"
[main.yml/windows] ⭐  Run dir
|  Volume in Laufwerk C: hat keine Bezeichnung.
|  Volumeseriennummer: 3E61-C6BE
|
|  Verzeichnis von C:\Users\Christopher\.cache\act\d1a916d6-c77e-49f8-8f22-bd87a29e6deb\hostexecutor
|
| 30.06.2021  22:38    <DIR>          .
| 30.06.2021  22:38    <DIR>          ..
| 30.06.2021  22:38    <DIR>          .github
|                0 Datei(en),              0 Bytes
|                3 Verzeichnis(se), 28.663.570.432 Bytes frei
[main.yml/windows]   ✅  Success - dir
time="2021-06-30T22:38:59+02:00" level=warning msg="unable to get git repo: unable to find git repo"
time="2021-06-30T22:38:59+02:00" level=warning msg="unable to get git revision: unable to find git repo"
time="2021-06-30T22:38:59+02:00" level=warning msg="unable to get git ref: unable to find git repo"
time="2021-06-30T22:38:59+02:00" level=warning msg="unable to get git repo: unable to find git repo"
time="2021-06-30T22:38:59+02:00" level=warning msg="unable to get git revision: unable to find git repo"
time="2021-06-30T22:38:59+02:00" level=warning msg="unable to get git ref: unable to find git repo"
[main.yml/windows] ⭐  Run type .github\workflows\main.yml
| on: push
| defaults:
|   run:
|     shell: cmd
| jobs:
|   windows:
|     runs-on: windows-latest
|     steps:
|     - uses: actions/checkout@v2
|     - run: echo Hello World3
|     - run: dir
[main.yml/windows]   ✅  Success - type .github\workflows\main.yml
Error: error during connect: This error may indicate that the docker daemon is not running.: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/volumes": open //./pipe/docker_engine: Das System kann die angegebene Datei nicht finden.

If you are interested, you find the code in my fork and a prebuild of act based on act v0.2.23. Used by my self-hosted runner prototype for github (feature request of act) to have a native freebsd runner. If my modification of act will ever going to be merged, it most likly will take over 6 month (One of my PR depends on another one e.g. this depends on #719).

fugkco commented 3 years ago

You all are clearly quite ahead of me but one more thought I'd like to add, perhaps adding support for qemu might be interesting. It would likely be a lot more work, but it would pave the way to for full macOS and Windows support.

catthehacker commented 3 years ago

qemu has absolutely terrible performance and breaks easily

vniehues commented 2 years ago

Are the plans to add support for windows & mac still active?

cloudcosmonaut commented 2 years ago

I'm also wondering that...

catthehacker commented 2 years ago

Are the plans to add support for windows & mac still active?

The issue is not closed so...

FranklinYu commented 2 years ago

You all are clearly quite ahead of me but one more thought I'd like to add, perhaps adding support for qemu might be interesting. It would likely be a lot more work, but it would pave the way to for full macOS and Windows support.

macOS on QEMU on KVM is against Apple EULA (End User License Agreement), FYI. This at least mean that support will be limited, and bug will be expected.

Not sure about Windows; perhaps they allow you to run Windows VM without a license?

jacob-carlborg commented 2 years ago

macOS on QEMU on KVM is against Apple EULA

You're allowed to virtualize macOS on Apple hardware.

FranklinYu commented 2 years ago

That's too much work for such little project especially since what you linked, those projects are not written in Go so it will be hard to make them work together.

How about https://github.com/penberg/go-osxhv? Direct cgo binding of Hypervisor Framework (i.e. the backend of xhyve).

fugkco commented 2 years ago

macOS on QEMU on KVM is against Apple EULA (End User License Agreement), FYI. This at least mean that support will be limited, and bug will be expected.

Not sure about Windows; perhaps they allow you to run Windows VM without a license?

It's not up to this project to figure out licensing anyway. It's up to the individual user of it to ensure they don't run Windows and macOS against Microsoft/Apple ToS.