rustc-tools 0.83.0

Some internal rustc tools made accessible
on:
  push:
    branches: [master]
  pull_request:

name: CI

# If a new push on the PR is done, cancel the build
concurrency: 
  group: ${{ github.head_ref }}
  cancel-in-progress: true

jobs:
  rustfmt:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: rustup show active-toolchain
      - run: cargo fmt -- --check

  clippy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: sed -i "s/rustfmt/clippy/" rust-toolchain
      - run: rustup show active-toolchain
      - run: cargo clippy --all-targets -- -D warnings

  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: rustup show active-toolchain
      - run: cargo check
      - run: cargo run --example ast -- asset/example_file.rs
      - run: cargo run --example hir -- asset/example_file.rs
      - run: cargo build --example lint
      - run: (cargo run --example lint -- asset/example_file.rs && exit 1) || exit 0

  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run tests
        run: |
          : # First we install `rustc-tools-inner`
          cd examples/with-cargo-integration/cargo-tools-inner
          cargo install --path .
          : # Then we install `rustc-tools`
          cd ../cargo-tools
          cargo install --path .
          : # We ensure that the lints are run.
          cargo tools 2>&1 | grep 'functions with odd number of lines should not exist'