act: Issue: #567 breaks `act` on Windows
Act version
https://github.com/nektos/act/commit/6cde8f64dcc0f54619168b4f3883afccc5539a9d https://github.com/nektos/act/releases/tag/v0.2.21
Expected behaviour
act
doesn’t fail
Actual behaviour
act
fails because paths on Windows (C:\users\something\path\
) differ from paths on Linux (/home/something/path
)
Workflow and/or repository
workflow
on:
push:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Steps to reproduce
Run act
on Windows
act
output
Log
cat ~\..\..\..\..\act git: (6c258cf...) ≢ +1 ~0 -0 !
❯❯❯ go run main.go -W .\.github\workflows\test.yml
[test.yml/tests-1] 🧪 Matrix: map[deno:1.1.0 os:ubuntu-latest]
[test.yml/tests-2] 🚧 Skipping unsupported platform 'macos-latest'
[test.yml/tests-1] 🚀 Start image=catthehacker/ubuntu:act-latest
[test.yml/tests-1] 🐳 docker run image=catthehacker/ubuntu:act-latest platform=linux/amd64 entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[test.yml/tests-1] 🐳 docker cp src=C:\Users\cat\go\src\github.com\nektos\act\. dst=\github\workspace
[test.yml/tests-1] ⭐ Run actions/checkout@v2
[test.yml/tests-1] ✅ Success - actions/checkout@v2
Error: context canceled
exit status 1
cat ~\..\..\..\..\act git: (6c258cf...) ≢ +1 ~0 -0 !
❯❯❯
cat ~\..\..\..\..\act git: (6cde8f6...) ≢ +1 ~0 -0 !
❯❯❯ go run main.go -W .\.github\workflows\test.yml
[test.yml/tests-1] 🧪 Matrix: map[deno:1.1.0 os:ubuntu-latest]
[test.yml/tests-2] 🚧 Skipping unsupported platform 'macos-latest'
[test.yml/tests-1] 🚀 Start image=catthehacker/ubuntu:act-latest
Error: Error response from daemon: the working directory 'C:\Users\cat\go\src\github.com\nektos\act' is invalid, it needs to be an absolute path
exit status 1
cat ~\..\..\..\..\act git: (6cde8f6...) ≢ +1 ~0 -0 !
❯❯❯
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 13
- Comments: 26 (24 by maintainers)
Commits related to this issue
- fix: use new platforms after survey, check working dir for `.actrc` (#577) — committed to nektos/act by deleted user 3 years ago
While waiting on the PRs to land, attached is a build that fixes all known issues I can tell on the windows side, as well as updated workers that run jobs in /home/runner as a non-root user to more closely match the actual github actions runner. To use these just update your .actrc with the following:
https://github.com/JustinGrote/act/tree/release/ActForWindows act.zip
Related Dockerfile repo: https://github.com/JustinGrote/act-dockerimage/
@metamoof v0.2.20 should still work FYI
https://github.com/nektos/act/releases/tag/v0.2.20
Recommendation to fix the issue for windows:
The CWD (working directory) of the docker commands that get executed should always be from the perspective of “inside” the container, so it should be the variable which resolves to /github/workspace or /home/runner/work/PROJECT or whatever regardless of if it is linux or windows. Docs: https://docs.docker.com/engine/reference/commandline/exec/
The Copy action to copy the working dir into the workspace via a docker command. Since act runs on windows there’s no path translation that has to happen here. Example: https://stackoverflow.com/a/40313917/5511129
The Bind action (
act -b
) should mount the workspace dir to the docker volume. You can totally use the windows path in the docker command for making the volume and/or the binding. Example: https://stackoverflow.com/a/57553028/5511129Your WIP seems to be trying to translate the windows path into the WSL /mnt/c/etc. path and that should not be necessary. I’ll attempt a PR of the above if I have some time today.
@catthehacker I basically have this method now to translate the paths. I was going to put it on Input however I think it would make more sense either on Config or RunContext but then I’d either have to import input for the initial absolute path resolution or just duplicate it to avoid the dependency, do you have a preference or recommendation?
Work in progress: https://github.com/catthehacker/act-fork/tree/windows-fix
@jsoref no the latest release introduced a regression due to the pathing of the exec commands in docker not being interpreted properly.