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

feat: Host environment #1293

Merged
merged 47 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0ffac4c
feat: HostEnvironment
ChristopherHX Aug 4, 2022
7f3b9b0
fix: lint
ChristopherHX Aug 4, 2022
5cbbeb9
fixes and update code
ChristopherHX Aug 4, 2022
cd66680
update go mod
ChristopherHX Aug 5, 2022
7172785
lint / test fixes
ChristopherHX Aug 5, 2022
51464dd
fix lint
ChristopherHX Aug 5, 2022
d98c077
Evaluate job env in jobexecutor, disable test
ChristopherHX Aug 5, 2022
ea2b60d
fix: CI is unstable due to new linting rules
ChristopherHX Aug 5, 2022
b9828de
stability fixes
ChristopherHX Aug 5, 2022
43c0006
fix lint
ChristopherHX Aug 5, 2022
e80a2a1
.
ChristopherHX Aug 5, 2022
32d3529
.
ChristopherHX Aug 5, 2022
18701cf
fix nil expreval in test
ChristopherHX Aug 5, 2022
e45dcd4
tweak to avoid crash in test
ChristopherHX Aug 5, 2022
ec3c803
fix test
ChristopherHX Aug 5, 2022
fb9a7cf
skip code in some Tests
ChristopherHX Aug 5, 2022
0ab6a53
fix: absolute cwd in windows
ChristopherHX Aug 6, 2022
2ffea60
fix: reading files from hostenv
ChristopherHX Aug 6, 2022
a2f8b94
fix: GITHUB_PATH not working hostenv
ChristopherHX Aug 6, 2022
b6af367
Add initial Tests
ChristopherHX Aug 6, 2022
652723f
change tool name for sh
ChristopherHX Aug 6, 2022
8d77e0c
disable docker action tests / fix env file parsing
ChristopherHX Aug 6, 2022
d2298ad
Apply some suggestions from code review
ChristopherHX Aug 8, 2022
164e92d
Split HostEnvironment in it's own function
ChristopherHX Aug 8, 2022
55ffe9c
fix logic
ChristopherHX Aug 8, 2022
8321770
Merge branch 'master' into host_environment
cplee Aug 29, 2022
341ff69
Resolve Conflicts: GetRunnerContext now has ctx
ChristopherHX Aug 29, 2022
7b03881
fix: GetContainerArchive on Folders
ChristopherHX Aug 30, 2022
68c2df9
workaround: PATH and Path on windows
ChristopherHX Aug 30, 2022
ded9f65
revert: removed empty line
ChristopherHX Aug 30, 2022
2c46605
fix: yaml style
ChristopherHX Sep 16, 2022
04b62c3
Merge master into host_environment
ChristopherHX Sep 16, 2022
1787b94
Add type asserts
ChristopherHX Sep 16, 2022
e79e05b
revert change
ChristopherHX Sep 16, 2022
924fad8
Add original lookpath LICENSE
ChristopherHX Oct 2, 2022
39789f1
Merge branch 'master' into host_environment
ChristopherHX Oct 2, 2022
a8677dd
Avoid weird lint error
ChristopherHX Oct 2, 2022
1e8c1f6
Remove disabled Test
ChristopherHX Oct 2, 2022
1f9a650
Merge branch 'master' into host_environment
ChristopherHX Oct 9, 2022
18a4da8
Fix merge
ChristopherHX Oct 9, 2022
96342c4
Merge branch 'master' into host_environment
ChristopherHX Oct 19, 2022
821c56e
Rewrite UpdateFromEnv
ChristopherHX Oct 19, 2022
618bff5
Remove unused import
ChristopherHX Oct 19, 2022
98f846a
fix error message
ChristopherHX Oct 19, 2022
2a1fba5
Merge branch 'master' of nektos/act
ChristopherHX Nov 8, 2022
292fa08
Merge branch 'master' into host_environment
mergify[bot] Nov 16, 2022
399f87b
Merge branch 'master' into host_environment
ChristopherHX Nov 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,25 @@ jobs:
files: coverage.txt
fail_ci_if_error: true # optional (default = false)

test-host:
strategy:
matrix:
os:
- windows-latest
- macos-latest
name: test-${{matrix.os}}
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
check-latest: true
- run: go test -v -run ^TestRunEventHostEnvironment$ ./...
# TODO merge coverage with test-linux

snapshot:
name: snapshot
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/AlecAivazis/survey/v2 v2.3.6
github.com/Masterminds/semver v1.5.0
github.com/andreaskoch/go-fswatch v1.0.0
github.com/creack/pty v1.1.17
github.com/docker/cli v20.10.21+incompatible
github.com/docker/distribution v2.8.1+incompatible
github.com/docker/docker v20.10.21+incompatible
Expand Down
3 changes: 2 additions & 1 deletion pkg/container/docker_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ type Container interface {
}

// NewContainer creates a reference to a container
func NewContainer(input *NewContainerInput) Container {
func NewContainer(input *NewContainerInput) ExecutionsEnvironment {
cr := new(containerReference)
cr.input = input
return cr
Expand Down Expand Up @@ -233,6 +233,7 @@ type containerReference struct {
input *NewContainerInput
UID int
GID int
LinuxContainerEnvironmentExtensions
}

func GetDockerClient(ctx context.Context) (cli client.APIClient, err error) {
Expand Down
3 changes: 3 additions & 0 deletions pkg/container/docker_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,6 @@ func TestDockerExecFailure(t *testing.T) {
conn.AssertExpectations(t)
client.AssertExpectations(t)
}

// Type assert containerReference implements ExecutionsEnvironment
var _ ExecutionsEnvironment = &containerReference{}
Comment on lines +166 to +168
Copy link
Member

Choose a reason for hiding this comment

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

❤️

13 changes: 13 additions & 0 deletions pkg/container/executions_environment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package container

import "context"

type ExecutionsEnvironment interface {
Container
ToContainerPath(string) string
GetActPath() string
GetPathVariableName() string
DefaultPathVariable() string
JoinPathVariable(...string) string
GetRunnerContext(ctx context.Context) map[string]interface{}
}
23 changes: 23 additions & 0 deletions pkg/container/file_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,29 @@ func (tc tarCollector) WriteFile(fpath string, fi fs.FileInfo, linkName string,
return nil
}

type copyCollector struct {
DstDir string
}

func (cc *copyCollector) WriteFile(fpath string, fi fs.FileInfo, linkName string, f io.Reader) error {
fdestpath := filepath.Join(cc.DstDir, fpath)
if err := os.MkdirAll(filepath.Dir(fdestpath), 0777); err != nil {
return err
}
if f == nil {
return os.Symlink(linkName, fdestpath)
}
df, err := os.OpenFile(fdestpath, os.O_CREATE|os.O_WRONLY, fi.Mode())
if err != nil {
return err
}
defer df.Close()
if _, err := io.Copy(df, f); err != nil {
return err
}
return nil
}

type fileCollector struct {
Ignorer gitignore.Matcher
SrcPath string
Expand Down
Loading