-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from LinuxSuRen/fix-remote-tag-check
Fix the wrong remote tag checking
- Loading branch information
Showing
9 changed files
with
155 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Pull Request Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Set up Go 1.16 | ||
uses: actions/setup-go@v2.1.4 | ||
with: | ||
go-version: 1.16 | ||
id: go | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2.3.4 | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2.7.0 | ||
with: | ||
version: latest | ||
args: release --skip-publish --rm-dist | ||
|
||
UnitTest: | ||
name: Test | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Set up Go 1.16 | ||
uses: actions/setup-go@v2.1.3 | ||
with: | ||
go-version: 1.16 | ||
id: go | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2.3.4 | ||
- name: Test | ||
run: | | ||
go test ./... -coverprofile coverage.out | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: coverage.out | ||
flags: unittests | ||
name: codecov-umbrella | ||
fail_ci_if_error: true |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// +build integration | ||
|
||
/* | ||
Copyright 2021 The KubeSphere Authors. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// +build integration | ||
|
||
package controllers | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"math/rand" | ||
"strconv" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestRemoteTagExists(t *testing.T) { | ||
repo, err := clone("https://gitee.com/linuxsuren/test", "master", nil, "bin/tmp") | ||
assert.Nil(t, err) | ||
|
||
result := remoteTagExists("v0.0.7", repo) | ||
assert.True(t, result) | ||
|
||
result = remoteTagExists("v0.0.8", repo) | ||
assert.True(t, result) | ||
|
||
def := rand.New(rand.NewSource(time.Now().UnixNano())) | ||
|
||
// not existing | ||
fakeTag := strconv.Itoa(def.Int()) | ||
result = remoteTagExists(fakeTag, repo) | ||
assert.False(t, result) | ||
|
||
result, err = setTag(repo, fakeTag, "message", "user") | ||
assert.True(t, result) | ||
assert.Nil(t, err) | ||
|
||
result = remoteTagExists(fakeTag, repo) | ||
assert.True(t, result) | ||
|
||
err = pushTags(repo, "xx", nil) | ||
assert.NotNil(t, err) | ||
|
||
_, err = clone("xx://wrong url format", "xxx", nil, "bin/tmp") | ||
assert.NotNil(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/go-git/go-git/v5/plumbing/transport" | ||
"github.com/go-git/go-git/v5/plumbing/transport/ssh" | ||
"github.com/stretchr/testify/assert" | ||
v1 "k8s.io/api/core/v1" | ||
"testing" | ||
) | ||
|
||
func TestGetAuth(t *testing.T) { | ||
var secret *v1.Secret | ||
var auth transport.AuthMethod | ||
|
||
// secret is nil | ||
auth = getAuth(secret) | ||
assert.Nil(t, auth) | ||
|
||
// empty secret | ||
secret = &v1.Secret{} | ||
auth = getAuth(secret) | ||
assert.Nil(t, auth) | ||
|
||
// basic auth | ||
secret = &v1.Secret{ | ||
Type: v1.SecretTypeBasicAuth, | ||
Data: map[string][]byte{ | ||
v1.BasicAuthUsernameKey: []byte("username"), | ||
v1.BasicAuthPasswordKey: []byte("password"), | ||
}, | ||
} | ||
auth = getAuth(secret) | ||
assert.NotNil(t, auth) | ||
assert.Contains(t, auth.String(), "username") | ||
assert.Equal(t, "http-basic-auth", auth.Name()) | ||
|
||
// ssh auth | ||
secret = &v1.Secret{ | ||
Type: v1.SecretTypeSSHAuth, | ||
} | ||
auth = getAuth(secret) | ||
assert.NotNil(t, auth) | ||
assert.Equal(t, ssh.PublicKeysName, auth.Name()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// +build integration | ||
|
||
/* | ||
Copyright 2021 The KubeSphere Authors. | ||
|