unit-tests.yml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. no-merge-commits:
  31. runs-on: ubuntu-latest
  32. steps:
  33. - name: Checkout
  34. uses: actions/checkout@v4
  35. - name: Run test
  36. uses: NexusPHP/no-merge-commits@v2.1.0
  37. with:
  38. token: ${{ secrets.GITHUB_TOKEN }}
  39. conventional:
  40. needs: no-merge-commits
  41. name: Conventional Commits
  42. runs-on: ubuntu-latest
  43. steps:
  44. - uses: actions/checkout@v4
  45. - uses: webiny/action-conventional-commits@v1.3.0
  46. unit-tests:
  47. needs: conventional
  48. runs-on: ${{ matrix.os }}
  49. continue-on-error: ${{ matrix.rust == 'nightly' }}
  50. strategy:
  51. matrix:
  52. os: [ubuntu-latest, macos-latest, windows-latest]
  53. rust: [1.70.0, stable, beta, nightly]
  54. steps:
  55. - name: Checkout repository
  56. uses: actions/checkout@v4
  57. - run: rustup toolchain install ${{ matrix.rust }} --profile minimal
  58. - uses: Swatinem/rust-cache@v2
  59. - name: Install cargo-hack
  60. uses: nick-fields/retry@v3
  61. with:
  62. timeout_minutes: 5
  63. max_attempts: 5
  64. command: cargo install cargo-hack
  65. - name: Run rustfmt checks
  66. run: cargo fmt --check
  67. - name: Run clippy lints
  68. if: ${{ matrix.os != 'windows-latest' }}
  69. run: cargo clippy -- -D warnings
  70. - name: Run unit tests
  71. run: cargo hack test
  72. flake-check:
  73. needs: conventional
  74. name: Check Nix Flake
  75. runs-on: ubuntu-22.04
  76. steps:
  77. - uses: actions/checkout@v4
  78. - name: Install Nix
  79. uses: DeterminateSystems/nix-installer-action@v16
  80. - name: Setup Nix cache
  81. uses: DeterminateSystems/magic-nix-cache-action@main
  82. - name: Nix Flake Check
  83. run: nix flake check --all-systems -L
  84. flake-build:
  85. needs: conventional
  86. name: Build Nix package
  87. # if cross compilation is desired add 'aarch64-linux', 'x86_64-darwin' and 'aarch64-darwin' and fix the flake to support cross compilation.
  88. strategy:
  89. matrix:
  90. target: [x86_64-linux]
  91. runs-on: ubuntu-22.04
  92. steps:
  93. - uses: actions/checkout@v4
  94. - name: Install Nix
  95. uses: DeterminateSystems/nix-installer-action@v16
  96. - name: Setup Nix cache
  97. uses: DeterminateSystems/magic-nix-cache-action@main
  98. - name: Nix Build
  99. run: nix build .#packages.${{ matrix.target }}.default -L