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

Separate Container Workdir from host Workdir #635

Merged
merged 4 commits into from
May 4, 2021

Conversation

JustinGrote
Copy link
Contributor

@JustinGrote JustinGrote commented Apr 24, 2021

This PR started as a WSL2 fix but the pathing issue was so pervasive it expanded in scope a bit to meet the requirement.

A summary of changes:

  • Adds path translation for WSL2 paths in order to enable act to function on Windows again.
  • Refactor Binds and Mounts to a new function to coordinate either/or based on the BindWorkDir setting
  • Add ContainerWorkDir() function to fetch the relative container function. This currently has the same behavior as before on Linux but translates to the WSL2 path on windows. In a future PR I will expand this to allow a command switch so that the container can as closely mimic the Github Actions runner paths as possible.

Tests:

  • Changed Integration tests to use BindWorkDir: false instead of true to more closely match the most common act behavior (since bindworkdir is false by default). Tested to work both ways, should probably expand them as such
  • Removed duplicate integration tests, not sure if this was done on purpose to make sure they are idempotent, this should be more clearly done with a loop instead
  • Added the ability for tests to read from the .secrets file so that GITHUB_TOKEN can be specified for actions like action/checkout and be tested locally and not just inside github actions
  • Removed checkout from workdir test, it's not necessary for the purpose of the test

Resolves #587

@JustinGrote JustinGrote marked this pull request as draft April 25, 2021 00:27
@catthehacker catthehacker self-requested a review April 25, 2021 12:13
@codecov
Copy link

codecov bot commented Apr 27, 2021

Codecov Report

Merging #635 (d83e7b0) into master (020d6a6) will decrease coverage by 0.35%.
The diff coverage is 76.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #635      +/-   ##
==========================================
- Coverage   49.62%   49.27%   -0.36%     
==========================================
  Files          23       23              
  Lines        2380     2401      +21     
==========================================
+ Hits         1181     1183       +2     
- Misses       1072     1090      +18     
- Partials      127      128       +1     
Impacted Files Coverage Δ
pkg/runner/runner.go 76.47% <37.50%> (-17.82%) ⬇️
pkg/runner/step_context.go 68.94% <80.76%> (-1.92%) ⬇️
pkg/runner/run_context.go 76.40% <93.10%> (-0.17%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 020d6a6...d83e7b0. Read the comment docs.

@JustinGrote JustinGrote changed the title Fix: Windows WSL2 path translation Separate Container Workdir from host Workdir Apr 27, 2021
@JustinGrote JustinGrote marked this pull request as ready for review April 27, 2021 06:23
@JustinGrote
Copy link
Contributor Author

JustinGrote commented Apr 27, 2021

@catthehacker ready to review.

FYI you need to update your codecov action to include a base target, otherwise this is pretty much always going to reject through no fault of my own because the codebase outside of my PR is being tested as well.
image

@catthehacker
Copy link
Member

Don't mind codecov, it does it job fine even when failing 😋
Will take a look later

@JustinGrote
Copy link
Contributor Author

Don't mind codecov, it does it job fine even when failing 😋
Will take a look later

Thanks, since you had codecov as a check I thought it might block the merge but since you're an admin I guess you can just force merge it anyways :)

pkg/runner/runner_test.go Show resolved Hide resolved
pkg/runner/runner_test.go Outdated Show resolved Hide resolved
pkg/runner/runner.go Outdated Show resolved Hide resolved
Comment on lines 20 to 25

{"testdata", "uses-and-run-in-one-step", "push", "Invalid run/uses syntax for job:test step:Test", platforms, "linux/arm64"},
{"testdata", "uses-github-empty", "push", "Expected format {org}/{repo}[/path]@ref", platforms, "linux/arm64"},
{"testdata", "uses-github-noref", "push", "Expected format {org}/{repo}[/path]@ref", platforms, "linux/arm64"},
{"testdata", "uses-github-root", "push", "", platforms, "linux/arm64"},
{"testdata", "uses-github-path", "push", "", platforms, "linux/arm64"},
Copy link
Member

Choose a reason for hiding this comment

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

Please no

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See answer above for run tests

pkg/runner/testdata/workdir/push.yml Show resolved Hide resolved
pkg/runner/step_context_test.go Show resolved Hide resolved
catthehacker
catthehacker previously approved these changes Apr 28, 2021
@JustinGrote JustinGrote marked this pull request as draft April 29, 2021 17:50
@JustinGrote
Copy link
Contributor Author

Reverted to draft to complete tests.

@JustinGrote JustinGrote marked this pull request as ready for review April 30, 2021 02:25
@JustinGrote
Copy link
Contributor Author

@catthehacker unit tests added for new functions, this should be ready to merge. Tests pass on my machine but the docker setup barfs in Windows Github Actions runner, I'll try to make a separate PR to enable Windows PR tests to run.

@catthehacker
Copy link
Member

@JustinGrote it's not possible to run Docker on Windows GitHub runner currently.

@JustinGrote
Copy link
Contributor Author

@JustinGrote it's not possible to run Docker on Windows GitHub runner currently.

Whoops you are right, derp. Maybe I can figure out a nested docker in ACI but I won't spend too much time on it for now.

@catthehacker
Copy link
Member

@JustinGrote If we get newer Windows version on GHA (ref: actions/runner-images#3138), we might be able to have Docker in WSL2 and run tests.
If not, I'll most likely add self-hosted runner.

@cplee cplee added the needs-work Extra attention is needed label May 2, 2021
@cplee
Copy link
Contributor

cplee commented May 2, 2021

@JustinGrote - Adding needs-work tag due to conflicts

@JustinGrote
Copy link
Contributor Author

Thanks, will rebase and sort it out.

@JustinGrote
Copy link
Contributor Author

@cplee Squashed and rebased on master. Conflicts were parallel fixes to tests. Should be ready for re-review

catthehacker
catthehacker previously approved these changes May 2, 2021
@cplee
Copy link
Contributor

cplee commented May 3, 2021

Looks like this is causing MacOS tests to fail now :(

@catthehacker
Copy link
Member

--- FAIL: TestRunContext_GetBindsAndMounts (0.00s)
    --- FAIL: TestRunContext_GetBindsAndMounts//mnt/linuxBind (0.00s)
    --- PASS: TestRunContext_GetBindsAndMounts//mnt/linux (0.00s)
    --- FAIL: TestRunContext_GetBindsAndMounts//mnt/path_with_spaces/linuxBind (0.00s)
    --- PASS: TestRunContext_GetBindsAndMounts//mnt/path_with_spaces/linux (0.00s)

@JustinGrote JustinGrote force-pushed the JustinGrote/issue587 branch 2 times, most recently from b5e02d6 to 47e9bde Compare May 3, 2021 16:06
@JustinGrote
Copy link
Contributor Author

@cplee I'm working on the mac test now

@JustinGrote
Copy link
Contributor Author

@cplee I'm working on the mac test now

Found it, bad test, forgot that MacOS adds that :delegated to the binds. Force pushing the update plus your latest master rebase

@JustinGrote
Copy link
Contributor Author

@cplee test fixed but now currently failing on new linter tests, rebase it when those tests get fixed and it should be OK.

@catthehacker
Copy link
Member

(JustinGrote/issue587)> ~/go/bin/golangci-lint run
pkg/runner/runner_test.go:104: File is not `goimports`-ed (goimports)
    {"testdata", "issue-597", "push", "", platforms, ""},
pkg/runner/run_context.go:554: unnecessary leading newline (whitespace)
func (ghc *githubContext) isLocalCheckout(step *model.Step) bool {

⏎                                           

@JustinGrote
Copy link
Contributor Author

@catthehacker The imports one comes from master, I can fix the whitespace one however.
https://github.com/nektos/act/runs/2493880863

@JustinGrote
Copy link
Contributor Author

@catthehacker @cplee just a reminder that the linting error is currently coming from master, not this PR, so I won't touch it assuming it will be fixed in master to avoid a conflict.

@JustinGrote
Copy link
Contributor Author

@catthehacker @cplee ugh I just noticed that a maybeCopy was added in a recent commit I'll need to reconcile, will report back.

@catthehacker
Copy link
Member

@catthehacker @cplee just a reminder that the linting error is currently coming from master, not this PR, so I won't touch it assuming it will be fixed in master to avoid a conflict.

it seems that lint issue is in your branch and in master it's already fixed

@JustinGrote
Copy link
Contributor Author

@catthehacker right, I didn't see that new changes had landed, working on that but once I rebase those in it should be good.

@cplee cplee removed the needs-work Extra attention is needed label May 4, 2021
@cplee cplee requested a review from catthehacker May 4, 2021 20:13
Copy link
Member

@catthehacker catthehacker 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! if we miss anything, I'll be sure to push fix 😸

@cplee cplee merged commit 0f04942 into nektos:master May 4, 2021
@JustinGrote JustinGrote deleted the JustinGrote/issue587 branch May 4, 2021 21:56
@JustinGrote
Copy link
Contributor Author

Yay! Thank you @cplee and @catthehacker, I'll try to be available for any regressions that occur since this was a bit of a broad change, but this will lay the groundwork for some additional things as well.

catthehacker pushed a commit to catthehacker/act-fork that referenced this pull request May 5, 2021
Since nektos#635 `envs.txt` is not copying properly when running `act` in WSL2
Moving it to fixed location resolves that.
catthehacker pushed a commit to catthehacker/act-fork that referenced this pull request May 5, 2021
Since nektos#635 `envs.txt` is not copying properly when running `act` in WSL2
Moving it to fixed location resolves that.
catthehacker pushed a commit to catthehacker/act-fork that referenced this pull request May 5, 2021
Since nektos#635 `envs.txt` is not copying properly when running `act` in WSL2
Moving it to fixed location resolves that.
catthehacker pushed a commit to catthehacker/act-fork that referenced this pull request May 5, 2021
Since nektos#635 `envs.txt` is not copying properly when running `act` in WSL2
Moving it to fixed location resolves that.
mergify bot pushed a commit that referenced this pull request May 5, 2021
…ocation (#667)

* fix: environment variables sourcing from `/etc/environment`

* fix: move `envs.txt` & `event.json` to `/tmp/`

Since #635 `envs.txt` is not copying properly when running `act` in WSL2
Moving it to fixed location resolves that.
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.

Issue: #567 breaks act on Windows
3 participants