unit-tests.yml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # SPDX-FileCopyrightText: 2024 Christina Sørensen
  2. # SPDX-License-Identifier: EUPL-1.2
  3. name: Unit tests
  4. on:
  5. push:
  6. pull_request:
  7. workflow_dispatch:
  8. concurrency:
  9. group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
  10. cancel-in-progress: true
  11. env:
  12. CARGO_TERM_COLOR: always
  13. RUSTFLAGS: --deny warnings
  14. jobs:
  15. no-merge-commits:
  16. runs-on: ubuntu-latest
  17. steps:
  18. - name: Checkout
  19. uses: actions/checkout@v4
  20. - name: Run test
  21. uses: NexusPHP/no-merge-commits@v2.1.0
  22. with:
  23. token: ${{ secrets.GITHUB_TOKEN }}
  24. conventional:
  25. needs: no-merge-commits
  26. name: Conventional Commits
  27. runs-on: ubuntu-latest
  28. steps:
  29. - uses: actions/checkout@v4
  30. - uses: webiny/action-conventional-commits@v1.3.0
  31. unit-tests:
  32. needs: conventional
  33. runs-on: ${{ matrix.os }}
  34. continue-on-error: ${{ matrix.rust == 'nightly' }}
  35. strategy:
  36. matrix:
  37. os: [ubuntu-latest, macos-latest, windows-latest]
  38. rust: [1.70.0, stable, beta, nightly]
  39. steps:
  40. - name: Checkout repository
  41. uses: actions/checkout@v4
  42. - run: rustup toolchain install ${{ matrix.rust }} --profile minimal
  43. - uses: Swatinem/rust-cache@v2
  44. - name: Install cargo-hack
  45. uses: nick-fields/retry@v3
  46. with:
  47. timeout_minutes: 5
  48. max_attempts: 5
  49. command: cargo install cargo-hack
  50. - name: Run rustfmt checks
  51. run: cargo fmt --check
  52. - name: Run clippy lints
  53. if: ${{ matrix.os != 'windows-latest' }}
  54. run: cargo clippy -- -D warnings
  55. - name: Run unit tests
  56. run: cargo hack test
  57. flake-check:
  58. needs: conventional
  59. name: Check Nix Flake
  60. runs-on: ubuntu-22.04
  61. steps:
  62. - uses: actions/checkout@v4
  63. - name: Install Nix
  64. uses: DeterminateSystems/nix-installer-action@v16
  65. - name: Setup Nix cache
  66. uses: DeterminateSystems/magic-nix-cache-action@main
  67. - name: Nix Flake Check
  68. run: nix flake check --all-systems -L
  69. flake-build:
  70. needs: conventional
  71. name: Build Nix package
  72. # if cross compilation is desired add 'aarch64-linux', 'x86_64-darwin' and 'aarch64-darwin' and fix the flake to support cross compilation.
  73. strategy:
  74. matrix:
  75. target: [x86_64-linux]
  76. runs-on: ubuntu-22.04
  77. steps:
  78. - uses: actions/checkout@v4
  79. - name: Install Nix
  80. uses: DeterminateSystems/nix-installer-action@v16
  81. - name: Setup Nix cache
  82. uses: DeterminateSystems/magic-nix-cache-action@main
  83. - name: Nix Build
  84. run: nix build .#packages.${{ matrix.target }}.default -L