Home > Software design >  Am I misunderstand something? Unexpected behaviour in github actions
Am I misunderstand something? Unexpected behaviour in github actions

Time:03-15

So 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/') }}

Obviously 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 copypasted things I forgot to add setup rust action. But that step succesfully 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?

CodePudding user response:

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 extract setup to install them in that case.

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

  • Related