name: sparse-registry

on: [push, pull_request]

jobs:
  sparse-registry:
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]

    name: Test `cargo check/test` with sparse registry on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}

    env:
      CARGO_TERM_COLOR: always
      CARGO_UNSTABLE_SPARSE_REGISTRY: true

    steps:
      - uses: actions/checkout@v3

      # When rustup is updated, it tries to replace its binary, which on Windows is somehow locked.
      # This can result in the CI failure, see: https://github.com/rust-lang/rustup/issues/3029
      - run: |
          rustup set auto-self-update disable
          rustup toolchain install nightly --profile minimal
          rustup default nightly

      - uses: ./
        with:
          workspaces: tests

      - run: |
          cargo check
          cargo test
        working-directory: tests
