@@ -11,20 +11,234 @@ env:
11
11
RUSTUP_MAX_RETRIES : 10
12
12
13
13
jobs :
14
- metrics :
15
- if : github.repository == 'rust-lang/rust-analyzer'
14
+ setup_cargo :
16
15
runs-on : ubuntu-latest
16
+ steps :
17
+ - name : Install Rust toolchain
18
+ run : |
19
+ rustup update --no-self-update stable
20
+ rustup component add rustfmt rust-src
21
+ - name : Cache cargo
22
+ uses : actions/cache@v3
23
+ with :
24
+ path : |
25
+ ~/.cargo/bin/
26
+ ~/.cargo/registry/index/
27
+ ~/.cargo/registry/cache/
28
+ ~/.cargo/git/db/
29
+ key : ${{ runner.os }}-cargo-${{ github.sha }}
30
+
31
+ build_metrics :
32
+ runs-on : ubuntu-latest
33
+ needs : setup_cargo
17
34
18
35
steps :
19
36
- name : Checkout repository
20
37
uses : actions/checkout@v3
21
38
22
- - name : Install Rust toolchain
23
- run : |
24
- rustup update --no-self-update stable
25
- rustup component add rustfmt rust-src
39
+ - name : Restore cargo cache
40
+ uses : actions/cache@v3
41
+ with :
42
+ path : |
43
+ ~/.cargo/bin/
44
+ ~/.cargo/registry/index/
45
+ ~/.cargo/registry/cache/
46
+ ~/.cargo/git/db/
47
+ key : ${{ runner.os }}-cargo-${{ github.sha }}
48
+
49
+
50
+ - name : Collect build metrics
51
+ run : cargo xtask metrics build
52
+
53
+ - name : Cache target
54
+ uses : actions/cache@v3
55
+ with :
56
+ path : target/
57
+ key : ${{ runner.os }}-target-${{ github.sha }}
58
+
59
+ - name : Upload build metrics
60
+ uses : actions/upload-artifact@v3
61
+ with :
62
+ name : build-${{ github.sha }}
63
+ path : target/build.json
64
+ if-no-files-found : error
65
+
66
+ self_metrics :
67
+ runs-on : ubuntu-latest
68
+ needs : [setup_cargo, build_metrics]
69
+
70
+ steps :
71
+ - name : Checkout repository
72
+ uses : actions/checkout@v3
73
+
74
+ - name : Restore cargo cache
75
+ uses : actions/cache@v3
76
+ with :
77
+ path : |
78
+ ~/.cargo/bin/
79
+ ~/.cargo/registry/index/
80
+ ~/.cargo/registry/cache/
81
+ ~/.cargo/git/db/
82
+ key : ${{ runner.os }}-cargo-${{ github.sha }}
83
+
84
+ - name : Restore target cache
85
+ uses : actions/cache@v3
86
+ with :
87
+ path : target/
88
+ key : ${{ runner.os }}-target-${{ github.sha }}
26
89
27
- - name : Collect metrics
28
- run : cargo xtask metrics
29
- env :
30
- METRICS_TOKEN : ${{ secrets.METRICS_TOKEN }}
90
+ - name : Collect build metrics
91
+ run : cargo xtask metrics self
92
+
93
+ - name : Upload build metrics
94
+ uses : actions/upload-artifact@v3
95
+ with :
96
+ name : self-${{ github.sha }}
97
+ path : target/self.json
98
+ if-no-files-found : error
99
+
100
+ ripgrep_metrics :
101
+ runs-on : ubuntu-latest
102
+ needs : [setup_cargo, build_metrics]
103
+
104
+ steps :
105
+ - name : Checkout repository
106
+ uses : actions/checkout@v3
107
+
108
+ - name : Restore cargo cache
109
+ uses : actions/cache@v3
110
+ with :
111
+ path : |
112
+ ~/.cargo/bin/
113
+ ~/.cargo/registry/index/
114
+ ~/.cargo/registry/cache/
115
+ ~/.cargo/git/db/
116
+ key : ${{ runner.os }}-cargo-${{ github.sha }}
117
+
118
+ - name : Restore target cache
119
+ uses : actions/cache@v3
120
+ with :
121
+ path : target/
122
+ key : ${{ runner.os }}-target-${{ github.sha }}
123
+
124
+ - name : Collect build metrics
125
+ run : cargo xtask metrics ripgrep
126
+
127
+ - name : Upload ripgrep metrics
128
+ uses : actions/upload-artifact@v3
129
+ with :
130
+ name : ripgrep-${{ github.sha }}
131
+ path : target/ripgrep.json
132
+ if-no-files-found : error
133
+
134
+ webrender_metrics :
135
+ runs-on : ubuntu-latest
136
+ needs : [setup_cargo, build_metrics]
137
+
138
+ steps :
139
+ - name : Checkout repository
140
+ uses : actions/checkout@v3
141
+
142
+ - name : Restore cargo cache
143
+ uses : actions/cache@v3
144
+ with :
145
+ path : |
146
+ ~/.cargo/bin/
147
+ ~/.cargo/registry/index/
148
+ ~/.cargo/registry/cache/
149
+ ~/.cargo/git/db/
150
+ key : ${{ runner.os }}-cargo-${{ github.sha }}
151
+
152
+ - name : Restore target cache
153
+ uses : actions/cache@v3
154
+ with :
155
+ path : target/
156
+ key : ${{ runner.os }}-target-${{ github.sha }}
157
+
158
+ - name : Collect webrender metrics
159
+ run : cargo xtask metrics webrender
160
+
161
+ - name : Upload webrender metrics
162
+ uses : actions/upload-artifact@v3
163
+ with :
164
+ name : webrender-${{ github.sha }}
165
+ path : target/webrender.json
166
+ if-no-files-found : error
167
+
168
+ diesel_metrics :
169
+ runs-on : ubuntu-latest
170
+ needs : [setup_cargo, build_metrics]
171
+
172
+ steps :
173
+ - name : Checkout repository
174
+ uses : actions/checkout@v3
175
+
176
+ - name : Restore cargo cache
177
+ uses : actions/cache@v3
178
+ with :
179
+ path : |
180
+ ~/.cargo/bin/
181
+ ~/.cargo/registry/index/
182
+ ~/.cargo/registry/cache/
183
+ ~/.cargo/git/db/
184
+ key : ${{ runner.os }}-cargo-${{ github.sha }}
185
+
186
+ - name : Restore target cache
187
+ uses : actions/cache@v3
188
+ with :
189
+ path : target/
190
+ key : ${{ runner.os }}-target-${{ github.sha }}
191
+
192
+ - name : Collect build metrics
193
+ run : cargo xtask metrics diesel
194
+
195
+ - name : Upload build metrics
196
+ uses : actions/upload-artifact@v3
197
+ with :
198
+ name : diesel-${{ github.sha }}
199
+ path : target/diesel.json
200
+ if-no-files-found : error
201
+
202
+
203
+
204
+ generate_final_metrics :
205
+ runs-on : ubuntu-latest
206
+ needs : [build_metrics, self_metrics, ripgrep_metrics, webrender_metrics, diesel_metrics]
207
+ steps :
208
+ - name : Checkout repository
209
+ uses : actions/checkout@v3
210
+
211
+ - name : Download build metrics
212
+ uses : actions/download-artifact@v3
213
+ with :
214
+ name : build-${{ github.sha }}
215
+
216
+ - name : Download self metrics
217
+ uses : actions/download-artifact@v3
218
+ with :
219
+ name : self-${{ github.sha }}
220
+
221
+ - name : Download ripgrep metrics
222
+ uses : actions/download-artifact@v3
223
+ with :
224
+ name : ripgrep-${{ github.sha }}
225
+
226
+ - name : Download webrender metrics
227
+ uses : actions/download-artifact@v3
228
+ with :
229
+ name : webrender-${{ github.sha }}
230
+
231
+ - name : Download diesel metrics
232
+ uses : actions/download-artifact@v3
233
+ with :
234
+ name : diesel-${{ github.sha }}
235
+
236
+ - name : Combine json
237
+ run : |
238
+ git clone --depth 1 https://$METRICS_TOKEN@github.com/nanthR/metrics.git
239
+ jq -s ".[0] * .[1] * .[2] * .[3] * .[4]" build.json self.json ripgrep.json webrender.json diesel.json -c >> metrics/metrics.json
240
+ git -C metrics add .
241
+ git -C metrics -c user.name=Bot -c user.email=dummy@example.com commit --message 📈
242
+ git -C metrics push origin master
243
+ env :
244
+ METRICS_TOKEN : ${{ secrets.METRICS_TOKEN }}
0 commit comments