Skip to content

Commit 2a07c02

Browse files
authored
Use Cirrus CLI artifacts instead of Cirrus CI Agent artifacts (#728)
1 parent e378c5b commit 2a07c02

File tree

16 files changed

+1310
-1291
lines changed

16 files changed

+1310
-1291
lines changed

internal/commands/run_darwin_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ task:
3838
install_proctools_script:
3939
- brew install proctools
4040
script:
41-
- pkill -STOP cirrus-ci-agent
41+
- pkill -STOP -f "cirrus agent"
4242
`, image, user, password)
4343

4444
testutil.TempChdir(t)

internal/executor/agent/agent.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func RetrieveBinary(
3636

3737
agentPath := filepath.Join(
3838
agentCacheDir,
39-
fmt.Sprintf("cirrus-ci-agent-%s-%s-%s%s", agentVersion, agentOS, agentArchitecture, agentSuffix),
39+
fmt.Sprintf("cirrus-%s-%s-%s%s", agentVersion, agentOS, agentArchitecture, agentSuffix),
4040
)
4141

4242
// Agent found in the cache
@@ -51,7 +51,7 @@ func RetrieveBinary(
5151
}
5252

5353
// Download the agent
54-
agentURL := fmt.Sprintf("https://github.com/cirruslabs/cirrus-ci-agent/releases/download/v%s/agent-%s-%s%s",
54+
agentURL := fmt.Sprintf("https://github.com/cirruslabs/cirrus-cli/releases/download/v%s/cirrus-%s-%s%s",
5555
agentVersion, agentOS, agentArchitecture, agentSuffix)
5656

5757
req, err := http.NewRequestWithContext(ctx, "GET", agentURL, http.NoBody)

internal/executor/executor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ func (e *Executor) runSingleTask(ctx context.Context, task *build.Task) (err err
194194
instanceRunOpts.SetLogger(taskLogger)
195195

196196
// Respect custom agent version
197-
if agentVersionFromEnv, ok := task.Environment["CIRRUS_AGENT_VERSION"]; ok {
198-
instanceRunOpts.SetAgentVersion(agentVersionFromEnv)
197+
if agentVersionFromEnv, ok := task.Environment["CIRRUS_CLI_VERSION"]; ok {
198+
instanceRunOpts.SetCLIVersion(agentVersionFromEnv)
199199
}
200200

201201
// Wrap the context to enforce a timeout for this task

internal/executor/executor_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ func TestExecutorClone(t *testing.T) {
6363
t.Fatal(err)
6464
}
6565

66+
renderer := renderers.NewSimpleRenderer(os.Stdout, nil)
67+
logger := echelon.NewLogger(echelon.TraceLevel, renderer)
68+
6669
e, err := executor.New(dir, []*api.Task{
6770
{
6871
LocalGroupId: 0,
@@ -85,7 +88,7 @@ func TestExecutorClone(t *testing.T) {
8588
},
8689
Instance: testutil.GetBasicContainerInstance(t, "debian:latest"),
8790
},
88-
})
91+
}, executor.WithLogger(logger))
8992
if err != nil {
9093
t.Fatal(err)
9194
}

internal/executor/instance/container/run.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ func RunContainerizedAgent(ctx context.Context, config *runconfig.RunConfig, par
6363
Image: params.Image,
6464
Architecture: params.Architecture,
6565
Entrypoint: []string{
66-
params.Platform.ContainerAgentPath(),
66+
params.Platform.ContainerCLIPath(),
67+
"agent",
6768
"-api-endpoint",
6869
config.Endpoint.Container(),
6970
"-server-token",

internal/executor/instance/persistentworker/isolation/none/none.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,13 @@ func (pwi *PersistentWorkerInstance) Attributes() []attribute.KeyValue {
6262

6363
func (pwi *PersistentWorkerInstance) Run(ctx context.Context, config *runconfig.RunConfig) (err error) {
6464
// Retrieve the agent's binary
65-
agentPath, err := agent.RetrieveBinary(ctx, config.GetAgentVersion(), runtime.GOOS, runtime.GOARCH)
65+
cliPath, err := agent.RetrieveBinary(ctx, config.GetAgentVersion(), runtime.GOOS, runtime.GOARCH)
6666
if err != nil {
6767
return err
6868
}
6969

70-
cmd := exec.Command(agentPath,
70+
cmd := exec.Command(cliPath,
71+
"agent",
7172
"-api-endpoint",
7273
config.Endpoint.Direct(),
7374
"-server-token",

internal/executor/instance/persistentworker/remoteagent/remoteagent.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func WaitForAgent(
8080

8181
logger.Debugf("uploading agent to %s...", addr)
8282

83-
remoteAgentPath, err := uploadAgent(ctx, cli, agentOS, config.GetAgentVersion(), agentArchitecture)
83+
remoteCLIPath, err := uploadAgent(ctx, cli, agentOS, config.GetAgentVersion(), agentArchitecture)
8484
if err != nil {
8585
return fmt.Errorf("%w: failed to upload agent via SFTP: %v",
8686
ErrFailed, err)
@@ -155,7 +155,8 @@ func WaitForAgent(
155155
}
156156

157157
command := []string{
158-
remoteAgentPath,
158+
remoteCLIPath,
159+
"agent",
159160
"-api-endpoint",
160161
apiEndpoint,
161162
"-server-token",

internal/executor/instance/persistentworker/remoteagent/sftp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func uploadAgent(
4343
}
4444

4545
// Create agent's binary remotely
46-
remoteAgentPath := path.Join(platform.NewUnix().CirrusDir(), "cirrus-ci-agent")
46+
remoteAgentPath := path.Join(platform.NewUnix().CirrusDir(), "cirrus")
4747
remoteAgentFile, err := sftpCli.Create(remoteAgentPath)
4848
if err != nil {
4949
return "", err

internal/executor/instance/runconfig/runconfig.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ func (rc *RunConfig) GetAgentVersion() string {
6666
return rc.agentVersion
6767
}
6868

69-
func (rc *RunConfig) SetAgentVersion(agentVersion string) {
69+
func (rc *RunConfig) SetCLIVersion(agentVersion string) {
7070
rc.agentVersion = agentVersion
7171
}
7272

73-
func (rc *RunConfig) SetAgentVersionWithoutDowngrade(agentVersion string) error {
73+
func (rc *RunConfig) SetCLIVersionWithoutDowngrade(agentVersion string) error {
7474
if agentVersion == "" {
7575
return nil
7676
}

internal/executor/instance/runconfig/runconfig_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ func TestSetAgentVersionWithoutDowngrade(t *testing.T) {
1414

1515
// No downgrade
1616
prettyLowVersion := "0.1.0"
17-
if err := rc.SetAgentVersionWithoutDowngrade(prettyLowVersion); err != nil {
17+
if err := rc.SetCLIVersionWithoutDowngrade(prettyLowVersion); err != nil {
1818
t.Fatal(err)
1919
}
2020
assert.Equal(t, platform.DefaultAgentVersion, rc.GetAgentVersion())
2121

2222
// Only upgrade
2323
prettyHighVersion := fmt.Sprintf("%d.0.0", math.MaxInt32)
24-
if err := rc.SetAgentVersionWithoutDowngrade(prettyHighVersion); err != nil {
24+
if err := rc.SetCLIVersionWithoutDowngrade(prettyHighVersion); err != nil {
2525
t.Fatal(err)
2626
}
2727
assert.Equal(t, prettyHighVersion, rc.GetAgentVersion())

0 commit comments

Comments
 (0)