Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

What does this get me? #72

Closed
dtolnay opened this issue May 2, 2020 · 3 comments
Closed

What does this get me? #72

dtolnay opened this issue May 2, 2020 · 3 comments

Comments

@dtolnay
Copy link

dtolnay commented May 2, 2020

This is my first time trying GitHub Actions, so apologies for the basic question.

I see that the example workflow in this repo's readme contains this example step:

- uses: actions-rs/cargo@v1
  with:
    command: build
    args: --release --all-features

Based on the readme of this repo it wasn't clear to me what benefit this would have over just:

- run: cargo build --release --all-features

which appears to work.

Maybe the readme could emphasize some of the benefits?

Thanks!

@svartalf
Copy link
Member

svartalf commented May 2, 2020

Hi, @dtolnay.

This is a totally legit and great question! You are right to assume that simple - run: step is not that different, here is what this Action does differently:

  1. It can call cross instead of cargo binary with use-cross: true flag passed and this allows you to construct such a build matrixes:
  compile:
    name: ${{ matrix.toolchain }} / ${{ matrix.triple.target }}
    runs-on: ${{ matrix.triple.os }}
    strategy:
      fail-fast: false
      matrix:
        triple:
          # Tier 1 platforms
          - { os: 'ubuntu-latest',  target: 'x86_64-unknown-linux-gnu', cross: false }
          - { os: 'ubuntu-latest',  target: 'i686-unknown-linux-gnu',   cross: true }
          - { os: 'macOS-latest',   target: 'x86_64-apple-darwin',      cross: false }
          - { os: 'windows-latest', target: 'x86_64-pc-windows-msvc',   cross: false }

          # Tier 2 platforms

          ## ARM64
          - { os: 'ubuntu-latest', target: 'aarch64-unknown-linux-gnu',  cross: true }
          - { os: 'ubuntu-latest', target: 'aarch64-unknown-linux-musl', cross: true }
          ## ARMv7
          - { os: 'ubuntu-latest', target: 'armv7-unknown-linux-gnueabihf',  cross: true }
          - { os: 'ubuntu-latest', target: 'armv7-unknown-linux-musleabihf', cross: true }
    steps:
      - uses: actions/checkout@v2
      - name: Install toolchain
        uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: ${{ matrix.toolchain }}
          override: true
      - uses: actions-rs/cargo@v1
        with:
          command: check
          args: --target=${{ matrix.triple.target }}
          use-cross: ${{ matrix.triple.cross }}
  1. It enables problem matcher for cargo messages. Basically, GitHub automatically runs specific regexp on each line of stdout/stderr and if there is a match, nifty annotation is created for it; in this execution you can see that clippy execution failed and in here a few rustc warnings can be found.

This Action was created just after the GitHub Actions became publicly available, and there was no clear vision on how should all that small actions-rs ecosystem behave; for example, actions-rs/components-nightly was deprecated because rustup can do that functionality better now, and there are plans to deprecate some other Actions too (actions-rs/tarpaulin is a first candidate).

So, at this point I'm inclined to agree that plain - run step looks much better in a most cases and does almost the same thing. I'll add it to the readme, thanks for pointing it out!

@svenstaro
Copy link

There should be an example featuring the complex usage you showed off here, @svartalf. Currently there are not even any examples that I can find that use macos or windows but I think there should be.

@piegamesde
Copy link

Is there a simple way to get the fancy error messages with a simple run step or is this truly exclusive to using a special action?

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

No branches or pull requests

4 participants