Skip to content

Commit d6cbec7

Browse files
duedares-rvjdependabot[bot]developerkunal
authored
chore: rebase main (#1566)
* chore(deps): bump github.com/auth0/go-auth0/v2 from 2.13.0 to 2.14.0 (#1563) Bumps [github.com/auth0/go-auth0/v2](https://github.com/auth0/go-auth0) from 2.13.0 to 2.14.0. - [Release notes](https://github.com/auth0/go-auth0/releases) - [Changelog](https://github.com/auth0/go-auth0/blob/main/CHANGELOG.md) - [Commits](auth0/go-auth0@v2.13.0...v2.14.0) --- updated-dependencies: - dependency-name: github.com/auth0/go-auth0/v2 dependency-version: 2.14.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Chore: Updated CI workflows to trigger releases based on branches (#1565) * Updated goreleaser condition for main and beta branches * Chore: Updated CI for main branch and Added CI for Beta * wf update * chore: Add Sentry DSN so crash reporting works in all builds (#1564) * Hardcode Sentry DSN so crash reporting works in all builds The Sentry DSN was injected at build time via ldflags from a SENTRY_DSN secret. That value has been empty in released binaries since around v1.10, so crash reporting has effectively been disabled, and it cannot work at all for from-source builds such as Homebrew Core. A Sentry DSN is a public, write-only key that is safe to ship inside client binaries, so this hardcodes it as the default. The build-time injection is removed from the release pipeline so every build path (releases, Homebrew Core, and plain go build) reports to Sentry consistently. * Skip Sentry reporting for local/dev builds Reporting now keys off buildinfo.Version instead of the Sentry DSN. Local builds stamp the version as "dev" (and a plain go build leaves it empty), so ReportException returns early for those and panics re-panic with a real stack trace. Release and Homebrew Core builds carry a real version and continue to report. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Kunal Dawar <35455566+developerkunal@users.noreply.github.com>
1 parent a1f92c1 commit d6cbec7

9 files changed

Lines changed: 131 additions & 10 deletions

File tree

.github/workflows/main.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Main Workflow
33
on:
44
pull_request: {}
55
push:
6-
branches: [ "main" ]
6+
branches: [ "main", "beta" ]
77

88

99
concurrency:
@@ -65,7 +65,9 @@ jobs:
6565
needs: unit-tests
6666

6767
# Skip running if the PR is coming from a fork or is created by dependabot or snyk due to missing repo secrets.
68-
if: github.event.pull_request.head.repo.fork == false && (github.actor != 'dependabot[bot]' && github.actor != 'snyk-bot')
68+
# Only run on pushes to main or PRs targeting main.
69+
if: github.event.pull_request.head.repo.fork == false && (github.actor != 'dependabot[bot]' && github.actor != 'snyk-bot') &&
70+
(github.ref == 'refs/heads/main' || github.base_ref == 'main')
6971

7072
steps:
7173
- name: Check out the code

.github/workflows/release-beta.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Release Beta
2+
3+
on:
4+
push:
5+
tags:
6+
# Prerelease tags only, e.g. v1.2.3-beta.1. Stable releases such as
7+
# v1.2.3 are handled by release.yml.
8+
- "v[0-9]+.[0-9]+.[0-9]+-*"
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
goreleaser:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
19+
with:
20+
fetch-depth: 0 # This ensures all history and tags are fetched
21+
path: auth0-cli
22+
23+
- name: Set up Go
24+
uses: actions/setup-go@be3c94b385c4f180051c996d336f57a34c397495 # v3.6.1
25+
with:
26+
go-version-file: auth0-cli/go.mod
27+
check-latest: true
28+
29+
# GoReleaser automatically marks SemVer prerelease tags (those with a
30+
# "-suffix") as GitHub prereleases. Homebrew and Scoop PRs are
31+
# intentionally omitted so beta builds never reach package managers.
32+
- name: Run GoReleaser
33+
uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3 # pin@6.2.1
34+
with:
35+
version: "2.7.0"
36+
args: release --clean
37+
workdir: 'auth0-cli'
38+
env:
39+
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ name: Release
33
on:
44
push:
55
tags:
6-
- "v*"
6+
# Stable releases only, e.g. v1.2.3. Prerelease tags such as
7+
# v1.2.3-beta.1 are handled by release-beta.yml.
8+
- "v[0-9]+.[0-9]+.[0-9]+"
9+
710

811
permissions:
912
contents: write
@@ -32,7 +35,6 @@ jobs:
3235
workdir: 'auth0-cli'
3336
env:
3437
GITHUB_TOKEN: ${{ github.token }}
35-
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
3638

3739
# Homebrew Tap Process
3840
- name: Checkout Homebrew Tap Repo

.github/workflows/security.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Security
33
on:
44
pull_request: {}
55
push:
6-
branches: [ "main" ]
6+
branches: [ "main", "beta" ]
77
schedule:
88
- cron: "30 0 1,15 * *"
99

.goreleaser.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ builds:
1717
- -X 'github.com/auth0/auth0-cli/internal/buildinfo.Revision={{.Commit}}'
1818
- -X 'github.com/auth0/auth0-cli/internal/buildinfo.BuildUser=goreleaser'
1919
- -X 'github.com/auth0/auth0-cli/internal/buildinfo.BuildDate={{.Date}}'
20-
- -X 'github.com/auth0/auth0-cli/internal/instrumentation.SentryDSN={{.Env.SENTRY_DSN}}'
2120
archives:
2221
- name_template: '{{ .ProjectName }}_{{ .Version }}_{{ title .Os }}_{{ if eq .Arch "arm64" }}arm64{{ else }}x86_64{{ end }}'
2322
files:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/PuerkitoBio/rehttp v1.4.0
88
github.com/atotto/clipboard v0.1.4
99
github.com/auth0/go-auth0 v1.43.0
10-
github.com/auth0/go-auth0/v2 v2.13.0
10+
github.com/auth0/go-auth0/v2 v2.14.0
1111
github.com/briandowns/spinner v1.23.2
1212
github.com/charmbracelet/glamour v1.0.0
1313
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z
2222
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
2323
github.com/auth0/go-auth0 v1.43.0 h1:sbtJHqukY1esWqlvyRpwIZ/If1m4h8e24TW2UztMXtA=
2424
github.com/auth0/go-auth0 v1.43.0/go.mod h1:32sQB1uAn+99fJo6N819EniKq8h785p0ag0lMWhiTaE=
25-
github.com/auth0/go-auth0/v2 v2.13.0 h1:Lf1cPRypkb879mHin1GlGS6NtWkO47Efo0Bq2HIMez4=
26-
github.com/auth0/go-auth0/v2 v2.13.0/go.mod h1:Q/Y3VZVoI3sw87VyTPhx2TQL6Sq4Q/iCP67rW2gcn+M=
25+
github.com/auth0/go-auth0/v2 v2.14.0 h1:zDxwRHGAt6gLK/OG6wAkB5ScQEJ8WW/ex1EnJig8fFc=
26+
github.com/auth0/go-auth0/v2 v2.14.0/go.mod h1:Q/Y3VZVoI3sw87VyTPhx2TQL6Sq4Q/iCP67rW2gcn+M=
2727
github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0 h1:0NmehRCgyk5rljDQLKUO+cRJCnduDyn11+zGZIc9Z48=
2828
github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0/go.mod h1:6L7zgvqo0idzI7IO8de6ZC051AfXb5ipkIJ7bIA2tGA=
2929
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=

internal/instrumentation/instrumentation.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@ import (
55
"time"
66

77
"github.com/getsentry/sentry-go"
8+
9+
"github.com/auth0/auth0-cli/internal/buildinfo"
810
)
911

10-
var SentryDSN string
12+
// SentryDSN is the destination for crash reports. A Sentry DSN is a public,
13+
// write-only key that is safe to ship inside client binaries, so we hardcode a
14+
// default here. This ensures crash reporting works for builds that are not
15+
// produced by our release pipeline (for example Homebrew Core, which builds
16+
// from source and cannot inject build-time values). Release builds may still
17+
// override this via ldflags.
18+
var SentryDSN = "https://370df87d33df46cb90182dd80a50fdc4@o27592.ingest.sentry.io/5694458"
1119

1220
// ReportException is designed to be called once as the CLI exits. We're
1321
// purposefully initializing a client all the time given this context.
@@ -16,6 +24,15 @@ func ReportException(err error) bool {
1624
return false
1725
}
1826

27+
// Skip crash reporting for local/development builds so that dev-time panics
28+
// and errors are not shipped to Sentry. Release pipelines (goreleaser and
29+
// Homebrew Core) stamp a real semantic version via ldflags, whereas a local
30+
// `make build`/`make install` stamps "dev" and a plain `go build` leaves it
31+
// empty.
32+
if buildinfo.Version == "" || buildinfo.Version == "dev" {
33+
return false
34+
}
35+
1936
if err := sentry.Init(sentry.ClientOptions{Dsn: SentryDSN}); err != nil {
2037
return false
2138
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package instrumentation
2+
3+
import (
4+
"errors"
5+
"testing"
6+
7+
"github.com/stretchr/testify/assert"
8+
9+
"github.com/auth0/auth0-cli/internal/buildinfo"
10+
)
11+
12+
func TestReportException(t *testing.T) {
13+
tests := []struct {
14+
name string
15+
sentryDSN string
16+
version string
17+
want bool
18+
}{
19+
{
20+
name: "skips when Sentry DSN is empty",
21+
sentryDSN: "",
22+
version: "1.32.0",
23+
want: false,
24+
},
25+
{
26+
name: "skips for a plain go build with no version",
27+
sentryDSN: "https://public@o0.ingest.sentry.io/0",
28+
version: "",
29+
want: false,
30+
},
31+
{
32+
name: "skips for a local dev build",
33+
sentryDSN: "https://public@o0.ingest.sentry.io/0",
34+
version: "dev",
35+
want: false,
36+
},
37+
{
38+
name: "reports for a real release build",
39+
sentryDSN: "https://public@o0.ingest.sentry.io/0",
40+
version: "1.32.0",
41+
want: true,
42+
},
43+
}
44+
45+
originalDSN := SentryDSN
46+
originalVersion := buildinfo.Version
47+
t.Cleanup(func() {
48+
SentryDSN = originalDSN
49+
buildinfo.Version = originalVersion
50+
})
51+
52+
for _, test := range tests {
53+
t.Run(test.name, func(t *testing.T) {
54+
SentryDSN = test.sentryDSN
55+
buildinfo.Version = test.version
56+
57+
got := ReportException(errors.New("boom"))
58+
59+
assert.Equal(t, test.want, got)
60+
})
61+
}
62+
}

0 commit comments

Comments
 (0)