Skip to content

Commit c0f0424

Browse files
committed
Use public repository for forks/repository with github secrets
1 parent 7a8a0a3 commit c0f0424

File tree

4 files changed

+56
-14
lines changed

4 files changed

+56
-14
lines changed

.github/workflows/pull_request.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
env:
5050
GITHUB_TOKEN: ${{ secrets.CLOUDBUILD_GITHUB_TOKEN || github.token }}
5151
SKIP_GCLOUD_TESTS: ${{ secrets.GCP_SA_KEY == '' && '1' || '' }}
52+
HAS_CLOUDBUILD_GITHUB_TOKEN: ${{ secrets.CLOUDBUILD_GITHUB_TOKEN && '1' || '' }}
5253
TEST_PKG: ./... # Run all tests
5354
run: make test
5455
- name: Set up testspaceTestspace

changelogutils/reader_test.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package changelogutils_test
22

33
import (
44
"context"
5+
"fmt"
56
"os"
67
"path/filepath"
78
"time"
@@ -27,8 +28,6 @@ var _ = Describe("ReaderTest", func() {
2728

2829
const (
2930
owner = "solo-io"
30-
repo = "testrepo"
31-
sha = "9065a9a84e286ea7f067f4fc240944b0a4d4c82a"
3231
)
3332

3433
var (
@@ -41,8 +40,22 @@ var _ = Describe("ReaderTest", func() {
4140
file = changelogutils.ChangelogFile{
4241
Entries: []*changelogutils.ChangelogEntry{&entry},
4342
}
43+
log = "1.yaml"
44+
repo = "testrepo"
45+
sha = "9065a9a84e286ea7f067f4fc240944b0a4d4c82a"
4446
)
4547

48+
if os.Getenv("HAS_CLOUDBUILD_GITHUB_TOKEN") == "" {
49+
log = "new-signature-manager.yaml"
50+
repo = "reporting-client"
51+
sha = "af5d207720ee6b548704b06bfa6631f9a2897294"
52+
entry = changelogutils.ChangelogEntry{
53+
Type: changelogutils.NEW_FEATURE,
54+
Description: "New signature manager implementation to be used in CLI clients that writes the signature to ~/.soloio",
55+
IssueLink: "https://github.com/solo-io/gloo/issues/1559",
56+
}
57+
}
58+
4659
BeforeEach(func() {
4760
client, err := githubutils.GetClient(ctx)
4861
Expect(err).NotTo(HaveOccurred())
@@ -51,7 +64,7 @@ var _ = Describe("ReaderTest", func() {
5164
})
5265

5366
It("can read changelog file", func() {
54-
changelogFile, err := reader.ReadChangelogFile(ctx, "changelog/v0.1.1/1.yaml")
67+
changelogFile, err := reader.ReadChangelogFile(ctx, fmt.Sprintf("changelog/v0.1.1/%s", log))
5568
Expect(err).NotTo(HaveOccurred())
5669
Expect(*changelogFile).To(BeEquivalentTo(file))
5770
})

githubutils/repo_client_test.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,26 @@ var _ = Describe("repo client utils", func() {
2424
repo = "testrepo"
2525
repoWithoutReleasesName = "testrepo-noreleases"
2626
sha = "9065a9a84e286ea7f067f4fc240944b0a4d4c82a"
27+
commitsInSha = 3
2728
otherSha = "ea649cd931820a6a59970b051d480094f9d61c4e"
2829
pr = 62
30+
commit1 = "6d389bc860e1cefdcbc99d43979e62104f13092f"
31+
commit2 = "9065a9a84e286ea7f067f4fc240944b0a4d4c82a"
32+
tagWithSha = "v0.1.16"
33+
shaForTag = "04da4a385be3fde4797963cd4f3f76a185e56ba7"
2934
)
3035

36+
if os.Getenv("HAS_CLOUDBUILD_GITHUB_TOKEN") == "" {
37+
repo = "reporting-client"
38+
repoWithoutReleasesName = "unik-hub"
39+
sha = "af5d207720ee6b548704b06bfa6631f9a2897294"
40+
commitsInSha = 2
41+
commit1 = "7ef898bc3df32db0e1ed2dee70a838c955a7b422"
42+
commit2 = "f47eacc21bd62e6bc8bb8954af0dc1817079af0d"
43+
tagWithSha = "v0.1.2"
44+
shaForTag = "a1c75ffaa40ea2b89368bfc338dc3f6f990b6df2"
45+
}
46+
3147
BeforeEach(func() {
3248
c, err := githubutils.GetClient(ctx)
3349
Expect(err).To(BeNil())
@@ -67,23 +83,23 @@ var _ = Describe("repo client utils", func() {
6783

6884
It("can do a commit comparison", func() {
6985
client = githubutils.NewRepoClient(githubClient, owner, repo)
70-
cc, err := client.CompareCommits(ctx, "6d389bc860e1cefdcbc99d43979e62104f13092f", "9065a9a84e286ea7f067f4fc240944b0a4d4c82a")
86+
cc, err := client.CompareCommits(ctx, commit1, commit2)
7187
Expect(err).To(BeNil())
7288
Expect(cc.Files).To(HaveLen(5))
7389
})
7490

7591
It("can get sha for tag", func() {
7692
client = githubutils.NewRepoClient(githubClient, owner, repo)
77-
sha, err := client.GetShaForTag(ctx, "v0.1.16")
93+
sha, err := client.GetShaForTag(ctx, tagWithSha)
7894
Expect(err).To(BeNil())
79-
Expect(sha).To(Equal("04da4a385be3fde4797963cd4f3f76a185e56ba7"))
95+
Expect(sha).To(Equal(shaForTag))
8096
})
8197

8298
It("can get a commit", func() {
8399
client = githubutils.NewRepoClient(githubClient, owner, repo)
84100
commit, err := client.GetCommit(ctx, sha)
85101
Expect(err).To(BeNil())
86-
Expect(len(commit.Files)).To(Equal(3))
102+
Expect(len(commit.Files)).To(Equal(commitsInSha))
87103
})
88104

89105
expectStatus := func(actual, expected *github.RepoStatus) {

vfsutils/mount_test.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package vfsutils_test
22

33
import (
44
"context"
5+
"os"
56

67
"github.com/solo-io/go-utils/githubutils"
78
"github.com/solo-io/go-utils/vfsutils"
@@ -14,29 +15,40 @@ var _ = Describe("mounted repo utils", func() {
1415

1516
const (
1617
owner = "solo-io"
17-
repo = "testrepo"
18-
sha = "9065a9a84e286ea7f067f4fc240944b0a4d4c82a"
1918
)
2019

2120
var (
22-
ctx = context.Background()
23-
mountedRepo vfsutils.MountedRepo
21+
ctx = context.Background()
22+
mountedRepo vfsutils.MountedRepo
23+
repo = "testrepo"
24+
sha = "9065a9a84e286ea7f067f4fc240944b0a4d4c82a"
25+
file = "tmp.txt"
26+
expectedContent = "another"
27+
path = "namespace"
2428
)
2529

30+
if os.Getenv("HAS_CLOUDBUILD_GITHUB_TOKEN") == "" {
31+
repo = "unik"
32+
sha = "767fb7285ea9c893efcced90a612c4e253ef8e4b"
33+
file = "README.md"
34+
expectedContent = "UniK"
35+
path = "containers/utils/vsphere-client/src/main/java/com/emc/unik"
36+
}
37+
2638
BeforeEach(func() {
2739
client, err := githubutils.GetClient(ctx)
2840
Expect(err).NotTo(HaveOccurred())
2941
mountedRepo = vfsutils.NewLazilyMountedRepo(client, owner, repo, sha)
3042
})
3143

3244
It("can get contents", func() {
33-
contents, err := mountedRepo.GetFileContents(ctx, "tmp.txt")
45+
contents, err := mountedRepo.GetFileContents(ctx, file)
3446
Expect(err).NotTo(HaveOccurred())
35-
Expect(string(contents)).To(ContainSubstring("another"))
47+
Expect(string(contents)).To(ContainSubstring(expectedContent))
3648
})
3749

3850
It("can list files", func() {
39-
files, err := mountedRepo.ListFiles(ctx, "namespace")
51+
files, err := mountedRepo.ListFiles(ctx, path)
4052
Expect(err).NotTo(HaveOccurred())
4153
Expect(len(files)).To(Equal(1))
4254
})

0 commit comments

Comments
 (0)