Skip to content
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

feat: Fix sentry source maps #2186

Merged
merged 7 commits into from
Aug 16, 2023
Merged

feat: Fix sentry source maps #2186

merged 7 commits into from
Aug 16, 2023

Conversation

KaylaBrady
Copy link
Contributor

@KaylaBrady KaylaBrady commented Aug 15, 2023

ticket: https://app.asana.com/0/1152340551558956/1205212771706510/f

This is largely based on Glides' setup of releases https://github.com/mbta/glides/pull/936. There are some differences in this approach in order to limit the scope of this PR based on Skate's existing setup, but I'll call those out with specific comments.

Note: It seems that Sentry may be moving towards "Artifact Bundles" using debug IDs (see What are Artifact Bundles, debug ID as mandatory and releases as optional in Uploading Source Maps). I attempted to take that approach in kb-sentry-stack-fix but was not able to get it to work: debug_meta was not present on the error event JSON when it is expected based on the troubleshooting docs across a few variations of attempts. In favor of fixing the problem at hand, I've opted to stop pursuing the debug ID approach in favor of the working releases approach, but we may want to revisit that approach down the line!

following basic structure of Glides' approach in mbta/glides#936
This will prevent duplication of the new sentry logic across each deploy action. Based on Glides' deploy actions https://github.com/mbta/glides/tree/main/.github/workflows
@KaylaBrady KaylaBrady temporarily deployed to dev-blue August 15, 2023 18:00 — with GitHub Actions Inactive
@github-actions
Copy link

Coverage of commit 764c9ec

Summary coverage rate:
  lines......: 94.8% (2938 of 3100 lines)
  functions..: 74.5% (1221 of 1639 functions)
  branches...: no data found

Files changed coverage rate: n/a

Download coverage report

@github-actions
Copy link

Coverage of commit 764c9ec

Summary coverage rate:
  lines......: 94.8% (2938 of 3100 lines)
  functions..: 74.5% (1221 of 1639 functions)
  branches...: no data found

Files changed coverage rate: n/a

Download coverage report

concurrency:
group: dev-blue
cancel-in-progress: true
if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'deploy-to-dev-blue') }}
Copy link
Contributor Author

@KaylaBrady KaylaBrady Aug 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In copying Glides' approach to splitting deploy actions, this also adds support for deploying a PR with the deploy-to-[env] label. That is not directly related to the task at hand though and can be removed if desired. I did find it helpful for the purposes of testing this PR!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this refactor, thank you!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing I like about this: using labels for dev envs might mean we don't need to ask if a dev env is open, because we could filter PR's by labels, and any open PR's with these label's would be "occupying" the environment.

Like this! https://github.com/mbta/skate/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc+label%3Adeploy-to-dev-green%2Cdeploy-to-dev-blue

Comment on lines +48 to +54
- uses: mbta/actions/build-push-ecr@v1
id: build-push
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
docker-repo: ${{ secrets.DOCKER_REPO }}
docker-additional-args: --build-arg SENTRY_RELEASE=${{steps.version-ids.outputs.sentry-release}}
Copy link
Contributor Author

@KaylaBrady KaylaBrady Aug 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glides also adds the source maps as part of using this release action. I opted to continue uploading the source maps as part of the upload_assets step for simplicity of using the exiting Skate source map upload script.

SENTRY_RELEASE=$(npx @sentry/[email protected] releases propose-version)
npx @sentry/[email protected] releases files "$SENTRY_RELEASE" upload-sourcemaps "$STATIC_DIR/js"
SENTRY_RELEASE=${2-$(npx @sentry/[email protected] releases propose-version)}
npx @sentry/[email protected] releases files "$SENTRY_RELEASE" upload-sourcemaps "$STATIC_DIR/js" --url-prefix "~/${APP}/js"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --url-prefix was needed here because the abs_path of the error points to the hosted static files, so the path of the uploaded sourcemaps needs to match the path of those hosted static files.

- name: Get version ids
id: version-ids
run: |
echo "sentry-release=${{github.ref}}_${{github.sha}}" | tr / - >> "$GITHUB_OUTPUT"
Copy link
Contributor Author

@KaylaBrady KaylaBrady Aug 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glides uses the tag as the sentry version when deploying from prod. Since we typically don't do prod deploys from tags, opting to use the ref + sha for all deploys.

with:
environment: ${{ inputs.env }}
version: ${{steps.version-ids.outputs.sentry-release}}
set_commits: "skip"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we enable the sentry => github integration for Skate, then set_commits can be set to "auto". This can be done if desired as part of this PR, opted to "skip" for simplicity for now!

@KaylaBrady KaylaBrady temporarily deployed to dev-blue August 15, 2023 20:10 — with GitHub Actions Inactive
@KaylaBrady KaylaBrady changed the title feat: Tag sentry events with release feat: Fix sentry source maps Aug 15, 2023
@github-actions
Copy link

Coverage of commit 2e51387

Summary coverage rate:
  lines......: 94.8% (2938 of 3100 lines)
  functions..: 74.5% (1221 of 1639 functions)
  branches...: no data found

Files changed coverage rate: n/a

Download coverage report

Not sure if there will be unintended consequences of this change, and it is out of scope for solving the immediate issue at hand
@KaylaBrady KaylaBrady temporarily deployed to dev-blue August 15, 2023 20:26 — with GitHub Actions Inactive
@github-actions
Copy link

Coverage of commit b79a567

Summary coverage rate:
  lines......: 94.8% (2938 of 3100 lines)
  functions..: 74.5% (1221 of 1639 functions)
  branches...: no data found

Files changed coverage rate: n/a

Download coverage report

@KaylaBrady KaylaBrady temporarily deployed to dev-blue August 15, 2023 20:58 — with GitHub Actions Inactive
@github-actions
Copy link

Coverage of commit c4b4f43

Summary coverage rate:
  lines......: 94.8% (2938 of 3100 lines)
  functions..: 74.5% (1221 of 1639 functions)
  branches...: no data found

Files changed coverage rate: n/a

Download coverage report

@KaylaBrady KaylaBrady marked this pull request as ready for review August 15, 2023 21:11
@KaylaBrady KaylaBrady requested a review from a team August 15, 2023 21:11
@github-actions
Copy link

Coverage of commit 5de0561

Summary coverage rate:
  lines......: 94.8% (2938 of 3100 lines)
  functions..: 74.5% (1221 of 1639 functions)
  branches...: no data found

Files changed coverage rate: n/a

Download coverage report

@KaylaBrady KaylaBrady merged commit ccb185b into master Aug 16, 2023
7 of 8 checks passed
@firestack firestack deleted the kb-sentry-include-release branch March 4, 2024 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants