Skip to content

[server] Do not use branch names for additionalRepositories #13529

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class ContextParser {
checkoutLocation: subRepo.checkoutLocation || subContext.repository.name,
upstreamRemoteURI: this.buildUpstreamCloneUrl(subContext),
// we want to create a local branch on all repos, in case it's a multi-repo change. If it's not there are no drawbacks anyway.
ref: context.ref,
//ref: context.ref,
refType: context.refType,
localBranch: context.localBranch,
});
Expand Down
83 changes: 83 additions & 0 deletions test/tests/components/ws-manager/additional_repositories_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package wsmanager

import (
"context"
"testing"
"time"

"sigs.k8s.io/e2e-framework/pkg/envconf"
"sigs.k8s.io/e2e-framework/pkg/features"

csapi "github.com/gitpod-io/gitpod/content-service/api"
"github.com/gitpod-io/gitpod/test/pkg/integration"
wsmanapi "github.com/gitpod-io/gitpod/ws-manager/api"
)

func TestAdditionalRepositories(t *testing.T) {
f := features.New("additional-repositories").
WithLabel("component", "ws-manager").
Assess("can open a workspace using the additionalRepositories property", func(_ context.Context, t *testing.T, cfg *envconf.Config) context.Context {
tests := []struct {
Name string
ContextURL string
}{
{
Name: "workspace with additionalRepositories using a branch",
ContextURL: "https://github.com/gitpod-io/gitpod-test-repo/tree/aledbf/test-additional-repositories",
},
{
Name: "workspace with additionalRepositories also using a branch in one of the additionalRepositories",
ContextURL: "https://github.com/gitpod-io/gitpod-test-repo/tree/aledbf/test-additional-repositories-with-branches",
},
}
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(5*len(tests))*time.Minute)
defer cancel()

for _, test := range tests {
t.Run(test.Name, func(t *testing.T) {
api := integration.NewComponentAPI(ctx, cfg.Namespace(), kubeconfig, cfg.Client())
t.Cleanup(func() {
api.Done(t)
})

_, stopWs, err := integration.LaunchWorkspaceDirectly(t, ctx, api, integration.WithRequestModifier(func(req *wsmanapi.StartWorkspaceRequest) error {
req.Type = wsmanapi.WorkspaceType_PREBUILD

req.Spec.Initializer = &csapi.WorkspaceInitializer{
Spec: &csapi.WorkspaceInitializer_Git{
Git: &csapi.GitInitializer{
RemoteUri: test.ContextURL,
Config: &csapi.GitConfig{},
},
},
}
return nil
}))
if err != nil {
t.Fatalf("cannot launch a workspace: %q", err)
}

defer func() {
sctx, scancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer scancel()

sapi := integration.NewComponentAPI(sctx, cfg.Namespace(), kubeconfig, cfg.Client())
defer sapi.Done(t)

_, err = stopWs(true, sapi)
if err != nil {
t.Errorf("cannot stop workspace: %q", err)
}
}()
})
}
return ctx
}).
Feature()

testEnv.Test(t, f)
}