From c1edd5ba60c4465f6e7619c1c7890e26a8100f88 Mon Sep 17 00:00:00 2001 From: zongz Date: Mon, 22 Jul 2024 16:30:14 +0800 Subject: [PATCH 1/3] fix: fix push error Signed-off-by: zongz --- .github/workflows/test.yaml | 13 ++++++ pkg/client/client.go | 10 ++--- pkg/client/client_test.go | 40 +++++++++++++++++ .../test_push_plain_http/helloworld_0.0.1.tar | Bin 0 -> 4096 bytes pkg/downloader/downloader.go | 2 +- pkg/oci/oci.go | 41 +++++++++++++----- scripts/e2e.sh | 4 -- scripts/e2e_prepare.sh | 4 ++ 8 files changed, 94 insertions(+), 20 deletions(-) create mode 100644 pkg/client/test_data/test_push_plain_http/helloworld_0.0.1.tar diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a0315c81..2160b92b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -26,6 +26,19 @@ jobs: - run: go build ./... - run: go vet ./... + - name: Running custom script + run: | + ./scripts/reg.sh + ./scripts/e2e_prepare.sh + + - name: Login to ghcr.io + run: | + ./bin/kpm login -u ${{ secrets.DEPLOY_ACCESS_NAME }} -p ${{ secrets.DEPLOY_ACCESS_TOKEN }} ghcr.io + + - name: Login to localhost:5001 + run: | + ./bin/kpm login -u test -p 1234 localhost:5001 + - name: Running go tests with coverage env: GO111MODULE: on diff --git a/pkg/client/client.go b/pkg/client/client.go index cae6aa66..631ffb2d 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -1020,7 +1020,7 @@ func (c *KpmClient) AcquireTheLatestOciVersion(ociSource downloader.Oci) (string ociClient, err := oci.NewOciClientWithOpts( oci.WithCredential(cred), oci.WithRepoPath(repoPath), - oci.WithPlainHttp(c.GetSettings().DefaultOciPlainHttp()), + oci.WithSettings(c.GetSettings()), ) if err != nil { @@ -1359,7 +1359,7 @@ func (c *KpmClient) DownloadPkgFromOci(dep *downloader.Oci, localPath string) (* ociClient, err := oci.NewOciClientWithOpts( oci.WithCredential(cred), oci.WithRepoPath(repoPath), - oci.WithPlainHttp(c.GetSettings().DefaultOciPlainHttp()), + oci.WithSettings(c.GetSettings()), ) if err != nil { @@ -1573,7 +1573,7 @@ func (c *KpmClient) PushToOci(localPath string, ociOpts *opt.OciOptions) error { ociCli, err := oci.NewOciClientWithOpts( oci.WithCredential(cred), oci.WithRepoPath(repoPath), - oci.WithPlainHttp(c.GetSettings().DefaultOciPlainHttp()), + oci.WithSettings(c.GetSettings()), ) if err != nil { @@ -1893,7 +1893,7 @@ func (c *KpmClient) pullTarFromOci(localPath string, ociOpts *opt.OciOptions) er ociCli, err := oci.NewOciClientWithOpts( oci.WithCredential(cred), oci.WithRepoPath(repoPath), - oci.WithPlainHttp(c.GetSettings().DefaultOciPlainHttp()), + oci.WithSettings(c.GetSettings()), ) if err != nil { @@ -1942,7 +1942,7 @@ func (c *KpmClient) FetchOciManifestIntoJsonStr(opts opt.OciFetchOptions) (strin ociCli, err := oci.NewOciClientWithOpts( oci.WithCredential(cred), oci.WithRepoPath(repoPath), - oci.WithPlainHttp(c.GetSettings().DefaultOciPlainHttp()), + oci.WithSettings(c.GetSettings()), ) if err != nil { diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index ddeb2425..a1d7a857 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -13,6 +13,7 @@ import ( "sort" "strings" "testing" + "time" "github.com/dominikbraun/graph" "github.com/elliotchance/orderedmap/v2" @@ -1939,3 +1940,42 @@ func TestRunInVendor(t *testing.T) { assert.Equal(t, buf.String(), "") assert.Equal(t, res.GetRawYamlResult(), "The_first_kcl_program: Hello World!") } + +func TestPushWithPlainHttp(t *testing.T) { + tests := []struct { + Reg string + Repo string + SkipOnWindows bool + }{ + {Reg: "localhost:5001", Repo: "test/helloworld", SkipOnWindows: true}, + {Reg: "ghcr.io", Repo: "kcl-lang/helloworld", SkipOnWindows: true}, + } + + for _, test := range tests { + if runtime.GOOS == "windows" && test.SkipOnWindows { + t.Logf("Skipping test on Windows for %s/%s", test.Reg, test.Repo) + continue // 在Windows上跳过此测试用例 + } + + tag := fmt.Sprintf("test-%d", time.Now().Unix()) + httpOciOpts := opt.OciOptions{ + Reg: test.Reg, + Repo: test.Repo, + PkgName: "helloworld", + Tag: tag, + } + + pkgPath := getTestDir("test_push_plain_http") + tarPath := filepath.Join(pkgPath, "helloworld_0.0.1.tar") + + kpmcli, err := NewKpmClient() + assert.Equal(t, err, nil) + + buf := new(bytes.Buffer) + kpmcli.logWriter = buf + err = kpmcli.PushToOci(tarPath, &httpOciOpts) + assert.Equal(t, err, (*reporter.KpmEvent)(nil)) + expectedMessage := fmt.Sprintf("pushed [registry] %s/test/helloworld", test.Reg) + assert.Contains(t, buf.String(), expectedMessage) + } +} diff --git a/pkg/client/test_data/test_push_plain_http/helloworld_0.0.1.tar b/pkg/client/test_data/test_push_plain_http/helloworld_0.0.1.tar new file mode 100644 index 0000000000000000000000000000000000000000..0b7e03d9a8ea768183a58de5c9247b808679d4b7 GIT binary patch literal 4096 zcmeH|&1!@&5XW=QQ&=y13lmKuJ@noODD+T@1dXovktNzK?9+E#EnSx4p3)YYAVg-u z%;f)LGK~0NfGd-doOh+pJ0xP+XCnaNLWvANp%Ma|OP-QQ`Y(-;w{g-AOF7x0K5Zn# zV^y``U+w{)m)bb_r(A8(vEG(mYnr7|V&R>A!=Hov;xAL=pJagi!E04(@PE$#<)DjJ z*XETDx;N276z@&f*>~%@GNz_%rp6Al`3UTuK}?UvjjIV5FdkD%e}YrU;YES9|5;~? z)=L5mdaM7@f7Sn~!toIL-xrXJxV>%$=8gQ4=q7)muJ|W1m4W{SCU3t_dy`j<8>bv! mg8blY?R1at{qAud1JUz52kv&>(ucr7fuKN8ASm!l3VZ-bHhBU7 literal 0 HcmV?d00001 diff --git a/pkg/downloader/downloader.go b/pkg/downloader/downloader.go index 8661d027..2369e3d0 100644 --- a/pkg/downloader/downloader.go +++ b/pkg/downloader/downloader.go @@ -150,7 +150,7 @@ func (d *OciDownloader) Download(opts DownloadOptions) error { ociCli, err := oci.NewOciClientWithOpts( oci.WithCredential(cred), oci.WithRepoPath(repoPath), - oci.WithPlainHttp(opts.Settings.DefaultOciPlainHttp()), + oci.WithSettings(&opts.Settings), ) if err != nil { diff --git a/pkg/oci/oci.go b/pkg/oci/oci.go index 06d86b83..418715c5 100644 --- a/pkg/oci/oci.go +++ b/pkg/oci/oci.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "log" + "net" "os" "path/filepath" "reflect" @@ -96,6 +97,7 @@ type OciClient struct { repo *remote.Repository ctx *context.Context logWriter io.Writer + settings *settings.Settings cred *remoteauth.Credential PullOciOptions *PullOciOptions } @@ -103,6 +105,14 @@ type OciClient struct { // OciClientOption configures how we set up the OciClient type OciClientOption func(*OciClient) error +// WithSettings sets the kpm settings of the OciClient +func WithSettings(settings *settings.Settings) OciClientOption { + return func(c *OciClient) error { + c.settings = settings + return nil + } +} + // WithRepoPath sets the repo path of the OciClient func WithRepoPath(repoPath string) OciClientOption { return func(c *OciClient) error { @@ -164,17 +174,28 @@ func NewOciClientWithOpts(opts ...OciClientOption) (*OciClient, error) { Credential: remoteauth.StaticCredential(client.repo.Reference.Host(), *client.cred), } - return &OciClient{ - repo: client.repo, - ctx: &ctx, - PullOciOptions: &PullOciOptions{ - CopyOpts: &oras.CopyOptions{ - CopyGraphOptions: oras.CopyGraphOptions{ - MaxMetadataBytes: DEFAULT_LIMIT_STORE_SIZE, // default is 64 MiB - }, + isPlainHttp, force := client.settings.ForceOciPlainHttp() + if force { + client.repo.PlainHTTP = isPlainHttp + } else { + registry := client.repo.Reference.String() + host, _, _ := net.SplitHostPort(registry) + if host == "localhost" || registry == "localhost" { + // not specified, defaults to plain http for localhost + client.repo.PlainHTTP = true + } + } + + client.ctx = &ctx + client.PullOciOptions = &PullOciOptions{ + CopyOpts: &oras.CopyOptions{ + CopyGraphOptions: oras.CopyGraphOptions{ + MaxMetadataBytes: DEFAULT_LIMIT_STORE_SIZE, // default is 64 MiB }, }, - }, nil + } + + return client, nil } // NewOciClient will new an OciClient. @@ -195,7 +216,7 @@ func NewOciClient(regName, repoName string, settings *settings.Settings) (*OciCl return NewOciClientWithOpts( WithRepoPath(utils.JoinPath(regName, repoName)), WithCredential(credential), - WithPlainHttp(settings.DefaultOciPlainHttp()), + WithSettings(settings), ) } diff --git a/scripts/e2e.sh b/scripts/e2e.sh index 2a6558df..3266add1 100755 --- a/scripts/e2e.sh +++ b/scripts/e2e.sh @@ -16,10 +16,6 @@ set -o pipefail # Install ginkgo GO111MODULE=on go install github.com/onsi/ginkgo/v2/ginkgo@v2.0.0 -# Build kpm binary -LDFLAGS="-X kcl-lang.io/kpm/pkg/version.version=test_version" -go build -ldflags "$LDFLAGS" -o ./bin/kpm - # Prepare e2e test env ./scripts/e2e_prepare.sh diff --git a/scripts/e2e_prepare.sh b/scripts/e2e_prepare.sh index f3f3d906..96519042 100755 --- a/scripts/e2e_prepare.sh +++ b/scripts/e2e_prepare.sh @@ -1,5 +1,9 @@ #!/bin/bash +# Build kpm binary +LDFLAGS="-X kcl-lang.io/kpm/pkg/version.version=test_version" +go build -ldflags "$LDFLAGS" -o ./bin/kpm + # Check kpm version version=$(./bin/kpm --version) if ! echo "$version" | grep -q "kpm version test_version"; then From ae8138c6df1903837332c088520943120476d15a Mon Sep 17 00:00:00 2001 From: zongz Date: Tue, 23 Jul 2024 16:52:15 +0800 Subject: [PATCH 2/3] fix: move test to e2e Signed-off-by: zongz --- .github/workflows/e2e-test.yml | 13 +++++ .github/workflows/test.yaml | 14 ------ pkg/client/client_test.go | 40 --------------- pkg/oci/oci.go | 22 +++++--- test/e2e/kpm_test.go | 50 +++++++++++++++++++ .../kpm_push/test_push_docker/test_suite.env | 2 + .../test_push_docker/test_suite.input | 1 + .../test_push_docker/test_suite.stderr | 0 .../test_push_docker/test_suite.stdout | 2 + .../kpm_push/test_push_ghcr/test_suite.env | 2 + .../kpm_push/test_push_ghcr/test_suite.input | 1 + .../kpm_push/test_push_ghcr/test_suite.stderr | 0 .../kpm_push/test_push_ghcr/test_suite.stdout | 2 + .../test_push_localhost/test_suite.env | 2 + .../test_push_localhost/test_suite.input | 1 + .../test_push_localhost/test_suite.stderr | 0 .../test_push_localhost/test_suite.stdout | 2 + .../test_data/test_push_docker/kcl.mod | 6 +++ .../test_data/test_push_docker/kcl.mod.lock | 0 .../test_data/test_push_docker/main.k | 1 + .../test_data/test_push_ghcr/kcl.mod | 6 +++ .../test_data/test_push_ghcr/kcl.mod.lock | 0 .../test_data/test_push_ghcr/main.k | 1 + .../test_data/test_push_localhost/kcl.mod | 6 +++ .../test_push_localhost/kcl.mod.lock | 0 .../test_data/test_push_localhost/main.k | 1 + 26 files changed, 113 insertions(+), 62 deletions(-) create mode 100644 test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.env create mode 100644 test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.input create mode 100644 test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.stderr create mode 100644 test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.stdout create mode 100644 test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.env create mode 100644 test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.input create mode 100644 test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.stderr create mode 100644 test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.stdout create mode 100644 test/e2e/test_suites/kpm/kpm_push/test_push_localhost/test_suite.env create mode 100644 test/e2e/test_suites/kpm/kpm_push/test_push_localhost/test_suite.input create mode 100644 test/e2e/test_suites/kpm/kpm_push/test_push_localhost/test_suite.stderr create mode 100644 test/e2e/test_suites/kpm/kpm_push/test_push_localhost/test_suite.stdout create mode 100644 test/e2e/test_suites/test_data/test_push_docker/kcl.mod create mode 100644 test/e2e/test_suites/test_data/test_push_docker/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_data/test_push_docker/main.k create mode 100644 test/e2e/test_suites/test_data/test_push_ghcr/kcl.mod create mode 100644 test/e2e/test_suites/test_data/test_push_ghcr/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_data/test_push_ghcr/main.k create mode 100644 test/e2e/test_suites/test_data/test_push_localhost/kcl.mod create mode 100644 test/e2e/test_suites/test_data/test_push_localhost/kcl.mod.lock create mode 100644 test/e2e/test_suites/test_data/test_push_localhost/main.k diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 0c694dcd..a70dba65 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -21,6 +21,19 @@ jobs: with: go-version: 1.22 + - name: Prepare the test oci registry + run: | + ./scripts/reg.sh + ./scripts/e2e_prepare.sh + + - name: Login to ghcr.io + run: | + ./bin/kpm login -u ${{ secrets.DEPLOY_ACCESS_NAME }} -p ${{ secrets.DEPLOY_ACCESS_TOKEN }} ghcr.io + + - name: Login to docker.io + run: | + ./bin/kpm login -u ${{ secrets.DEPLOY_ACCESS_NAME }} -p ${{ secrets.DEPLOY_ACCESS_TOKEN }} docker.io + - name: run e2e run: | make e2e diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2160b92b..fd2e08c1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -25,20 +25,6 @@ jobs: - run: go build ./... - run: go vet ./... - - - name: Running custom script - run: | - ./scripts/reg.sh - ./scripts/e2e_prepare.sh - - - name: Login to ghcr.io - run: | - ./bin/kpm login -u ${{ secrets.DEPLOY_ACCESS_NAME }} -p ${{ secrets.DEPLOY_ACCESS_TOKEN }} ghcr.io - - - name: Login to localhost:5001 - run: | - ./bin/kpm login -u test -p 1234 localhost:5001 - - name: Running go tests with coverage env: GO111MODULE: on diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index a1d7a857..ddeb2425 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -13,7 +13,6 @@ import ( "sort" "strings" "testing" - "time" "github.com/dominikbraun/graph" "github.com/elliotchance/orderedmap/v2" @@ -1940,42 +1939,3 @@ func TestRunInVendor(t *testing.T) { assert.Equal(t, buf.String(), "") assert.Equal(t, res.GetRawYamlResult(), "The_first_kcl_program: Hello World!") } - -func TestPushWithPlainHttp(t *testing.T) { - tests := []struct { - Reg string - Repo string - SkipOnWindows bool - }{ - {Reg: "localhost:5001", Repo: "test/helloworld", SkipOnWindows: true}, - {Reg: "ghcr.io", Repo: "kcl-lang/helloworld", SkipOnWindows: true}, - } - - for _, test := range tests { - if runtime.GOOS == "windows" && test.SkipOnWindows { - t.Logf("Skipping test on Windows for %s/%s", test.Reg, test.Repo) - continue // 在Windows上跳过此测试用例 - } - - tag := fmt.Sprintf("test-%d", time.Now().Unix()) - httpOciOpts := opt.OciOptions{ - Reg: test.Reg, - Repo: test.Repo, - PkgName: "helloworld", - Tag: tag, - } - - pkgPath := getTestDir("test_push_plain_http") - tarPath := filepath.Join(pkgPath, "helloworld_0.0.1.tar") - - kpmcli, err := NewKpmClient() - assert.Equal(t, err, nil) - - buf := new(bytes.Buffer) - kpmcli.logWriter = buf - err = kpmcli.PushToOci(tarPath, &httpOciOpts) - assert.Equal(t, err, (*reporter.KpmEvent)(nil)) - expectedMessage := fmt.Sprintf("pushed [registry] %s/test/helloworld", test.Reg) - assert.Contains(t, buf.String(), expectedMessage) - } -} diff --git a/pkg/oci/oci.go b/pkg/oci/oci.go index 418715c5..9f6075d5 100644 --- a/pkg/oci/oci.go +++ b/pkg/oci/oci.go @@ -98,6 +98,7 @@ type OciClient struct { ctx *context.Context logWriter io.Writer settings *settings.Settings + isPlainHttp *bool cred *remoteauth.Credential PullOciOptions *PullOciOptions } @@ -136,10 +137,7 @@ func WithCredential(credential *remoteauth.Credential) OciClientOption { // WithPlainHttp sets the plain http of the OciClient func WithPlainHttp(plainHttp bool) OciClientOption { return func(c *OciClient) error { - if c.repo == nil { - return fmt.Errorf("repo is nil") - } - c.repo.PlainHTTP = plainHttp + c.isPlainHttp = &plainHttp return nil } } @@ -174,16 +172,24 @@ func NewOciClientWithOpts(opts ...OciClientOption) (*OciClient, error) { Credential: remoteauth.StaticCredential(client.repo.Reference.Host(), *client.cred), } - isPlainHttp, force := client.settings.ForceOciPlainHttp() - if force { - client.repo.PlainHTTP = isPlainHttp - } else { + // If the plain http is not specified + if client.isPlainHttp == nil { + // Set the default value of the plain http registry := client.repo.Reference.String() host, _, _ := net.SplitHostPort(registry) if host == "localhost" || registry == "localhost" { // not specified, defaults to plain http for localhost client.repo.PlainHTTP = true } + + // If the plain http is specified in the settings file + // Override the default value of the plain http + if client.settings != nil { + isPlainHttp, force := client.settings.ForceOciPlainHttp() + if force { + client.repo.PlainHTTP = isPlainHttp + } + } } client.ctx = &ctx diff --git a/test/e2e/kpm_test.go b/test/e2e/kpm_test.go index 8ba10c87..63d7ea91 100644 --- a/test/e2e/kpm_test.go +++ b/test/e2e/kpm_test.go @@ -3,9 +3,11 @@ package e2e import ( "context" "encoding/json" + "fmt" "os" "path/filepath" "strings" + "time" "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" @@ -316,4 +318,52 @@ var _ = ginkgo.Describe("Kpm CLI Testing", func() { }) } }) + + ginkgo.Context("testing 'test push '", func() { + testSuitesRoot := filepath.Join(filepath.Join(filepath.Join(GetWorkDir(), TEST_SUITES_DIR), "kpm"), "kpm_push") + testSuites := LoadAllTestSuites(testSuitesRoot) + testDataRoot := filepath.Join(filepath.Join(GetWorkDir(), TEST_SUITES_DIR), "test_data") + for _, ts := range testSuites { + ts := ts + ginkgo.It(ts.GetTestSuiteInfo(), func() { + workspace := GetWorkspace() + + CopyDir(filepath.Join(testDataRoot, ts.Name), filepath.Join(workspace, ts.Name)) + + tag := fmt.Sprintf("test-%d", time.Now().Unix()) + kpmcli, err := client.NewKpmClient() + gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) + fmt.Printf("ts.Name: %v\n", ts.Name) + kpkg, err := kpmcli.LoadPkgFromPath(filepath.Join(workspace, ts.Name)) + gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) + + kpkg.ModFile.Pkg.Version = tag + kpkg.ModFile.Pkg.Name = "helloworld" + + kpkg.HomePath = filepath.Join(workspace, ts.Name, "helloworld") + kpkg.ModFile.HomePath = kpkg.HomePath + err = os.MkdirAll(kpkg.HomePath, os.ModePerm) + fmt.Printf("kpkg.HomePath: %v\n", kpkg.HomePath) + gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) + err = kpmcli.InitEmptyPkg(kpkg) + gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) + + // Init a package with tag create by time + input := ReplaceAllKeyByValue(ts.Input, "", filepath.Join(workspace, ts.Name)) + stdout, stderr, err := ExecKpmWithWorkDir(input, kpkg.HomePath) + expectedStdout := ReplaceAllKeyByValue(ts.ExpectStdout, "", workspace) + expectedStderr := ReplaceAllKeyByValue(ts.ExpectStderr, "", workspace) + + gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) + if !IsIgnore(expectedStdout) { + gomega.Expect(stdout).To(gomega.ContainSubstring(expectedStdout)) + } + if !IsIgnore(expectedStderr) { + gomega.Expect(stderr).To(gomega.ContainSubstring(expectedStderr)) + } + + gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) + }) + } + }) }) diff --git a/test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.env b/test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.env new file mode 100644 index 00000000..4c789529 --- /dev/null +++ b/test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.env @@ -0,0 +1,2 @@ +KPM_HOME="" +KCLVM_VENDOR_HOME="" \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.input b/test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.input new file mode 100644 index 00000000..da7c1a2f --- /dev/null +++ b/test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.input @@ -0,0 +1 @@ +kpm push oci://docker.io/kcllang/helloworld \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.stderr b/test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.stderr new file mode 100644 index 00000000..e69de29b diff --git a/test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.stdout new file mode 100644 index 00000000..5ac618fa --- /dev/null +++ b/test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.stdout @@ -0,0 +1,2 @@ +package 'helloworld' will be pushed +pushed [registry] localhost:5001/test/helloworld \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.env b/test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.env new file mode 100644 index 00000000..4c789529 --- /dev/null +++ b/test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.env @@ -0,0 +1,2 @@ +KPM_HOME="" +KCLVM_VENDOR_HOME="" \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.input b/test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.input new file mode 100644 index 00000000..7a9a3232 --- /dev/null +++ b/test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.input @@ -0,0 +1 @@ +kpm push oci://ghcr.io/kcl-lang/helloworld \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.stderr b/test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.stderr new file mode 100644 index 00000000..e69de29b diff --git a/test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.stdout new file mode 100644 index 00000000..5ac618fa --- /dev/null +++ b/test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.stdout @@ -0,0 +1,2 @@ +package 'helloworld' will be pushed +pushed [registry] localhost:5001/test/helloworld \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_push/test_push_localhost/test_suite.env b/test/e2e/test_suites/kpm/kpm_push/test_push_localhost/test_suite.env new file mode 100644 index 00000000..4c789529 --- /dev/null +++ b/test/e2e/test_suites/kpm/kpm_push/test_push_localhost/test_suite.env @@ -0,0 +1,2 @@ +KPM_HOME="" +KCLVM_VENDOR_HOME="" \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_push/test_push_localhost/test_suite.input b/test/e2e/test_suites/kpm/kpm_push/test_push_localhost/test_suite.input new file mode 100644 index 00000000..c65e9ac0 --- /dev/null +++ b/test/e2e/test_suites/kpm/kpm_push/test_push_localhost/test_suite.input @@ -0,0 +1 @@ +kpm push oci://localhost:5001/test/helloworld \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_push/test_push_localhost/test_suite.stderr b/test/e2e/test_suites/kpm/kpm_push/test_push_localhost/test_suite.stderr new file mode 100644 index 00000000..e69de29b diff --git a/test/e2e/test_suites/kpm/kpm_push/test_push_localhost/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_push/test_push_localhost/test_suite.stdout new file mode 100644 index 00000000..5ac618fa --- /dev/null +++ b/test/e2e/test_suites/kpm/kpm_push/test_push_localhost/test_suite.stdout @@ -0,0 +1,2 @@ +package 'helloworld' will be pushed +pushed [registry] localhost:5001/test/helloworld \ No newline at end of file diff --git a/test/e2e/test_suites/test_data/test_push_docker/kcl.mod b/test/e2e/test_suites/test_data/test_push_docker/kcl.mod new file mode 100644 index 00000000..6fd01805 --- /dev/null +++ b/test/e2e/test_suites/test_data/test_push_docker/kcl.mod @@ -0,0 +1,6 @@ +[package] +name = "helloworld" +edition = "v0.9.0" +version = "0.0.1" + + diff --git a/test/e2e/test_suites/test_data/test_push_docker/kcl.mod.lock b/test/e2e/test_suites/test_data/test_push_docker/kcl.mod.lock new file mode 100644 index 00000000..e69de29b diff --git a/test/e2e/test_suites/test_data/test_push_docker/main.k b/test/e2e/test_suites/test_data/test_push_docker/main.k new file mode 100644 index 00000000..fa7048e6 --- /dev/null +++ b/test/e2e/test_suites/test_data/test_push_docker/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_data/test_push_ghcr/kcl.mod b/test/e2e/test_suites/test_data/test_push_ghcr/kcl.mod new file mode 100644 index 00000000..6fd01805 --- /dev/null +++ b/test/e2e/test_suites/test_data/test_push_ghcr/kcl.mod @@ -0,0 +1,6 @@ +[package] +name = "helloworld" +edition = "v0.9.0" +version = "0.0.1" + + diff --git a/test/e2e/test_suites/test_data/test_push_ghcr/kcl.mod.lock b/test/e2e/test_suites/test_data/test_push_ghcr/kcl.mod.lock new file mode 100644 index 00000000..e69de29b diff --git a/test/e2e/test_suites/test_data/test_push_ghcr/main.k b/test/e2e/test_suites/test_data/test_push_ghcr/main.k new file mode 100644 index 00000000..fa7048e6 --- /dev/null +++ b/test/e2e/test_suites/test_data/test_push_ghcr/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_data/test_push_localhost/kcl.mod b/test/e2e/test_suites/test_data/test_push_localhost/kcl.mod new file mode 100644 index 00000000..6fd01805 --- /dev/null +++ b/test/e2e/test_suites/test_data/test_push_localhost/kcl.mod @@ -0,0 +1,6 @@ +[package] +name = "helloworld" +edition = "v0.9.0" +version = "0.0.1" + + diff --git a/test/e2e/test_suites/test_data/test_push_localhost/kcl.mod.lock b/test/e2e/test_suites/test_data/test_push_localhost/kcl.mod.lock new file mode 100644 index 00000000..e69de29b diff --git a/test/e2e/test_suites/test_data/test_push_localhost/main.k b/test/e2e/test_suites/test_data/test_push_localhost/main.k new file mode 100644 index 00000000..fa7048e6 --- /dev/null +++ b/test/e2e/test_suites/test_data/test_push_localhost/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file From 6bb0136e5dc261ed3c5983b7fd9ca30544668c63 Mon Sep 17 00:00:00 2001 From: zongz Date: Tue, 23 Jul 2024 16:58:05 +0800 Subject: [PATCH 3/3] fix: fix typo Signed-off-by: zongz --- .github/workflows/e2e-test.yml | 2 +- .../test_suites/kpm/kpm_push/test_push_docker/test_suite.stdout | 2 +- .../test_suites/kpm/kpm_push/test_push_ghcr/test_suite.stdout | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index a70dba65..a93bd909 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -32,7 +32,7 @@ jobs: - name: Login to docker.io run: | - ./bin/kpm login -u ${{ secrets.DEPLOY_ACCESS_NAME }} -p ${{ secrets.DEPLOY_ACCESS_TOKEN }} docker.io + ./bin/kpm login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} docker.io - name: run e2e run: | diff --git a/test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.stdout index 5ac618fa..01c476f9 100644 --- a/test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.stdout +++ b/test/e2e/test_suites/kpm/kpm_push/test_push_docker/test_suite.stdout @@ -1,2 +1,2 @@ package 'helloworld' will be pushed -pushed [registry] localhost:5001/test/helloworld \ No newline at end of file +pushed [registry] docker.io/kcllang/helloworld \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.stdout index 5ac618fa..20eb365c 100644 --- a/test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.stdout +++ b/test/e2e/test_suites/kpm/kpm_push/test_push_ghcr/test_suite.stdout @@ -1,2 +1,2 @@ package 'helloworld' will be pushed -pushed [registry] localhost:5001/test/helloworld \ No newline at end of file +pushed [registry] ghcr.io/kcl-lang/helloworld \ No newline at end of file