'Caching Rust/Wasm tools in Gitlab CI?

I'm working with Wasm and Rust, and I'm deploying the page with gitlab pages.

I'm using a gitlab-ci.yml file that looks like this:

image: "rust:latest"

variables:
  PUBLIC_URL: "/repo-name"

pages:
  stage: deploy
  script:
    - rustup target add wasm32-unknown-unknown
    - cargo install wasm-pack
    - wasm-pack build --target web
    - mkdir public
    - mv ./pkg ./public/pkg
    - cp ./index.html ./public/index.html
  artifacts:
    paths:
      - public

But even for a "Hello World" app, this takes ~12 minutes.

~11 minutes of that is taken by the cargo install wasm-pack step.

Is there any way I can cache the intermediate step, to avoid doing this every time?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source