actions-rs / toolchain

🛠️ GitHub Action for `rustup` commands
https://github.com/marketplace/actions/rust-toolchain
MIT License
585 stars 86 forks source link

Use RUNNER_TEMP as TMPDIR #218

Open andrewthetechie opened 2 years ago

andrewthetechie commented 2 years ago

Motivation

On our selfhosted github actions runners, the action fails because we have /tmp mounted noexec, a security requirement.

To use rustup manually on the instance, we could use the TMPDIR env var to define an alternative temporary directory

TMPDIR=/opt/tmp rustup.sh

On a runner, there's an env var RUNNER_TEMP that is a temporary directory for this run. In workflow example, I show how we use this to work around our noexec setting on tmp.

It would be great if the workflow could just use RUNNER_TEMP by default. Setting the environment variable TMPDIR equal to RUNNER_TEMP should be enough to make this work automatically.

Workflow example

jobs:
  tests:
    name: Lint and test
    runs-on: [self-hosted]
    steps:
      - name: Check out the repository
        uses: actions/checkout@v3.0.2
      - name: Setup rust
        uses: actions-rs/toolchain@v1
        env:
          TMPDIR: ${{ runner.temp }}