diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6de4fd..c8af04e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,7 @@ env: GOOGLE_PROJECT_NUMBER: ${{ secrets.GOOGLE_PROJECT_NUMBER }} ROOT_COLLECTION_SUFFIX: ${{ secrets.ROOT_COLLECTION_SUFFIX }} ENVIRONMENT: ${{ secrets.ENVIRONMENT }} + JAEGER_URL: ${{ secrets.JAEGER_URL }} jobs: lint_and_test: @@ -28,8 +29,8 @@ jobs: runs-on: ${{ matrix.os }} timeout-minutes: 80 steps: - - uses: actions/checkout@v2 - - uses: google-github-actions/setup-gcloud@master + - uses: actions/checkout@v3 + - uses: google-github-actions/setup-gcloud@v0 with: project_id: ${{ secrets.GOOGLE_CLOUD_PROJECT }} service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} @@ -44,15 +45,23 @@ jobs: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.37.1 go get -u github.com/kisielk/errcheck go get -u golang.org/x/lint/golint - go get -u honnef.co/go/tools/cmd/staticcheck + go install honnef.co/go/tools/cmd/staticcheck@2021.1.2 go get -u github.com/axw/gocov/gocov go get -u github.com/securego/gosec/cmd/gosec go get -u github.com/ory/go-acc + go get golang.org/x/oauth2/internal + go get google.golang.org/grpc + go get google.golang.org/grpc/internal/transport go get -u github.com/client9/misspell/cmd/misspell go get -u github.com/gordonklaus/ineffassign go get github.com/fzipp/gocyclo go get github.com/stretchr/testify/assert@v1.7.0 go get github.com/ory/go-acc + go get contrib.go.opencensus.io/exporter/stackdriver@v0.13.6 + go get cloud.google.com/go/errorreporting + go get cloud.google.com/go/profiler + + - name: Run lint and test run: | staticcheck ./... diff --git a/go.sum b/go.sum index a7a895d..38c2b58 100644 --- a/go.sum +++ b/go.sum @@ -330,8 +330,6 @@ github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U= github.com/vektah/gqlparser/v2 v2.1.0 h1:uiKJ+T5HMGGQM2kRKQ8Pxw8+Zq9qhhZhz/lieYvCMns= github.com/vektah/gqlparser/v2 v2.1.0/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms= -github.com/vektah/gqlparser/v2 v2.2.0 h1:bAc3slekAAJW6sZTi07aGq0OrfaCjj4jxARAaC7g2EM= -github.com/vektah/gqlparser/v2 v2.2.0/go.mod h1:i3mQIGIrbK2PD1RrCeMTlVbkF2FJ6WkU1KJlJlC+3F4= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= diff --git a/server_utils.go b/server_utils.go index ad363db..558c6c1 100644 --- a/server_utils.go +++ b/server_utils.go @@ -29,7 +29,14 @@ func Sentry() error { if err != nil { return err } - return sentry.Init(sentry.ClientOptions{Dsn: dsn}) + environment, err := GetEnvVar(Environment) + if err != nil { + return err + } + return sentry.Init(sentry.ClientOptions{ + Dsn: dsn, + Environment: environment, + }) } // ListenAddress determines what port to listen on and falls back to a default diff --git a/server_utils_test.go b/server_utils_test.go index bcba7c2..9305bbd 100644 --- a/server_utils_test.go +++ b/server_utils_test.go @@ -32,9 +32,12 @@ func TestSentry(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + initialEnvironment := os.Getenv("ENVIRONMENT") + os.Setenv("ENVIRONMENT", "staging") if err := serverutils.Sentry(); (err != nil) != tt.wantErr { t.Errorf("Sentry() error = %v, wantErr %v", err, tt.wantErr) } + os.Setenv("ENVIRONMENT", initialEnvironment) }) } }