unit-tests.yml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # SPDX-FileCopyrightText: 2024 Christina Sørensen
  2. # SPDX-License-Identifier: EUPL-1.2
  3. #
  4. # SPDX-FileCopyrightText: 2023-2024 Christina Sørensen, eza contributors
  5. # SPDX-FileCopyrightText: 2014 Benjamin Sago
  6. # SPDX-License-Identifier: MIT
  7. name: Unit tests
  8. on:
  9. push:
  10. branches: [main]
  11. paths:
  12. - '.github/workflows/unit-tests.yml'
  13. - 'src/**'
  14. - 'Cargo.*'
  15. - build.rs
  16. pull_request:
  17. branches: [main]
  18. paths:
  19. - '.github/workflows/unit-tests.yml'
  20. - 'src/**'
  21. - 'Cargo.*'
  22. - build.rs
  23. concurrency:
  24. group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
  25. cancel-in-progress: true
  26. env:
  27. CARGO_TERM_COLOR: always
  28. RUSTFLAGS: --deny warnings
  29. jobs:
  30. unit-tests:
  31. runs-on: ${{ matrix.os }}
  32. continue-on-error: ${{ matrix.rust == 'nightly' }}
  33. strategy:
  34. matrix:
  35. os: [ubuntu-latest, macos-latest, windows-latest]
  36. rust: [1.70.0, stable, beta, nightly]
  37. steps:
  38. - name: Checkout repository
  39. uses: actions/checkout@v4
  40. - run: rustup toolchain install ${{ matrix.rust }} --profile minimal
  41. - uses: Swatinem/rust-cache@v2
  42. - name: Install cargo-hack
  43. uses: nick-fields/retry@v3
  44. with:
  45. timeout_minutes: 5
  46. max_attempts: 5
  47. command: cargo install cargo-hack
  48. - name: Run rustfmt checks
  49. run: cargo fmt --check
  50. - name: Run clippy lints
  51. if: ${{ matrix.os != 'windows-latest' }}
  52. run: cargo clippy -- -D warnings
  53. - name: Run unit tests
  54. run: cargo hack test