unit-tests.yml 2.8 KB

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