Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support sccache #33

Open
orf opened this issue Nov 23, 2024 · 1 comment
Open

Support sccache #33

orf opened this issue Nov 23, 2024 · 1 comment

Comments

@orf
Copy link

orf commented Nov 23, 2024

Hey! Awesome action <3

It would be amazing to support sccache with this action. It's possible right now, but fiddly: I've hacked it in with:

      # From https://github.com/mozilla/sccache/blob/main/docs/GHA.md
      - name: Configure sccache
        uses: actions/github-script@v7
        with:
          script: |
            core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
            core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

      - name: Run sccache-cache
        uses: mozilla-actions/[email protected]

      - name: Build binary
        uses: houseabsolute/actions-rust-cross@v0
        env:
          CROSS_CONFIG: "cross/Cross.sccache.toml"
          RUSTC_WRAPPER: "sccache"
        with:
          target: ${{ matrix.platform.target }}

With

[build.dockerfile]
file = "cross/cross.sccache.Dockerfile"

[build.env]
passthrough = [
    "SCCACHE_GHA_ENABLED",
    "ACTIONS_CACHE_URL",
    "ACTIONS_RUNTIME_TOKEN",
    "RUSTC_WRAPPER=sccache"
]

And the dockerfile:

ARG CROSS_BASE_IMAGE
FROM $CROSS_BASE_IMAGE
ARG DEBIAN_FRONTEND=noninteractive

COPY cross/sccache.sh /sccache.sh
RUN /sccache.sh x86_64-unknown-linux-musl

ENV RUSTC_WRAPPER="/usr/bin/sccache"

with the script from the cross wiki.

@autarch
Copy link
Member

autarch commented Nov 23, 2024

This seems like it'd be useful. Are you sure that you need the first bit? The docs for the sccache-action don't call this out, so I wonder if this is actually needed.

Also, I'm not clear on where that TOML snippet you shared goes. Is that in your Cargo.toml? If that's the case, can we set those variables via env vars instead? That way people wouldn't need to modify their Cargo.toml to take advantage of this. It'd be nice if this just worked transparently for folks (probably with an option to disable it).

And I think that instead of using that sccache.sh script we could use my ubi tool. It's a little annoying to use because on Linux x86-64 it tries to download the sccache-dist tarball instead of sccache, so you need to passing --match sccache-v to get it to pick the right thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants