-
Notifications
You must be signed in to change notification settings - Fork 22
Fix PRs from forks #556
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
base: main
Are you sure you want to change the base?
Fix PRs from forks #556
Changes from all commits
3e485bd
94cca5f
8d45a93
d208a1f
b58acb5
2c931d2
0a79e97
94f3d49
e9413d1
b485c2c
3ef4ec5
efc3fe4
9ad010f
3e82777
504017f
de9d0bb
fba93b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,17 @@ | ||
| name: pull_request | ||
| name: Code format check | ||
| on: pull_request | ||
| jobs: | ||
| codegen: | ||
| name: Code format check | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - name: Cancel Previous Actions | ||
| uses: styfle/cancel-workflow-action@0.11.0 | ||
| uses: styfle/cancel-workflow-action@0.12.1 | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've upgraded each action as there doesn't appear to be any particular reason to use old actions |
||
| with: | ||
| access_token: ${{ github.token }} | ||
| - name: Free disk space | ||
| run: | | ||
| : Free disk space | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a fancy hack I've learned that makes reading GitHub action logs better |
||
| echo "Before clearing disk space:" | ||
| df -h | ||
|
|
||
|
|
@@ -27,11 +28,11 @@ jobs: | |
| echo "After clearing disk space:" | ||
| df -h | ||
| - name: Check out code into the Go module directory | ||
| uses: actions/checkout@v3 | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Set up Go | ||
| uses: actions/setup-go@v4 | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: "go.mod" | ||
| id: go | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| name: pull_request | ||
| name: Tests | ||
|
|
||
| on: | ||
| push: | ||
|
|
@@ -13,43 +13,51 @@ jobs: | |
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - name: Cancel Previous Runs | ||
| uses: styfle/cancel-workflow-action@0.11.0 | ||
| uses: styfle/cancel-workflow-action@0.12.1 | ||
| with: | ||
| access_token: ${{ github.token }} | ||
| - uses: actions/checkout@v3 | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: 3.8 | ||
| - uses: google-github-actions/setup-gcloud@a48b55b3b0eeaf77b6e1384aab737fbefe2085ac | ||
|
|
||
| - name: Gcloud login | ||
| if: ${{ env.has_auth }} | ||
| uses: google-github-actions/auth@v2 | ||
|
Comment on lines
-26
to
+29
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Google refactored their actions a long time ago so that the login step is done by this other action. |
||
| with: | ||
| version: '290.0.1' | ||
| project_id: ${{ secrets.GCP_PROJECT_ID }} | ||
| service_account_key: ${{ secrets.GCP_SA_KEY }} | ||
| export_default_credentials: true | ||
| name: Gcloud Login | ||
| credentials_json: ${{ secrets.GCP_SA_KEY }} | ||
| create_credentials_file: true | ||
| env: | ||
| has_auth: ${{ secrets.GCP_PROJECT_ID && secrets.GCP_SA_KEY && 1 }} | ||
|
Comment on lines
+28
to
+35
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In order to not try to auth when you don't have credentials, you have to bend over backwards because GitHub doesn't give you access to |
||
|
|
||
| - name: Install Trivy (latest) | ||
| run: | | ||
| : "Install Trivy (latest)" | ||
| TRIVY_VERSION=$(curl --silent "https://api.github.com/repos/aquasecurity/trivy/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/') | ||
| echo Using Trivy v${TRIVY_VERSION} | ||
| wget https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.deb | ||
| sudo dpkg -i trivy_${TRIVY_VERSION}_Linux-64bit.deb | ||
| - name: Set up Go | ||
| uses: actions/setup-go@v4 | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: "go.mod" | ||
| - name: Run tests | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.CLOUDBUILD_GITHUB_TOKEN }} | ||
| GITHUB_TOKEN: ${{ secrets.CLOUDBUILD_GITHUB_TOKEN || github.token }} | ||
|
Comment on lines
-45
to
+50
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This gives us at least some token in the pull request from fork (or in a pull request in a fork). |
||
| SKIP_GCLOUD_TESTS: ${{ secrets.GCP_SA_KEY == '' && '1' || '' }} | ||
| HAS_CLOUDBUILD_GITHUB_TOKEN: ${{ secrets.CLOUDBUILD_GITHUB_TOKEN && '1' || '' }} | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we don't have Gcloud / GitHub secrets, we need to know. |
||
| TEST_PKG: ./... # Run all tests | ||
| run: make test | ||
| - uses: testspace-com/setup-testspace@v1 | ||
| - name: Set up testspaceTestspace | ||
| uses: testspace-com/setup-testspace@v1 | ||
| with: | ||
| domain: solo-io.testspace.com | ||
| if: ${{ always() && github.event_name == 'push' && github.ref == 'refs/heads/master' }} | ||
| if: ${{ always() && github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository_owner == 'solo-io' }} | ||
| - name: Push result to Testspace server | ||
| run: | | ||
| testspace push --verbose "**/junit.xml" | ||
| if: ${{ always() && github.event_name == 'push' && github.ref == 'refs/heads/master' }} | ||
| if: ${{ always() && github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository_owner == 'solo-io' }} | ||
|
Comment on lines
+55
to
+63
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These steps are incredibly unlikely to work in forks, so let's save everyone's forks the cost of trying. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,7 @@ clean: ## Clean any local assets | |
|
|
||
| GINKGO_VERSION ?= $(shell echo $(shell go list -m github.com/onsi/ginkgo/v2) | cut -d' ' -f2) | ||
| GINKGO_ENV ?= GOLANG_PROTOBUF_REGISTRATION_CONFLICT=ignore ACK_GINKGO_DEPRECATIONS=$(GINKGO_VERSION) | ||
| GINKGO_FLAGS ?= -v -tags=purego -compilers=4 -fail-fast -race -randomize-suites -randomize-all -skip-package=./installutils/kubeinstall,./debugutils/test | ||
| GINKGO_FLAGS ?= -v -tags=purego -compilers=4 $(shell [ -z "${CI}" ] && echo '-fail-fast') -race -randomize-suites -randomize-all -skip-package=./installutils/kubeinstall,./debugutils/test | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It took me a lot of round trips to GitHub to find and fix all of the items here. It would have been much less painful if |
||
| GINKGO_REPORT_FLAGS ?= --json-report=test-report.json --junit-report=junit.xml -output-dir=$(OUTPUT_DIR) | ||
| GINKGO_COVERAGE_FLAGS ?= --cover --covermode=atomic --coverprofile=coverage.cov | ||
| TEST_PKG ?= ./... # Default to run all tests | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| changelog: | ||
| - type: DEPENDENCY_BUMP | ||
| dependencyOwner: actions | ||
| dependencyRepo: checkout | ||
| dependencyTag: v5 | ||
| description: "Use node 24" | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| - type: DEPENDENCY_BUMP | ||
| dependencyOwner: actions | ||
| dependencyRepo: setup-go | ||
| dependencyTag: v6 | ||
| description: "Use node 24" | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| - type: DEPENDENCY_BUMP | ||
| dependencyOwner: actions | ||
| dependencyRepo: setup-python | ||
| dependencyTag: v6 | ||
| description: "Use node 24" | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| - type: DEPENDENCY_BUMP | ||
| dependencyOwner: styfle | ||
| dependencyRepo: cancel-workflow-action | ||
| dependencyTag: 0.12.1 | ||
| description: "Bump to node20" | ||
| resolvesIssue: false | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| - type: NON_USER_FACING | ||
| dependencyOwner: google-github-actions | ||
| dependencyRepo: auth | ||
| dependencyTag: v2 | ||
| description: "Replace deprecated action flow" | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| - type: NON_USER_FACING | ||
| resolvesIssue: false | ||
| description: Show all failures in CI. | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| - type: NON_USER_FACING | ||
| resolvesIssue: false | ||
| description: Replace deprecated methods. | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| - type: NON_USER_FACING | ||
| resolvesIssue: false | ||
| description: Add name to testspace step. | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| - type: NON_USER_FACING | ||
| resolvesIssue: false | ||
| description: Add name to testspace step. | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| - type: NON_USER_FACING | ||
| resolvesIssue: false | ||
| description: Add pretty comments to workflows. | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| - type: NON_USER_FACING | ||
| resolvesIssue: false | ||
| description: Skip gcloud steps for forks without gcloud secrets. | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| - type: NON_USER_FACING | ||
| resolvesIssue: false | ||
| description: Skip testspace steps for forks. | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| - type: NON_USER_FACING | ||
| resolvesIssue: false | ||
| description: Skip write steps for forks without cloudbuild secrets. | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| - type: NON_USER_FACING | ||
| resolvesIssue: false | ||
| description: Use public repositories for tests for forks without github secrets. | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| - type: NON_USER_FACING | ||
| resolvesIssue: false | ||
| description: Use public repositories for tests. | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| - type: FIX | ||
| resolvesIssue: false | ||
| description: Fix running tests for forks. | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| - type: FIX | ||
| issueLink: https://github.com/solo-io/go-utils/pull/556 | ||
| description: Fixing handling of PRs from forks | ||
| resolvesIssue: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ import ( | |
| "bytes" | ||
| "context" | ||
| "fmt" | ||
| "io/ioutil" | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has been deprecated for ages and the version of golang used here supports the replacements. |
||
| "os" | ||
| "path/filepath" | ||
| "strings" | ||
|
|
@@ -415,7 +414,7 @@ closing | |
| ctx := context.Background() | ||
| client, err := githubutils.GetClient(ctx) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
| hasChangelog, err := changelogutils.RefHasChangelog(ctx, client, "solo-io", "testrepo", "master") | ||
| hasChangelog, err := changelogutils.RefHasChangelog(ctx, client, "solo-io", "reporting-client", "master") | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No one outside of solo-io has access to |
||
| Expect(err).NotTo(HaveOccurred()) | ||
| Expect(hasChangelog).To(BeTrue()) | ||
| }) | ||
|
|
@@ -508,7 +507,7 @@ func createSubdirs(dir string, names ...string) error { | |
| } | ||
|
|
||
| func mustWriteTestDir() string { | ||
| tmpDir, err := ioutil.TempDir("", "changelog-test-") | ||
| tmpDir, err := os.MkdirTemp("", "changelog-test-") | ||
| Expect(err).NotTo(HaveOccurred()) | ||
| return tmpDir | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ package changelogutils_test | |
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "os" | ||
| "path/filepath" | ||
| "time" | ||
|
|
@@ -27,8 +28,6 @@ var _ = Describe("ReaderTest", func() { | |
|
|
||
| const ( | ||
| owner = "solo-io" | ||
| repo = "testrepo" | ||
| sha = "9065a9a84e286ea7f067f4fc240944b0a4d4c82a" | ||
| ) | ||
|
|
||
| var ( | ||
|
|
@@ -41,8 +40,22 @@ var _ = Describe("ReaderTest", func() { | |
| file = changelogutils.ChangelogFile{ | ||
| Entries: []*changelogutils.ChangelogEntry{&entry}, | ||
| } | ||
| log = "1.yaml" | ||
| repo = "testrepo" | ||
| sha = "9065a9a84e286ea7f067f4fc240944b0a4d4c82a" | ||
|
Comment on lines
+43
to
+45
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, I'm letting the testrepo flavor continue to exist, although I'd be inclined to just use the public repositories entirely for the normal stuff and reserve if for the special cases. |
||
| ) | ||
|
|
||
| if os.Getenv("HAS_CLOUDBUILD_GITHUB_TOKEN") == "" { | ||
| log = "new-signature-manager.yaml" | ||
| repo = "reporting-client" | ||
| sha = "af5d207720ee6b548704b06bfa6631f9a2897294" | ||
| entry = changelogutils.ChangelogEntry{ | ||
| Type: changelogutils.NEW_FEATURE, | ||
| Description: "New signature manager implementation to be used in CLI clients that writes the signature to ~/.soloio", | ||
| IssueLink: "https://github.com/solo-io/gloo/issues/1559", | ||
| } | ||
| } | ||
|
Comment on lines
+48
to
+57
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the general logic for replacing the private repo structure bits with things that work for everyone who isn't a member of solo-io. |
||
|
|
||
| BeforeEach(func() { | ||
| client, err := githubutils.GetClient(ctx) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
@@ -51,7 +64,7 @@ var _ = Describe("ReaderTest", func() { | |
| }) | ||
|
|
||
| It("can read changelog file", func() { | ||
| changelogFile, err := reader.ReadChangelogFile(ctx, "changelog/v0.1.1/1.yaml") | ||
| changelogFile, err := reader.ReadChangelogFile(ctx, fmt.Sprintf("changelog/v0.1.1/%s", log)) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since I found a similar v0.1.1, I'm using Sprintf to select the filename -- I could have left the entire string in the variables above, but this seemed slightly easier to understand. (Apparently |
||
| Expect(err).NotTo(HaveOccurred()) | ||
| Expect(*changelogFile).To(BeEquivalentTo(file)) | ||
| }) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having two very unrelated workflows with the same name wasn't terribly helpful.