LukeMathWalker / zero-to-production

Code for "Zero To Production In Rust", a book on API development using Rust.
https://www.zero2prod.com
Apache License 2.0
5.43k stars 470 forks source link

Clippy job in the pipeline can use sqlx Offline mode #223

Open 9SMTM6 opened 9 months ago

9SMTM6 commented 9 months ago

The clippy job, unless I missed something or did not get there yet, (currently chapter 7) doesn't require to use a live database. So it can be shortend (importantly also in execution time and resource usage) by removing everything but the checkout, the cache and then the linting task.

Its generally somewhat annoying to me how many tasks are repeated between the different jobs, but admittedly I also cant find an approach that does this better without tradeoffs (such as doing them only as steps in one task, or committing some image to an image repository, which requires more buy in into some container image repository such as github, and might leave behind a lot of garbage).

9SMTM6 commented 9 months ago

here is the job for clippy, worked up to chapter 7:

  # `clippy` container job
  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    container: ghcr.io/catthehacker/ubuntu:act-latest
    env:
      SQLX_OFFLINE: true
    steps:
      - uses: actions/checkout@v3
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2
        with:
          key: sqlx-${{ env.SQLX_VERSION }}
      - name: Linting
        run: cargo clippy -- -D warnings