返回 DeepSeek-Reasonix
app-memory.yml
根目录 / .github / workflows / app-memory.yml
1 name: App memory screening
2
3 on:
4 pull_request:
5 branches: [main-v2]
6 push:
7 branches: [main-v2]
8 schedule:
9 - cron: "17 3 * * *"
10 workflow_dispatch:
11
12 permissions:
13 actions: read
14 contents: read
15
16 concurrency:
17 group: app-memory-${{ github.event.pull_request.number || github.ref }}
18 cancel-in-progress: true
19
20 env:
21 EXPECTED_SOURCE_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
22
23 jobs:
24 changes:
25 runs-on: ubuntu-22.04
26 outputs:
27 memory: ${{ steps.paths.outputs.memory }}
28 memory_profile: ${{ steps.profile.outputs.profile }}
29 memory_shards: ${{ steps.profile.outputs.shards }}
30 steps:
31 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
32 with:
33 ref: ${{ env.EXPECTED_SOURCE_SHA }}
34 fetch-depth: 0
35 - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
36 with:
37 node-version-file: .node-version
38 - id: paths
39 env:
40 BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
41 EVENT_NAME: ${{ github.event_name }}
42 run: |
43 args=(--head "$EXPECTED_SOURCE_SHA" --github-output "$GITHUB_OUTPUT" --summary "$GITHUB_STEP_SUMMARY")
44 if [ "$EVENT_NAME" = workflow_dispatch ] || [ "$EVENT_NAME" = schedule ]; then
45 args+=(--full)
46 elif [ "$EVENT_NAME" = pull_request ]; then
47 args+=(--base "$BASE_SHA" --mode pull_request)
48 else
49 args+=(--base "$BASE_SHA" --mode push)
50 fi
51 node scripts/ci-paths.mjs "${args[@]}"
52 - name: Select memory profile
53 id: profile
54 env:
55 EVENT_NAME: ${{ github.event_name }}
56 MEMORY: ${{ steps.paths.outputs.memory }}
57 MEMORY_FULL: ${{ steps.paths.outputs.memory_full }}
58 run: |
59 if [ "$MEMORY" != true ]; then
60 profile=off
61 shards='[1]'
62 elif [ "$EVENT_NAME" = pull_request ] && [ "$MEMORY_FULL" != true ]; then
63 profile=short
64 shards='[1]'
65 else
66 profile=full
67 shards='[1,2,3]'
68 fi
69 echo "profile=$profile" >> "$GITHUB_OUTPUT"
70 echo "shards=$shards" >> "$GITHUB_OUTPUT"
71 printf 'App memory profile: **%s**; shards: `%s`\n' "$profile" "$shards" >> "$GITHUB_STEP_SUMMARY"
72
73 prepare:
74 needs: changes
75 if: needs.changes.outputs.memory == 'true'
76 runs-on: ubuntu-22.04
77 timeout-minutes: 20
78 env:
79 REASONIX_APP_MEMORY_PROFILE: ${{ needs.changes.outputs.memory_profile }}
80 defaults:
81 run:
82 working-directory: desktop/frontend
83 steps:
84 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
85 with:
86 ref: ${{ env.EXPECTED_SOURCE_SHA }}
87 - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
88 with:
89 version: 10
90 run_install: false
91 - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
92 with:
93 node-version-file: .node-version
94 cache: pnpm
95 cache-dependency-path: desktop/pnpm-lock.yaml
96 - name: Install memory dependencies
97 run: pnpm install --frozen-lockfile
98 - run: node --test bench/app-memory-shards.test.mjs bench/app-memory-paths.test.mjs bench/app-memory-timing.test.mjs
99 - name: Build memory frontend
100 run: pnpm build
101 - run: node bench/app-memory-prepare.mjs "$RUNNER_TEMP/app-memory-build"
102 - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
103 with:
104 name: app-memory-build-${{ github.run_id }}
105 path: ${{ runner.temp }}/app-memory-build
106 overwrite: true
107 include-hidden-files: true
108 if-no-files-found: error
109 retention-days: 7
110
111 shard:
112 needs: [changes, prepare]
113 runs-on: ubuntu-22.04
114 timeout-minutes: 90
115 strategy:
116 fail-fast: false
117 matrix:
118 shard: ${{ fromJSON(needs.changes.outputs.memory_shards) }}
119 env:
120 REASONIX_APP_MEMORY_PROFILE: ${{ needs.changes.outputs.memory_profile }}
121 defaults:
122 run:
123 working-directory: desktop/frontend
124 steps:
125 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
126 with:
127 ref: ${{ env.EXPECTED_SOURCE_SHA }}
128 - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
129 with:
130 version: 10
131 run_install: false
132 - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
133 with:
134 node-version-file: .node-version
135 cache: pnpm
136 cache-dependency-path: desktop/pnpm-lock.yaml
137 - name: Install memory dependencies
138 run: pnpm install --frozen-lockfile
139 - name: Install browser runtimes
140 run: pnpm exec playwright install --with-deps chromium
141 - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
142 with:
143 name: app-memory-build-${{ github.run_id }}
144 path: ${{ runner.temp }}/app-memory-build
145 - run: cp -a "$RUNNER_TEMP/app-memory-build/dist/." dist/
146 - name: Run complete independent memory process
147 env:
148 REASONIX_APP_MEMORY_SHARD: ${{ matrix.shard }}
149 REASONIX_APP_MEMORY_PREPARED: ${{ runner.temp }}/app-memory-build/identity.json
150 REASONIX_APP_MEMORY_ARTIFACTS: ${{ runner.temp }}/app-memory-results
151 PLAYWRIGHT_BROWSERS_PATH: /home/runner/.cache/ms-playwright
152 run: node bench/app-memory.mjs
153 - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
154 if: always()
155 with:
156 name: app-memory-shard-${{ matrix.shard }}-${{ github.run_id }}
157 path: ${{ runner.temp }}/app-memory-results
158 overwrite: true
159 if-no-files-found: error
160 retention-days: 7
161
162 app-memory:
163 if: always()
164 needs: [changes, prepare, shard]
165 runs-on: ubuntu-22.04
166 steps:
167 - name: Verify all prerequisite jobs
168 env:
169 CHANGES_RESULT: ${{ needs.changes.result }}
170 SHOULD_RUN: ${{ needs.changes.outputs.memory }}
171 PREPARE_RESULT: ${{ needs.prepare.result }}
172 SHARD_RESULT: ${{ needs.shard.result }}
173 MEMORY_PROFILE: ${{ needs.changes.outputs.memory_profile }}
174 run: |
175 test "$CHANGES_RESULT" = success
176 if [ "$SHOULD_RUN" = true ]; then
177 test "$MEMORY_PROFILE" = short || test "$MEMORY_PROFILE" = full
178 test "$PREPARE_RESULT" = success
179 test "$SHARD_RESULT" = success
180 else
181 test "$SHOULD_RUN" = false
182 test "$MEMORY_PROFILE" = off
183 test "$PREPARE_RESULT" = skipped
184 test "$SHARD_RESULT" = skipped
185 fi
186 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
187 if: needs.changes.outputs.memory == 'true'
188 with:
189 ref: ${{ env.EXPECTED_SOURCE_SHA }}
190 - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7
191 if: needs.changes.outputs.memory == 'true'
192 with:
193 node-version-file: .node-version
194 - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
195 if: needs.changes.outputs.memory == 'true'
196 with:
197 pattern: app-memory-shard-*-${{ github.run_id }}
198 path: ${{ runner.temp }}/app-memory-reports
199 - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
200 if: needs.changes.outputs.memory == 'true'
201 with:
202 name: app-memory-build-${{ github.run_id }}
203 path: ${{ runner.temp }}/app-memory-build
204 - name: Verify same-build complete protocol
205 if: needs.changes.outputs.memory == 'true'
206 run: |
207 node desktop/frontend/bench/app-memory-aggregate.mjs \
208 "$RUNNER_TEMP/app-memory-reports" "$RUNNER_TEMP/app-memory-build/identity.json" \
209 "$RUNNER_TEMP/app-memory-report.json" "$EXPECTED_SOURCE_SHA"
210 - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
211 if: success() && needs.changes.outputs.memory == 'true'
212 with:
213 name: app-memory-aggregate-${{ github.run_id }}-${{ github.run_attempt }}
214 path: ${{ runner.temp }}/app-memory-report.json
215 if-no-files-found: error
216 retention-days: 7
217 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
218 if: always() && needs.changes.outputs.memory == 'true'
219 with:
220 ref: ${{ env.EXPECTED_SOURCE_SHA }}
221 path: .ci-metrics-source
222 - name: Summarize memory timing
223 if: always() && needs.changes.outputs.memory == 'true'
224 env:
225 GH_TOKEN: ${{ github.token }}
226 run: |
227 gh api "repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" > "$RUNNER_TEMP/memory-run.json"
228 gh api "repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/jobs?filter=latest&per_page=100" > "$RUNNER_TEMP/memory-jobs.json"
229 node .ci-metrics-source/scripts/ci-timings.mjs \
230 --run "$RUNNER_TEMP/memory-run.json" \
231 --jobs "$RUNNER_TEMP/memory-jobs.json" \
232 --summary "$GITHUB_STEP_SUMMARY" \
233 --title "App memory timing"
234
234 lines YAML