[PR #635] [MERGED] Separate Container Workdir from host Workdir #1531

Closed
opened 2026-03-01 21:51:34 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/nektos/act/pull/635
Author: @JustinGrote
Created: 4/24/2021
Status: Merged
Merged: 5/4/2021
Merged by: @cplee

Base: masterHead: JustinGrote/issue587


📝 Commits (4)

  • 90bce73 Separate Container Workdir from Host Workdir
  • 3545920 Add delegated component to MacOS Test
  • 5713e5b Lint: Remove leading newline
  • d83e7b0 Fix trailing path issue

📊 Changes

8 files changed (+263 additions, -66 deletions)

View changed files

📝 .gitignore (+4 -0)
📝 pkg/runner/run_context.go (+45 -26)
📝 pkg/runner/run_context_test.go (+66 -0)
📝 pkg/runner/runner.go (+44 -0)
📝 pkg/runner/runner_test.go (+67 -3)
📝 pkg/runner/step_context.go (+32 -33)
📝 pkg/runner/step_context_test.go (+4 -1)
📝 pkg/runner/testdata/workdir/push.yml (+1 -3)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/nektos/act/pull/635 **Author:** [@JustinGrote](https://github.com/JustinGrote) **Created:** 4/24/2021 **Status:** ✅ Merged **Merged:** 5/4/2021 **Merged by:** [@cplee](https://github.com/cplee) **Base:** `master` ← **Head:** `JustinGrote/issue587` --- ### 📝 Commits (4) - [`90bce73`](https://github.com/nektos/act/commit/90bce73fdf0b6a7e295176c14e167c5bb2b61ca4) Separate Container Workdir from Host Workdir - [`3545920`](https://github.com/nektos/act/commit/35459209fc3f29164fba52141700fa3293b5e5e8) Add delegated component to MacOS Test - [`5713e5b`](https://github.com/nektos/act/commit/5713e5bc64dafefc0f41fe917e5b4e56579ebbf0) Lint: Remove leading newline - [`d83e7b0`](https://github.com/nektos/act/commit/d83e7b0f3fcfaf523308d51650a0cd2981dbb782) Fix trailing path issue ### 📊 Changes **8 files changed** (+263 additions, -66 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+4 -0) 📝 `pkg/runner/run_context.go` (+45 -26) 📝 `pkg/runner/run_context_test.go` (+66 -0) 📝 `pkg/runner/runner.go` (+44 -0) 📝 `pkg/runner/runner_test.go` (+67 -3) 📝 `pkg/runner/step_context.go` (+32 -33) 📝 `pkg/runner/step_context_test.go` (+4 -1) 📝 `pkg/runner/testdata/workdir/push.yml` (+1 -3) </details> ### 📄 Description 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-01 21:51:34 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#1531
No description provided.