Skip to content

Commit 186f890

Browse files
feat(flutter): enable generic debug files upload to sentry (#439)
* use secrets * test * test * cleanup * testing * const org and project * make sentry org and project args * enable back sentry_dart_plugin, remove debug prints * fix: typo * chore: spelling
1 parent fd05409 commit 186f890

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

.config/dictionaries/project.dic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ metno
8888
mithril
8989
mkdocs
9090
modcache
91+
molinski
9192
mozallowfullscreen
9293
msedgedriver
9394
multilib

earthly/flutter/Earthfile

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -234,30 +234,51 @@ UNIT_TESTS:
234234
END
235235

236236
# Build web app and save artifacts locally if needed.
237+
# TODO(damian-molinski): This target should become BUILD_APP with platforms ARG.
238+
# platforms='web,android,ios'
239+
# Because `sentry_dart_plugin` requires access to .dart_tool as well as flutter itself
240+
# and using `sentry-cli` instead seems to not be worth effort.
237241
BUILD_WEB:
238242
FUNCTION
239243

240244
ARG --required TARGET
241245
ARG BUILD_MODE='--release'
246+
ARG --required BUILD_NAME
247+
ARG --required BUILD_NUMBER
242248
ARG SAVE_LOCALLY=false
243249
ARG WORKDIR
244-
ARG SENTRY_UPLOAD_DEBUG_SYMBOLS=false
245-
ARG BUILD_ARGS=''
250+
ARG UPLOAD_DEBUG_SYMBOLS=false
251+
ARG SENTRY_ORG
252+
ARG SENTRY_PROJECT
246253

247254
WORKDIR $WORKDIR
248255

249-
IF [ $SENTRY_UPLOAD_DEBUG_SYMBOLS = true ]
250-
IF [ ! echo "$BUILD_ARGS" | grep -q -- '--source-maps' ]
251-
ARG BUILD_ARGS='$BUILD_ARGS --source-maps'
252-
END
256+
LET ADDITIONAL_BUILD_ARGS = ""
257+
LET SENTRY_RELEASE = "$SENTRY_PROJECT@$BUILD_NAME+$BUILD_NUMBER"
258+
LET SENTRY_DIST = "$BUILD_NUMBER"
259+
260+
IF [ $UPLOAD_DEBUG_SYMBOLS = true ]
261+
SET ADDITIONAL_BUILD_ARGS = "--dart-define=SENTRY_RELEASE=$SENTRY_RELEASE $ADDITIONAL_BUILD_ARGS"
262+
SET ADDITIONAL_BUILD_ARGS = "--dart-define=SENTRY_DIST=$SENTRY_DIST $ADDITIONAL_BUILD_ARGS"
263+
SET ADDITIONAL_BUILD_ARGS = "$ADDITIONAL_BUILD_ARGS --source-maps"
253264
END
254265

255266
RUN flutter clean
256267
RUN flutter pub get
257-
RUN flutter build web $BUILD_MODE --pwa-strategy=none --target $TARGET --build-number=$(date +%s) $BUILD_ARGS
258-
259-
IF [ $SENTRY_UPLOAD_DEBUG_SYMBOLS = true ]
260-
RUN flutter pub run sentry_dart_plugin
268+
RUN flutter build web $BUILD_MODE \
269+
--pwa-strategy=none \
270+
--target $TARGET \
271+
--build-name=$BUILD_NAME \
272+
--build-number=$BUILD_NUMBER \
273+
$ADDITIONAL_BUILD_ARGS
274+
275+
IF [ $UPLOAD_DEBUG_SYMBOLS = true ]
276+
RUN --secret SENTRY_AUTH_TOKEN=SENTRY_AUTH_TOKEN \
277+
flutter pub run sentry_dart_plugin \
278+
--sentry-define=org=$SENTRY_ORG \
279+
--sentry-define=project=$SENTRY_PROJECT \
280+
--sentry-define=release=$SENTRY_RELEASE \
281+
--sentry-define=dist=$SENTRY_DIST
261282
END
262283

263284
WORKDIR "$WORKDIR/build"

0 commit comments

Comments
 (0)