ci.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/usr/bin/env bash
  2. set -eox pipefail
  3. export DEFMT_LOG=trace
  4. MSRV="1.65.0"
  5. RUSTC_VERSIONS=(
  6. $MSRV
  7. "stable"
  8. "nightly"
  9. )
  10. FEATURES_TEST=(
  11. "default"
  12. "std,proto-ipv4"
  13. "std,medium-ethernet,phy-raw_socket,proto-ipv6,socket-udp,socket-dns"
  14. "std,medium-ethernet,phy-tuntap_interface,proto-ipv6,socket-udp"
  15. "std,medium-ethernet,proto-ipv4,proto-ipv4-fragmentation,socket-raw,socket-dns"
  16. "std,medium-ethernet,proto-ipv4,proto-igmp,socket-raw,socket-dns"
  17. "std,medium-ethernet,proto-ipv4,socket-udp,socket-tcp,socket-dns"
  18. "std,medium-ethernet,proto-ipv4,proto-dhcpv4,socket-udp"
  19. "std,medium-ethernet,medium-ip,medium-ieee802154,proto-ipv6,socket-udp,socket-dns"
  20. "std,medium-ethernet,proto-ipv6,socket-tcp"
  21. "std,medium-ethernet,medium-ip,proto-ipv4,socket-icmp,socket-tcp"
  22. "std,medium-ip,proto-ipv6,socket-icmp,socket-tcp"
  23. "std,medium-ieee802154,proto-sixlowpan,socket-udp"
  24. "std,medium-ieee802154,proto-sixlowpan,proto-sixlowpan-fragmentation,socket-udp"
  25. "std,medium-ieee802154,proto-rpl,proto-sixlowpan,proto-sixlowpan-fragmentation,socket-udp"
  26. "std,medium-ip,proto-ipv4,proto-ipv6,socket-tcp,socket-udp"
  27. "std,medium-ethernet,medium-ip,medium-ieee802154,proto-ipv4,proto-ipv6,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
  28. "std,medium-ieee802154,medium-ip,proto-ipv4,socket-raw"
  29. )
  30. FEATURES_TEST_NIGHTLY=(
  31. "alloc,medium-ethernet,proto-ipv4,proto-ipv6,socket-raw,socket-udp,socket-tcp,socket-icmp"
  32. )
  33. FEATURES_CHECK=(
  34. "medium-ip,medium-ethernet,medium-ieee802154,proto-ipv6,proto-ipv6,proto-igmp,proto-dhcpv4,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
  35. "defmt,medium-ip,medium-ethernet,proto-ipv6,proto-ipv6,proto-igmp,proto-dhcpv4,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
  36. "defmt,alloc,medium-ip,medium-ethernet,proto-ipv6,proto-ipv6,proto-igmp,proto-dhcpv4,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
  37. )
  38. test() {
  39. local version=$1
  40. rustup toolchain install $version
  41. for features in ${FEATURES_TEST[@]}; do
  42. cargo +$version test --no-default-features --features "$features"
  43. done
  44. if [[ $version == "nightly" ]]; then
  45. for features in ${FEATURES_TEST_NIGHTLY[@]}; do
  46. cargo +$version test --no-default-features --features "$features"
  47. done
  48. fi
  49. }
  50. check() {
  51. local version=$1
  52. rustup toolchain install $version
  53. export DEFMT_LOG="trace"
  54. for features in ${FEATURES_CHECK[@]}; do
  55. cargo +$version check --no-default-features --features "$features"
  56. done
  57. }
  58. clippy() {
  59. rustup toolchain install $MSRV
  60. rustup component add clippy --toolchain=$MSRV
  61. cargo +$MSRV clippy --tests --examples -- -D warnings
  62. }
  63. coverage() {
  64. for features in ${FEATURES_TEST[@]}; do
  65. cargo llvm-cov --no-report --no-default-features --features "$features"
  66. done
  67. cargo llvm-cov report --lcov --output-path lcov.info
  68. }
  69. if [[ $1 == "test" || $1 == "all" ]]; then
  70. if [[ -n $2 ]]; then
  71. if [[ $2 == "msrv" ]]; then
  72. test $MSRV
  73. else
  74. test $2
  75. fi
  76. else
  77. for version in ${RUSTC_VERSIONS[@]}; do
  78. test $version
  79. done
  80. fi
  81. fi
  82. if [[ $1 == "check" || $1 == "all" ]]; then
  83. if [[ -n $2 ]]; then
  84. if [[ $2 == "msrv" ]]; then
  85. check $MSRV
  86. else
  87. check $2
  88. fi
  89. else
  90. for version in ${RUSTC_VERSIONS[@]}; do
  91. check $version
  92. done
  93. fi
  94. fi
  95. if [[ $1 == "clippy" || $1 == "all" ]]; then
  96. clippy
  97. fi
  98. if [[ $1 == "coverage" || $1 == "all" ]]; then
  99. coverage
  100. fi