Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can I run cargo in github actions without setting it up?

I have a GitHub workflow with job like this:

docker:
    name: Docker image
    needs: test-n-build
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: Set docker image tag
        if: startsWith(github.ref, 'refs/tags/')
        run: echo "DOCKER_TAG=:$(cargo read-manifest | sed 's/.*"version":"\{0,1\}\([^,"]*\)"\{0,1\}.*/\1/')" >> $GITHUB_ENV

      - name: Login to DockerHub
        uses: docker/login-action@v1

      - name: Build and push
        uses: docker/build-push-action@v2
        with:
          push: ${{ startsWith(github.ref, 'refs/tags/') }}

This workflow builds docker image and pushes it to registry if tag pushed to branch. As seen there are a Set docker image tag step with cargo command used, but when I'm copy-pasted things I forgot to add setup rust action. But that step successfully executed and no error like command cargo not found not appears.

Is it because that job needs test-n-build job where I actually setup Rust, or QEMU installs Rust? How it finds cargo command?

like image 420
ultram4rine Avatar asked Mar 05 '26 17:03

ultram4rine


1 Answers

As you can see on the Ubuntu-20.04 virtual environment, it is provided with some Rust Tools installed:

### Rust Tools
Cargo 1.58.0
Rust 1.58.1
Rustdoc 1.58.1
Rustup 1.24.3

Therefore, you wouldn't need any extra setup to install them in that case.

You can check the available virtual environment used as runners and their configurations here.

like image 192
GuiFalourd Avatar answered Mar 07 '26 09:03

GuiFalourd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!