11name : metrics
22on :
33 push :
4- branches :
5- - master
4+ branches :
5+ - master
66
77env :
88 CARGO_INCREMENTAL : 0
@@ -11,20 +11,135 @@ env:
1111 RUSTUP_MAX_RETRIES : 10
1212
1313jobs :
14- metrics :
14+ setup_cargo :
1515 if : github.repository == 'rust-lang/rust-analyzer'
1616 runs-on : ubuntu-latest
17+ steps :
18+ - name : Install Rust toolchain
19+ run : |
20+ rustup update --no-self-update stable
21+ rustup component add rustfmt rust-src
22+ rustup default stable
23+ - name : Cache cargo
24+ uses : actions/cache@v3
25+ with :
26+ path : |
27+ ~/.cargo/bin/
28+ ~/.cargo/registry/index/
29+ ~/.cargo/registry/cache/
30+ ~/.cargo/git/db/
31+ key : ${{ runner.os }}-cargo-${{ github.sha }}
32+
33+ build_metrics :
34+ runs-on : ubuntu-latest
35+ needs : setup_cargo
36+
37+ steps :
38+ - name : Checkout repository
39+ uses : actions/checkout@v3
40+
41+ - name : Restore cargo cache
42+ uses : actions/cache@v3
43+ with :
44+ path : |
45+ ~/.cargo/bin/
46+ ~/.cargo/registry/index/
47+ ~/.cargo/registry/cache/
48+ ~/.cargo/git/db/
49+ key : ${{ runner.os }}-cargo-${{ github.sha }}
50+
51+ - name : Collect build metrics
52+ run : cargo xtask metrics build
53+
54+ - name : Cache target
55+ uses : actions/cache@v3
56+ with :
57+ path : target/
58+ key : ${{ runner.os }}-target-${{ github.sha }}
59+
60+ - name : Upload build metrics
61+ uses : actions/upload-artifact@v3
62+ with :
63+ name : build-${{ github.sha }}
64+ path : target/build.json
65+ if-no-files-found : error
66+
67+ other_metrics :
68+ strategy :
69+ matrix :
70+ names : [self, ripgrep, webrender, diesel]
71+ runs-on : ubuntu-latest
72+ needs : [setup_cargo, build_metrics]
73+
74+ steps :
75+ - name : Checkout repository
76+ uses : actions/checkout@v3
77+
78+ - name : Restore cargo cache
79+ uses : actions/cache@v3
80+ with :
81+ path : |
82+ ~/.cargo/bin/
83+ ~/.cargo/registry/index/
84+ ~/.cargo/registry/cache/
85+ ~/.cargo/git/db/
86+ key : ${{ runner.os }}-cargo-${{ github.sha }}
87+
88+ - name : Restore target cache
89+ uses : actions/cache@v3
90+ with :
91+ path : target/
92+ key : ${{ runner.os }}-target-${{ github.sha }}
1793
94+ - name : Collect metrics
95+ run : cargo xtask metrics ${{ matrix.names }}
96+
97+ - name : Upload metrics
98+ uses : actions/upload-artifact@v3
99+ with :
100+ name : ${{ matrix.names }}-${{ github.sha }}
101+ path : target/${{ matrix.names }}.json
102+ if-no-files-found : error
103+
104+ generate_final_metrics :
105+ runs-on : ubuntu-latest
106+ needs : [build_metrics, other_metrics]
18107 steps :
19- - name : Checkout repository
20- uses : actions/checkout@v3
21-
22- - name : Install Rust toolchain
23- run : |
24- rustup update --no-self-update stable
25- rustup component add rustfmt rust-src
26-
27- - name : Collect metrics
28- run : cargo xtask metrics
29- env :
30- METRICS_TOKEN : ${{ secrets.METRICS_TOKEN }}
108+ - name : Checkout repository
109+ uses : actions/checkout@v3
110+
111+ - name : Download build metrics
112+ uses : actions/download-artifact@v3
113+ with :
114+ name : build-${{ github.sha }}
115+
116+ - name : Download self metrics
117+ uses : actions/download-artifact@v3
118+ with :
119+ name : self-${{ github.sha }}
120+
121+ - name : Download ripgrep metrics
122+ uses : actions/download-artifact@v3
123+ with :
124+ name : ripgrep-${{ github.sha }}
125+
126+ - name : Download webrender metrics
127+ uses : actions/download-artifact@v3
128+ with :
129+ name : webrender-${{ github.sha }}
130+
131+ - name : Download diesel metrics
132+ uses : actions/download-artifact@v3
133+ with :
134+ name : diesel-${{ github.sha }}
135+
136+ - name : Combine json
137+ run : |
138+ git clone --depth 1 https://$METRICS_TOKEN@github.com/rust-analyzer/metrics.git
139+ jq -s ".[0] * .[1] * .[2] * .[3] * .[4]" build.json self.json ripgrep.json webrender.json diesel.json -c >> metrics/metrics.json
140+ cd metrics
141+ git add .
142+ git -c user.name=Bot -c user.email=dummy@example.com commit --message 📈
143+ git push origin master
144+ env :
145+ METRICS_TOKEN : ${{ secrets.METRICS_TOKEN }}
0 commit comments