mirror of
https://github.com/actions/actions-runner-controller.git
synced 2025-12-11 03:57:01 +00:00
e2e,acceptance: Cover enterprise runners (#1124)
Adds various code and changes I have used while testing #1062
This commit is contained in:
@@ -5,12 +5,15 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Getenv(t *testing.T, name string) string {
|
||||
func Getenv(t *testing.T, name string, opts ...string) string {
|
||||
t.Helper()
|
||||
|
||||
v := os.Getenv(name)
|
||||
if v == "" {
|
||||
t.Fatal(name + " must be set")
|
||||
if len(opts) == 0 {
|
||||
t.Fatal(name + " must be set")
|
||||
}
|
||||
v = opts[0]
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ type GitRepo struct {
|
||||
Name string
|
||||
CommitMessage string
|
||||
Contents map[string][]byte
|
||||
Branch string
|
||||
|
||||
runtime.Cmdr
|
||||
}
|
||||
@@ -43,6 +44,11 @@ func (g *GitRepo) Sync(ctx context.Context) error {
|
||||
|
||||
for path, content := range g.Contents {
|
||||
absPath := filepath.Join(dir, path)
|
||||
d := filepath.Dir(absPath)
|
||||
|
||||
if err := os.MkdirAll(d, 0755); err != nil {
|
||||
return fmt.Errorf("error creating dir %s: %v", d, err)
|
||||
}
|
||||
|
||||
if err := os.WriteFile(absPath, content, 0755); err != nil {
|
||||
return fmt.Errorf("error writing %s: %w", path, err)
|
||||
@@ -89,7 +95,7 @@ func (g *GitRepo) gitCommitCmd(ctx context.Context, dir, msg string) *exec.Cmd {
|
||||
}
|
||||
|
||||
func (g *GitRepo) gitPushCmd(ctx context.Context, dir string) *exec.Cmd {
|
||||
cmd := exec.CommandContext(ctx, "git", "push", "origin", "master")
|
||||
cmd := exec.CommandContext(ctx, "git", "push", "origin", g.Branch)
|
||||
cmd.Dir = dir
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -323,6 +323,11 @@ func (k *Kind) Start(ctx context.Context) error {
|
||||
kindConfig := []byte(fmt.Sprintf(`kind: Cluster
|
||||
apiVersion: kind.x-k8s.io/v1alpha4
|
||||
name: %s
|
||||
networking:
|
||||
apiServerAddress: 0.0.0.0
|
||||
nodes:
|
||||
- role: control-plane
|
||||
- role: worker
|
||||
`, k.Name))
|
||||
|
||||
if err := os.WriteFile(f.Name(), kindConfig, 0644); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user