user-idle-time 0.7.0

Get a user's idle time.
Documentation
name: Weekly beta compile test

on:
  schedule:
    - cron: "0 12 * * 1"
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    strategy:
      matrix:
        os: [windows-latest, ubuntu-latest, macos-latest]
    runs-on: ${{ matrix.os }}
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@beta
      - name: Install Linux dependencies
        uses: ./.github/actions/install-linux-dependencies
      - name: Build & run tests
        run: cargo test --workspace --lib --bins --tests --benches
        env:
          CARGO_INCREMENTAL: 0
          RUSTFLAGS: "-C debuginfo=0 -D warnings"

  lint:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@beta
        with:
          components: rustfmt, clippy
      - name: Check formatting
        run: cargo fmt --all -- --check
      - name: Install Linux dependencies
        uses: ./.github/actions/install-linux-dependencies
      - name: Clippy
        run: cargo clippy --workspace --all-targets --all-features -- -Dwarnings

  check-compiles:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    needs: test
    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-check-compiles-${{ hashFiles('**/Cargo.toml') }}
      - uses: dtolnay/rust-toolchain@beta
      - name: Install Linux dependencies
        uses: ./.github/actions/install-linux-dependencies
      - name: Check Compile
        run: |
          cargo test --target-dir ../../../target
          # cargo check --benches --target-dir ../target --manifest-path ./benches/Cargo.toml
          cargo check --workspace --examples
          cargo check --workspace
          cargo check --workspace --tests

  check-doc:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-check-doc-${{ hashFiles('**/Cargo.toml') }}
      - uses: dtolnay/rust-toolchain@beta
      - name: Install Linux dependencies
        uses: ./.github/actions/install-linux-dependencies
      - name: Build doc
        run: cargo doc --workspace --all-features --no-deps --document-private-items --keep-going
        env:
          CARGO_INCREMENTAL: 0
          RUSTFLAGS: "-C debuginfo=0 --cfg docsrs_dep"
      - name: Check doc
        run: cargo test --workspace --doc
        env:
          CARGO_INCREMENTAL: 0
          RUSTFLAGS: "-C debuginfo=0 --cfg docsrs_dep"
      - name: Installs cargo-deadlinks
        run: cargo install --force cargo-deadlinks
      - name: Checks dead links
        run: cargo deadlinks --dir target/doc
        continue-on-error: true

  open-issue:
    name: Warn that weekly CI fails
    runs-on: ubuntu-latest
    needs: [test, lint, check-compiles, check-doc]
    permissions:
      issues: write
    # Use always() so the job does not get canceled if any other jobs fail
    if: ${{ always() && contains(needs.*.result, 'failure') }}
    steps:
      - name: Create issue
        run: |
          previous_issue_number=$(gh issue list \
            --search "$TITLE in:title" \
            --json number \
            --jq '.[0].number')
          if [[ -n $previous_issue_number ]]; then
            gh issue comment $previous_issue_number \
              --body "Weekly pipeline still fails: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
          else
            gh issue create \
              --title "$TITLE" \
              --label "$LABELS" \
              --body "$BODY"
          fi
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GH_REPO: ${{ github.repository }}
          TITLE: Main branch fails to compile on Rust beta.
          LABELS: C-Bug,S-Needs-Triage
          BODY: |
            ## Weekly CI run has failed.
            [The offending run.](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})