.pre-commit-config.yaml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. fail_fast: false
  2. repos:
  3. - repo: https://github.com/pre-commit/pre-commit-hooks
  4. rev: v4.3.0
  5. hooks:
  6. - id: check-byte-order-marker
  7. - id: check-case-conflict
  8. - id: check-merge-conflict
  9. - id: check-symlinks
  10. - id: check-yaml
  11. - id: end-of-file-fixer
  12. - id: mixed-line-ending
  13. - id: trailing-whitespace
  14. - repo: https://github.com/psf/black
  15. rev: 22.10.0
  16. hooks:
  17. - id: black
  18. - repo: local
  19. hooks:
  20. - id: cargo-fmt
  21. name: cargo fmt
  22. description: Format files with rustfmt.
  23. entry: bash -c 'cargo fmt -- --check'
  24. language: rust
  25. files: \.rs$
  26. args: []
  27. - id: typos
  28. name: typos
  29. description: check typo
  30. entry: bash -c 'typos'
  31. language: rust
  32. files: \.*$
  33. pass_filenames: false
  34. - id: cargo-check
  35. name: cargo check
  36. description: Check the package for errors.
  37. entry: |
  38. bash -c '
  39. # Get all packages in the workspace
  40. packages=$(cargo metadata --format-version 1 | jq -r ".packages[] | select(.name != \"xtask\") | .name")
  41. # Check each package
  42. for package in $packages; do
  43. echo "Checking package: $package"
  44. cargo check -p "$package" --target riscv64imac-unknown-none-elf
  45. check_status=$?
  46. # If the check fails, exit with the error code
  47. if [ "$check_status" -ne 0 ]; then
  48. echo "Package $package check failed, exit status: $check_status!"
  49. exit $check_status
  50. fi
  51. done
  52. echo "All packages checked successfully."
  53. exit 0
  54. '
  55. language: rust
  56. files: \.rs$
  57. pass_filenames: false
  58. - id: cargo-clippy
  59. name: cargo clippy
  60. description: Lint Rust sources.
  61. entry: |
  62. bash -c '
  63. # Get all packages in the workspace
  64. packages=$(cargo metadata --format-version 1 | jq -r ".packages[] | select(.name != \"xtask\") | .name")
  65. # Lint each package
  66. for package in $packages; do
  67. echo "Linting package: $package"
  68. cargo clippy -p "$package" --target riscv64imac-unknown-none-elf -- -D warnings
  69. clippy_status=$?
  70. # If the linting fails, exit with the error code
  71. if [ "$clippy_status" -ne 0 ]; then
  72. echo "Package $package clippy check failed, exit status: $clippy_status!"
  73. exit $clippy_status
  74. fi
  75. done
  76. echo "All packages linted successfully."
  77. exit 0
  78. '
  79. language: rust
  80. files: \.rs$
  81. pass_filenames: false