Skip to content

Commit f4ac242

Browse files
fix(uptime): in ci, generate and upload debug symbols to sentry, per project/org (#488)
Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent a455a9f commit f4ac242

File tree

4 files changed

+67
-3
lines changed

4 files changed

+67
-3
lines changed

.github/workflows/image.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,21 @@ jobs:
113113
google_ar_image_name: us-central1-docker.pkg.dev/sentryio/uptime-checker/image
114114
google_workload_identity_provider: projects/868781662168/locations/global/workloadIdentityPools/prod-github/providers/github-oidc-pool
115115
google_service_account: gha-gcr-push@sac-prod-sa.iam.gserviceaccount.com
116+
117+
- name: Extract debug symbols
118+
run: |
119+
docker build \
120+
--target debug-symbols \
121+
--build-arg UPTIME_CHECKER_GIT_REVISION=${{ github.sha }} \
122+
--output type=local,dest=./debug-out \
123+
-f Dockerfile .
124+
125+
- name: Install sentry-cli
126+
run: curl -sL https://sentry.io/get-cli/ | bash
127+
128+
- name: Upload debug symbols to Sentry
129+
run: scripts/upload-debug-symbols ./debug-out/uptime-checker.debug
130+
env:
131+
SENTRY_ORGS: ${{ secrets.SENTRY_ORGS }}
132+
SENTRY_PROJECTS: ${{ secrets.SENTRY_PROJECTS }}
133+
SENTRY_AUTH_TOKENS: ${{ secrets.SENTRY_AUTH_TOKENS }}

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ rdkafka = { git = "https://github.com/fede1024/rust-rdkafka" }
7474
# we're using the danf/hickory-dns-nameservers branch on the reqwest-uptime fork
7575

7676
[profile.release]
77+
debug = true
7778
lto = true
7879
codegen-units = 1
7980
panic = 'abort'
80-
strip = "debuginfo"
8181

8282
[dev-dependencies]
8383
redis-test-macro = { path = "./redis-test-macro" }

Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ RUN apk add --no-cache \
88
g++ \
99
pkgconfig \
1010
openssl-dev \
11-
protoc
11+
protoc \
12+
binutils
1213

1314
# Configure cargo
1415
RUN mkdir -p ~/.cargo && \
@@ -38,7 +39,16 @@ ENV UPTIME_CHECKER_GIT_REVISION=$UPTIME_CHECKER_GIT_REVISION
3839

3940
# Copy the actual source code and build
4041
COPY . .
41-
RUN cargo build --release
42+
43+
# Do the build, and then strip off debug info into a separate .debug file
44+
RUN cargo build --release && \
45+
objcopy --only-keep-debug target/release/uptime-checker target/release/uptime-checker.debug && \
46+
objcopy --strip-debug --strip-unneeded target/release/uptime-checker && \
47+
objcopy --add-gnu-debuglink target/release/uptime-checker.debug target/release/uptime-checker
48+
49+
# Stage for extracting debug symbols in CI
50+
FROM scratch AS debug-symbols
51+
COPY --from=builder /app/target/release/uptime-checker.debug /uptime-checker.debug
4252

4353
FROM alpine:3.22.1
4454

scripts/upload-debug-symbols

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Usage:
4+
# upload-debug-symbols <debug-file>
5+
6+
# Required environment variables (semicolon-delimited for multiple targets):
7+
# SENTRY_ORGS: e.g. "org1;org2"
8+
# SENTRY_PROJECTS: e.g. "proj1;proj2"
9+
# SENTRY_AUTH_TOKENS: e.g. "token1;token2"
10+
set -euo pipefail
11+
12+
DEBUG_FILE="${1:?Usage: $0 <debug-file>}"
13+
14+
if [ ! -f "$DEBUG_FILE" ]; then
15+
echo "Error: debug file not found: $DEBUG_FILE" >&2
16+
exit 1
17+
fi
18+
19+
IFS=';' read -ra ORGS <<< "${SENTRY_ORGS:?SENTRY_ORGS is required}"
20+
IFS=';' read -ra PROJECTS <<< "${SENTRY_PROJECTS:?SENTRY_PROJECTS is required}"
21+
IFS=';' read -ra TOKENS <<< "${SENTRY_AUTH_TOKENS:?SENTRY_AUTH_TOKENS is required}"
22+
23+
if [ ${#ORGS[@]} -ne ${#PROJECTS[@]} ] || [ ${#ORGS[@]} -ne ${#TOKENS[@]} ]; then
24+
echo "Error: SENTRY_ORGS, SENTRY_PROJECTS, and SENTRY_AUTH_TOKENS must have the same number of entries" >&2
25+
exit 1
26+
fi
27+
28+
for i in "${!ORGS[@]}"; do
29+
echo "Uploading debug symbols to ${ORGS[$i]}/${PROJECTS[$i]}..."
30+
SENTRY_ORG="${ORGS[$i]}" \
31+
SENTRY_PROJECT="${PROJECTS[$i]}" \
32+
SENTRY_AUTH_TOKEN="${TOKENS[$i]}" \
33+
sentry-cli debug-files upload "$DEBUG_FILE"
34+
done
35+
36+
echo "Done."

0 commit comments

Comments
 (0)