Skip to content

Commit e9ec976

Browse files
committed
Merge branch 'main' into truman/app-onboarding
2 parents aea7612 + 5e155d6 commit e9ec976

863 files changed

Lines changed: 59648 additions & 16687 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/check-rust.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66

77
env:
88
CARGO_TERM_COLOR: always
9+
CARGO_INCREMENTAL: 0
910
SQLX_OFFLINE: true
1011

1112
jobs:

‎.github/workflows/daedalus-docker.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ jobs:
101101
~/.cargo/bin
102102
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}
103103

104+
- name: Ensure sccache directory exists
105+
if: needs.skip-if-clean.outputs.internal == 'true'
106+
run: sudo mkdir -p /mnt/sccache && sudo chown $(id -u):$(id -g) /mnt/sccache
107+
104108
- name: Mount sccache disk cache
105109
if: needs.skip-if-clean.outputs.internal == 'true'
106110
uses: useblacksmith/stickydisk@13af8883542ca949a717e70fef89d15edbb29d88 # v1.2.0

‎.github/workflows/frontend-deploy.yml‎

Lines changed: 75 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ on:
1616
workflow_dispatch:
1717
workflow_call:
1818
inputs:
19-
environment:
20-
required: true
21-
type: string
22-
description: 'The environment to deploy to (staging-preview or production-preview)'
19+
preview:
20+
required: false
21+
type: boolean
22+
description: 'Whether this is a preview deployment'
2323
head_sha:
2424
required: false
2525
type: string
@@ -28,9 +28,13 @@ on:
2828
required: false
2929
type: string
3030
description: 'The branch name to deploy (defaults to github.ref_name)'
31+
branch_alias:
32+
required: false
33+
type: string
34+
description: 'The persistent preview alias for the branch'
3135

3236
concurrency:
33-
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.environment || 'push' }}
37+
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.preview && 'preview' || 'push' }}
3438
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/prod' }}
3539

3640
jobs:
@@ -49,23 +53,31 @@ jobs:
4953
- name: Configure environment
5054
id: meta
5155
env:
52-
ENV_INPUT: ${{ inputs.environment }}
56+
PREVIEW_INPUT: ${{ inputs.preview }}
5357
REF: ${{ github.ref }}
5458
DEPLOY_SHA: ${{ inputs.head_sha || github.sha }}
59+
BRANCH_ALIAS: ${{ inputs.branch_alias }}
5560
run: |
5661
echo "cmd=deploy" >> $GITHUB_OUTPUT
5762
5863
SHA_SHORT="${DEPLOY_SHA::8}"
5964
60-
if [ "$ENV_INPUT" = "staging-preview" ]; then
61-
echo "env=staging" >> $GITHUB_OUTPUT
62-
echo "url=https://git-$SHA_SHORT-frontend-staging.modrinth.workers.dev" >> $GITHUB_OUTPUT
63-
echo "cmd=versions upload --preview-alias git-$SHA_SHORT --var PREVIEW:true" >> $GITHUB_OUTPUT
64-
65-
elif [ "$ENV_INPUT" = "production-preview" ]; then
65+
if [ "$PREVIEW_INPUT" = "true" ]; then
66+
URL="https://git-$SHA_SHORT-frontend.modrinth.workers.dev"
67+
STAGING_URL="https://git-$SHA_SHORT-staging-frontend.modrinth.workers.dev"
6668
echo "env=production" >> $GITHUB_OUTPUT
67-
echo "url=https://git-$SHA_SHORT-frontend.modrinth.workers.dev" >> $GITHUB_OUTPUT
68-
echo "cmd=versions upload --preview-alias git-$SHA_SHORT --var PREVIEW:true" >> $GITHUB_OUTPUT
69+
echo "url=$URL" >> $GITHUB_OUTPUT
70+
echo "staging_url=$STAGING_URL" >> $GITHUB_OUTPUT
71+
echo "cmd=versions upload --preview-alias git-$SHA_SHORT --var PREVIEW:true --var CF_PAGES_URL:$URL" >> $GITHUB_OUTPUT
72+
73+
STAGING_VARS=$(jq -r '.env.staging.vars | to_entries[] | "--var \(.key):\(.value)"' ./apps/frontend/wrangler.jsonc | tr '\n' ' ')
74+
echo "staging_cmd=versions upload --preview-alias git-$SHA_SHORT-staging ${STAGING_VARS}--var PREVIEW:true --var CF_PAGES_URL:$STAGING_URL" >> $GITHUB_OUTPUT
75+
76+
if [ -n "$BRANCH_ALIAS" ]; then
77+
echo "branch_alias_url=https://$BRANCH_ALIAS-frontend.modrinth.workers.dev" >> $GITHUB_OUTPUT
78+
echo "staging_branch_alias_url=https://$BRANCH_ALIAS-staging-frontend.modrinth.workers.dev" >> $GITHUB_OUTPUT
79+
echo "staging_branch_alias_cmd=versions upload --preview-alias $BRANCH_ALIAS-staging ${STAGING_VARS}--var PREVIEW:true --var CF_PAGES_URL:https://$BRANCH_ALIAS-staging-frontend.modrinth.workers.dev" >> $GITHUB_OUTPUT
80+
fi
6981
7082
elif [ "$REF" = "refs/heads/main" ]; then
7183
echo "env=staging" >> $GITHUB_OUTPUT
@@ -120,7 +132,7 @@ jobs:
120132
CF_PAGES_COMMIT_SHA: ${{ inputs.head_sha || github.sha }}
121133
CF_PAGES_URL: ${{ steps.meta.outputs.url }}
122134
BUILD_ENV: ${{ steps.meta.outputs.env }}
123-
PREVIEW: ${{ inputs.environment != '' && 'true' || 'false' }}
135+
PREVIEW: ${{ inputs.preview && 'true' || 'false' }}
124136
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
125137

126138
- name: Create Sentry release and upload sourcemaps
@@ -146,6 +158,39 @@ jobs:
146158
wranglerVersion: '4.54.0'
147159
command: ${{ steps.meta.outputs.cmd }}
148160

161+
- name: Deploy staging Cloudflare Worker preview
162+
if: ${{ inputs.preview }}
163+
uses: cloudflare/wrangler-action@9acf94ace14e7dc412b076f2c5c20b8ce93c79cd # v3.15.0
164+
with:
165+
apiToken: ${{ secrets.CF_API_TOKEN }}
166+
accountId: ${{ secrets.CF_ACCOUNT_ID }}
167+
workingDirectory: ./apps/frontend
168+
packageManager: pnpm
169+
wranglerVersion: '4.54.0'
170+
command: ${{ steps.meta.outputs.staging_cmd }}
171+
172+
- name: Deploy persistent Cloudflare Worker preview
173+
if: ${{ inputs.preview && inputs.branch_alias != '' }}
174+
uses: cloudflare/wrangler-action@9acf94ace14e7dc412b076f2c5c20b8ce93c79cd # v3.15.0
175+
with:
176+
apiToken: ${{ secrets.CF_API_TOKEN }}
177+
accountId: ${{ secrets.CF_ACCOUNT_ID }}
178+
workingDirectory: ./apps/frontend
179+
packageManager: pnpm
180+
wranglerVersion: '4.54.0'
181+
command: versions upload --preview-alias ${{ inputs.branch_alias }} --var PREVIEW:true --var CF_PAGES_URL:${{ steps.meta.outputs.branch_alias_url }}
182+
183+
- name: Deploy persistent staging Cloudflare Worker preview
184+
if: ${{ inputs.preview && inputs.branch_alias != '' }}
185+
uses: cloudflare/wrangler-action@9acf94ace14e7dc412b076f2c5c20b8ce93c79cd # v3.15.0
186+
with:
187+
apiToken: ${{ secrets.CF_API_TOKEN }}
188+
accountId: ${{ secrets.CF_ACCOUNT_ID }}
189+
workingDirectory: ./apps/frontend
190+
packageManager: pnpm
191+
wranglerVersion: '4.54.0'
192+
command: ${{ steps.meta.outputs.staging_branch_alias_cmd }}
193+
149194
- name: Purge cache
150195
if: github.ref == 'refs/heads/prod'
151196
run: |
@@ -155,14 +200,22 @@ jobs:
155200
--data '{"hosts": ["modrinth.com", "www.modrinth.com", "staging.modrinth.com"]}' \
156201
https://api.cloudflare.com/client/v4/zones/e39df17b9c4ef44cbce2646346ee6d33/purge_cache
157202
158-
- name: Write deployment URL to file
159-
if: ${{ inputs.environment != '' }}
203+
- name: Write deployment URLs to files
204+
if: ${{ inputs.preview }}
160205
run: |
161-
echo "${{ steps.meta.outputs.url }}" > deployment-url-${{ inputs.environment }}.txt
206+
echo "${{ steps.meta.outputs.url }}" > deployment-url-production.txt
207+
echo "${{ steps.meta.outputs.staging_url }}" > deployment-url-staging.txt
208+
209+
- name: Upload production deployment URL
210+
if: ${{ inputs.preview }}
211+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
212+
with:
213+
name: deployment-url-production
214+
path: deployment-url-production.txt
162215

163-
- name: Upload deployment URL
164-
if: ${{ inputs.environment != '' }}
216+
- name: Upload staging deployment URL
217+
if: ${{ inputs.preview }}
165218
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
166219
with:
167-
name: deployment-url-${{ inputs.environment }}
168-
path: deployment-url-${{ inputs.environment }}.txt
220+
name: deployment-url-staging
221+
path: deployment-url-staging.txt

‎.github/workflows/frontend-preview.yml‎

Lines changed: 70 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,33 @@ on:
1212
- '.github/workflows/frontend-preview.yml'
1313

1414
jobs:
15+
metadata:
16+
if: github.repository_owner == 'modrinth' && github.event.pull_request.head.repo.full_name == github.repository
17+
runs-on: ubuntu-latest
18+
outputs:
19+
branch-alias: ${{ steps.meta.outputs.branch_alias }}
20+
steps:
21+
- name: Configure branch alias
22+
id: meta
23+
run: echo "branch_alias=pr-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
24+
1525
deploy:
1626
if: github.repository_owner == 'modrinth' && github.event.pull_request.head.repo.full_name == github.repository
27+
needs: metadata
1728
uses: ./.github/workflows/frontend-deploy.yml
1829
secrets: inherit
1930
concurrency:
20-
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.environment }}
31+
group: ${{ github.workflow }}-${{ github.ref }}-deploy
2132
cancel-in-progress: true
22-
strategy:
23-
matrix:
24-
environment: [staging-preview, production-preview]
2533
with:
26-
environment: ${{ matrix.environment }}
34+
preview: true
2735
head_sha: ${{ github.event.pull_request.head.sha }}
2836
head_ref: ${{ github.event.pull_request.head.ref }}
37+
branch_alias: ${{ needs.metadata.outputs.branch-alias }}
2938

3039
deploy-storybook:
3140
if: github.repository_owner == 'modrinth' && github.event.pull_request.head.repo.full_name == github.repository
41+
needs: metadata
3242
runs-on: blacksmith-2vcpu-ubuntu-2404
3343
concurrency:
3444
group: ${{ github.workflow }}-${{ github.ref }}-storybook
@@ -66,6 +76,8 @@ jobs:
6676

6777
- name: Build Storybook
6878
working-directory: ./packages/ui
79+
env:
80+
NODE_OPTIONS: --max-old-space-size=6144
6981
run: pnpm run build-storybook
7082

7183
- name: Configure short SHA
@@ -84,10 +96,26 @@ jobs:
8496
wranglerVersion: '4.54.0'
8597
command: versions upload --preview-alias git-${{ steps.meta.outputs.sha_short }}
8698

99+
- name: Deploy persistent Storybook preview
100+
uses: cloudflare/wrangler-action@9acf94ace14e7dc412b076f2c5c20b8ce93c79cd # v3.15.0
101+
env:
102+
NODE_OPTIONS: --max-old-space-size=6144
103+
with:
104+
apiToken: ${{ secrets.CF_API_TOKEN }}
105+
accountId: ${{ secrets.CF_ACCOUNT_ID }}
106+
workingDirectory: ./packages/ui
107+
packageManager: pnpm
108+
wranglerVersion: '4.54.0'
109+
command: versions upload --preview-alias ${{ needs.metadata.outputs.branch-alias }}
110+
87111
comment:
88-
if: github.repository_owner == 'modrinth' && github.event.pull_request.head.repo.full_name == github.repository
112+
if: |
113+
!cancelled()
114+
&& github.repository_owner == 'modrinth'
115+
&& github.event.pull_request.head.repo.full_name == github.repository
116+
&& needs.deploy.result == 'success'
89117
runs-on: ubuntu-latest
90-
needs: [deploy, deploy-storybook]
118+
needs: [metadata, deploy, deploy-storybook]
91119
steps:
92120
- name: Download deployment URLs
93121
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
@@ -99,16 +127,29 @@ jobs:
99127
id: urls
100128
env:
101129
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
130+
BRANCH_ALIAS: ${{ needs.metadata.outputs.branch-alias }}
131+
STORYBOOK_RESULT: ${{ needs.deploy-storybook.result }}
132+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
102133
run: |
103-
STAGING_PREVIEW_URL=$(cat deployment-url-staging-preview.txt)
104-
PRODUCTION_PREVIEW_URL=$(cat deployment-url-production-preview.txt)
105-
106-
echo "Production preview URL: $PRODUCTION_PREVIEW_URL"
107-
echo "Staging preview URL: $STAGING_PREVIEW_URL"
108-
109-
echo "staging-preview-url=$STAGING_PREVIEW_URL" >> $GITHUB_OUTPUT
110-
echo "production-preview-url=$PRODUCTION_PREVIEW_URL" >> $GITHUB_OUTPUT
111-
echo "storybook-preview-url=https://git-${HEAD_SHA::8}-storybook.modrinth.workers.dev" >> $GITHUB_OUTPUT
134+
STAGING_SHA_URL=$(cat deployment-url-staging.txt)
135+
PRODUCTION_SHA_URL=$(cat deployment-url-production.txt)
136+
STAGING_BRANCH_URL="https://$BRANCH_ALIAS-staging-frontend.modrinth.workers.dev"
137+
PRODUCTION_BRANCH_URL="https://$BRANCH_ALIAS-frontend.modrinth.workers.dev"
138+
139+
if [ "$STORYBOOK_RESULT" = "success" ]; then
140+
STORYBOOK_SHA_URL="https://git-${HEAD_SHA::8}-storybook.modrinth.workers.dev"
141+
STORYBOOK_BRANCH_URL="https://$BRANCH_ALIAS-storybook.modrinth.workers.dev"
142+
else
143+
STORYBOOK_SHA_URL="⚠️ Deployment $STORYBOOK_RESULT ([logs]($RUN_URL))"
144+
STORYBOOK_BRANCH_URL="⚠️ Deployment $STORYBOOK_RESULT ([logs]($RUN_URL))"
145+
fi
146+
147+
echo "staging-sha-url=$STAGING_SHA_URL" >> $GITHUB_OUTPUT
148+
echo "production-sha-url=$PRODUCTION_SHA_URL" >> $GITHUB_OUTPUT
149+
echo "storybook-sha-url=$STORYBOOK_SHA_URL" >> $GITHUB_OUTPUT
150+
echo "staging-branch-url=$STAGING_BRANCH_URL" >> $GITHUB_OUTPUT
151+
echo "production-branch-url=$PRODUCTION_BRANCH_URL" >> $GITHUB_OUTPUT
152+
echo "storybook-branch-url=$STORYBOOK_BRANCH_URL" >> $GITHUB_OUTPUT
112153
113154
- name: Find comment
114155
if: github.event_name == 'pull_request'
@@ -131,9 +172,19 @@ jobs:
131172
132173
Last deployed commit is [${{ github.event.pull_request.head.sha }}](${{ github.event.pull_request.head.repo.html_url }}/commit/${{ github.event.pull_request.head.sha }})
133174
175+
### Persistent
176+
177+
| Environment | URL |
178+
|-------------|-----|
179+
| staging | ${{ steps.urls.outputs.staging-branch-url }} |
180+
| production | ${{ steps.urls.outputs.production-branch-url }} |
181+
| storybook | ${{ steps.urls.outputs.storybook-branch-url }} |
182+
183+
### Latest commit
184+
134185
| Environment | URL |
135186
|-------------|-----|
136-
| staging | ${{ steps.urls.outputs.staging-preview-url }} |
137-
| production | ${{ steps.urls.outputs.production-preview-url }} |
138-
| storybook | ${{ steps.urls.outputs.storybook-preview-url }} |
187+
| staging | ${{ steps.urls.outputs.staging-sha-url }} |
188+
| production | ${{ steps.urls.outputs.production-sha-url }} |
189+
| storybook | ${{ steps.urls.outputs.storybook-sha-url }} |
139190
edit-mode: replace

‎.github/workflows/labrinth-docker.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ jobs:
109109
~/.cargo/bin
110110
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}
111111

112+
- name: Ensure sccache directory exists
113+
if: needs.skip-if-clean.outputs.internal == 'true'
114+
run: sudo mkdir -p /mnt/sccache && sudo chown $(id -u):$(id -g) /mnt/sccache
115+
112116
- name: Mount sccache disk cache
113117
if: needs.skip-if-clean.outputs.internal == 'true'
114118
uses: useblacksmith/stickydisk@13af8883542ca949a717e70fef89d15edbb29d88 # v1.2.0

‎.github/workflows/turbo-ci.yml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ jobs:
8282
SCCACHE_DIR: ${{ needs.skip-if-clean.outputs.internal == 'true' && '/mnt/sccache' || '' }}
8383
SCCACHE_CACHE_SIZE: ${{ needs.skip-if-clean.outputs.internal == 'true' && '10G' || '' }}
8484
RUSTC_WRAPPER: ${{ needs.skip-if-clean.outputs.internal == 'true' && 'sccache' || '' }}
85+
CARGO_INCREMENTAL: 0
86+
# Redis config for tests
87+
REDIS_TOPOLOGY: cluster
88+
REDIS_CONNECTION_TYPE: multiplexed
89+
REDIS_URL: redis://127.0.0.1:7000,redis://127.0.0.1:7001,redis://127.0.0.1:7002,redis://127.0.0.1:7003,redis://127.0.0.1:7004,redis://127.0.0.1:7005
90+
# Avoid stack overflows in tests
91+
RUST_MIN_STACK: 16777216
8592

8693
steps:
8794
- name: Check out code
@@ -185,7 +192,7 @@ jobs:
185192
186193
- name: Start services
187194
if: steps.check-labrinth.outputs.needs_services == 'true'
188-
run: docker compose up --wait
195+
run: docker compose --profile clustered-redis up --wait
189196

190197
- name: Setup labrinth environment and database
191198
if: steps.check-labrinth.outputs.needs_services == 'true'

0 commit comments

Comments
 (0)