summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Lempereur <jeremy.lempereur@gmail.com>2020-06-23 20:57:24 +0200
committerGitHub <noreply@github.com>2020-06-23 20:57:24 +0200
commit7cc668707b9c586a45f717301902224bca6d2a12 (patch)
tree6b3626d3cf39a625cda68430d9c9b11a72d46c57
parentFix container volumes being reused sometimes (#283) (diff)
downloadforgejo-act-0.2.10.tar.xz
forgejo-act-0.2.10.zip
remove .gitignore before docker cp (#288)v0.2.10
* Test setup before I try to understand how things work * Remove .gitignore before we run docker cp
-rw-r--r--pkg/runner/runner_test.go1
-rw-r--r--pkg/runner/step_context.go24
-rw-r--r--pkg/runner/testdata/issue-228/main.yaml14
3 files changed, 38 insertions, 1 deletions
diff --git a/pkg/runner/runner_test.go b/pkg/runner/runner_test.go
index 94ea327..14a576b 100644
--- a/pkg/runner/runner_test.go
+++ b/pkg/runner/runner_test.go
@@ -53,6 +53,7 @@ func TestRunEvent(t *testing.T) {
{"matrix", "push", ""},
{"commands", "push", ""},
{"workdir", "push", ""},
+ {"issue-228", "push", ""}, // TODO [igni]: Remove this once everything passes
}
log.SetLevel(log.DebugLevel)
diff --git a/pkg/runner/step_context.go b/pkg/runner/step_context.go
index 1ec5fb0..66291b7 100644
--- a/pkg/runner/step_context.go
+++ b/pkg/runner/step_context.go
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
+ "path"
"path/filepath"
"regexp"
"runtime"
@@ -266,7 +267,11 @@ func (sc *StepContext) runAction(actionDir string, actionPath string) common.Exe
switch action.Runs.Using {
case model.ActionRunsUsingNode12:
if step.Type() == model.StepTypeUsesActionRemote {
- err := rc.JobContainer.CopyDir(containerActionDir+string(filepath.Separator), actionDir)(ctx)
+ err := removeGitIgnore(actionDir)
+ if err != nil {
+ return err
+ }
+ err = rc.JobContainer.CopyDir(containerActionDir+string(filepath.Separator), actionDir)(ctx)
if err != nil {
return err
}
@@ -351,3 +356,20 @@ func newRemoteAction(action string) *remoteAction {
}
return ra
}
+
+// https://github.com/nektos/act/issues/228#issuecomment-629709055
+// files in .gitignore are not copied in a Docker container
+// this causes issues with actions that ignore other important resources
+// such as `node_modules` for example
+func removeGitIgnore(directory string) error {
+ gitIgnorePath := path.Join(directory, ".gitignore")
+ if _, err := os.Stat(gitIgnorePath); err == nil {
+ // .gitignore exists
+ log.Debugf("Removing %s before docker cp", gitIgnorePath)
+ err := os.Remove(gitIgnorePath)
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
diff --git a/pkg/runner/testdata/issue-228/main.yaml b/pkg/runner/testdata/issue-228/main.yaml
new file mode 100644
index 0000000..e0a0dfb
--- /dev/null
+++ b/pkg/runner/testdata/issue-228/main.yaml
@@ -0,0 +1,14 @@
+name: issue-228
+
+on:
+ - push
+
+jobs:
+ kind:
+ runs-on: ubuntu-latest
+ steps:
+ - run: apt-get update -y && apt-get install git -y # setup git credentials will fail otherwise
+ - name: Setup git credentials
+ uses: fusion-engineering/setup-git-credentials@v2
+ with:
+ credentials: https://test@github.com/