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

[platf,react] fix double-upload of source maps, template-ize webpack config #423

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions bin/sentry-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Create release and upload sourcemaps to Sentry
# Must be run within project directory (e.g. './react/')

USAGE="Usage: ./sentry-release.sh ENV RELEASE"
USAGE="Usage: ./sentry-release.sh ENV RELEASE UPLOAD_SOURCEMAPS \
UPLOAD_SOURCEMAPS = false | true"

set -e # exit immediately if any command exits with a non-zero status

Expand All @@ -12,7 +13,8 @@ echo "$0: Creating release and uploading source maps with sentry-cli..."
# Parse and validate command-line arguments
env="$1"
release="$2"
if [[ "$env" == "" || "$release" == "" ]]; then
upload_sourcemaps="$3"
if [[ "$env" == "" || "$release" == "" || "$upload_sourcemaps" == "" ]]; then
echo "$0: [error] missing required command-line arguments."
echo $USAGE
exit 1
Expand All @@ -32,5 +34,7 @@ fi
sentry-cli releases -o $SENTRY_ORG new -p $sentry_project $release
sentry-cli releases -o $SENTRY_ORG finalize -p $sentry_project $release
sentry-cli releases -o $SENTRY_ORG -p $sentry_project set-commits --auto $release --ignore-missing
sentry-cli releases -o $SENTRY_ORG -p $sentry_project files $release upload-sourcemaps --url-prefix "$sourcemaps_url_prefix" --validate "$sourcemaps_dir"
if [ "$upload_sourcemaps" == "true" ]; then
sentry-cli releases -o $SENTRY_ORG -p $sentry_project files $release upload-sourcemaps --url-prefix "$sourcemaps_url_prefix" --validate "$sourcemaps_dir"
fi
sentry-cli deploys -o $SENTRY_ORG new -p $sentry_project -r $release -e $env -n $env
8 changes: 7 additions & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function cleanup {
rm -f $top/spring-boot/src/main/appengine/app.yaml
rm -f $top/spring-boot/src/main/resources/application.properties
rm -f $top/crons-python/crontab
rm -f $top/react/config-overrides.js
if [ "$generated_envs" != "" ]; then
rm -f $generated_envs # bash only (passed as separate args)
fi
Expand Down Expand Up @@ -165,7 +166,12 @@ for proj in $projects; do # bash only
./build.sh

if [[ "$fe_projects" = *"$proj "* ]]; then # project is frontend
sentry-release.sh $env $RELEASE
if [[ "$proj" == "react" ]]; then
upload_sourcemaps="false" # using webpack plugin
else
upload_sourcemaps="true"
fi
sentry-release.sh $env $RELEASE $upload_sourcemaps
# NOTE: Sentry may create releases from events even without this step
fi

Expand Down
2 changes: 1 addition & 1 deletion react/app.yaml.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

env: standard
service: <SERVICE>
runtime: nodejs16
runtime: nodejs18

handlers:
- url: /static
Expand Down
3 changes: 3 additions & 0 deletions react/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

set -e # exit immediately if any command exits with a non-zero status

envsubst < config-overrides.js.template > config-overrides.js

rm -rf build
# npm ci does not update minor versions ->
# (1) less chance of breaking (2) less noise in PR from package-lock.json
npm ci
npm run build # defined in 'scripts' in package.json

Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module.exports = function override(config, env) {
SentryWebpackPlugin.sentryWebpackPlugin({
authToken: process.env.SENTRY_AUTH_TOKEN,
include: '.',
org: 'demo',
project: 'react',
org: '${SENTRY_ORG}',
project: '${REACT_SENTRY_PROJECT}',
ignoreFile: '.sentrycliignore',
ignore: ['webpack.config.js'],
configFile: 'sentry.properties',
Expand Down
Loading
Loading