Skip to content

Commit

Permalink
Use actions/cache again in metrics CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed May 15, 2024
1 parent 9bc6873 commit 34e4bcd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,24 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Restore cargo cache
uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609
- name: Cache cargo
uses: actions/cache@v4
with:
shared-key: ${{ runner.os }}-cargo-metrics-${{ github.sha }}
cache-targets: "false"
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ github.sha }}

- name: Collect build metrics
run: cargo xtask metrics build

- name: Cache target
uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609
uses: actions/cache@v4
with:
shared-key: ${{ runner.os }}-cargo-metrics-${{ github.sha }}
cache-targets: "true"
path: target/
key: ${{ runner.os }}-target-${{ github.sha }}

- name: Upload build metrics
uses: actions/upload-artifact@v4
Expand All @@ -64,11 +68,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Restore cargo cache
uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609
- name: Restore target cache
uses: actions/cache@v4
with:
shared-key: ${{ runner.os }}-cargo-metrics-${{ github.sha }}
cache-targets: "true"
path: target/
key: ${{ runner.os }}-target-${{ github.sha }}

- name: Collect metrics
run: cargo xtask metrics "${{ matrix.names }}"
Expand Down
3 changes: 2 additions & 1 deletion xtask/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl flags::Metrics {
pub(crate) fn run(self, sh: &Shell) -> anyhow::Result<()> {
let mut metrics = Metrics::new(sh)?;
if !Path::new("./target/rustc-perf").exists() {
sh.create_dir("./target/rustc-perf")?;
sh.create_dir("./target/rustc-perf/.git")?;
cmd!(sh, "git clone https://github.com/rust-lang/rustc-perf.git ./target/rustc-perf")
.run()?;
}
Expand Down Expand Up @@ -192,6 +192,7 @@ impl Metrics {

impl Host {
fn new(sh: &Shell) -> anyhow::Result<Host> {

Check failure on line 194 in xtask/src/metrics.rs

View workflow job for this annotation

GitHub Actions / Rust (ubuntu-latest)

unused variable: `sh`
return Ok(Host { os: String::new(), cpu: String::new(), mem: String::new() });
if cfg!(not(target_os = "linux")) {

Check failure on line 196 in xtask/src/metrics.rs

View workflow job for this annotation

GitHub Actions / Rust (ubuntu-latest)

unreachable statement
bail!("can only collect metrics on Linux ");
}
Expand Down

0 comments on commit 34e4bcd

Please sign in to comment.