ci.sh 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #!/usr/bin/env bash
  2. set -eox pipefail
  3. export DEFMT_LOG=trace
  4. MSRV="1.81.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,multicast,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,multicast,proto-rpl,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,multicast,proto-rpl,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
  28. "std,medium-ip,proto-ipv4,proto-ipv6,multicast,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
  29. "std,medium-ieee802154,medium-ip,proto-ipv4,socket-raw"
  30. "std,medium-ethernet,proto-ipv4,proto-ipsec,socket-raw"
  31. )
  32. FEATURES_TEST_NIGHTLY=(
  33. "alloc,medium-ethernet,proto-ipv4,proto-ipv6,socket-raw,socket-udp,socket-tcp,socket-icmp"
  34. )
  35. FEATURES_CHECK=(
  36. "medium-ip,medium-ethernet,medium-ieee802154,proto-ipv6,proto-ipv6,multicast,proto-dhcpv4,proto-ipsec,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
  37. "defmt,medium-ip,medium-ethernet,proto-ipv6,proto-ipv6,multicast,proto-dhcpv4,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
  38. "defmt,alloc,medium-ip,medium-ethernet,proto-ipv6,proto-ipv6,multicast,proto-dhcpv4,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
  39. "medium-ieee802154,proto-sixlowpan,socket-dns"
  40. )
  41. test() {
  42. local version=$1
  43. rustup toolchain install $version
  44. for features in ${FEATURES_TEST[@]}; do
  45. cargo +$version test --no-default-features --features "$features"
  46. done
  47. if [[ $version == "nightly" ]]; then
  48. for features in ${FEATURES_TEST_NIGHTLY[@]}; do
  49. cargo +$version test --no-default-features --features "$features"
  50. done
  51. fi
  52. }
  53. netsim() {
  54. cargo test --release --features _netsim netsim
  55. }
  56. check() {
  57. local version=$1
  58. rustup toolchain install $version
  59. export DEFMT_LOG="trace"
  60. for features in ${FEATURES_CHECK[@]}; do
  61. cargo +$version check --no-default-features --features "$features"
  62. done
  63. cargo +$version check --examples
  64. if [[ $version == "nightly" ]]; then
  65. cargo +$version check --benches
  66. fi
  67. }
  68. clippy() {
  69. rustup toolchain install $MSRV
  70. rustup component add clippy --toolchain=$MSRV
  71. cargo +$MSRV clippy --tests --examples -- -D warnings
  72. }
  73. build_16bit() {
  74. rustup toolchain install nightly
  75. rustup +nightly component add rust-src
  76. TARGET_WITH_16BIT_POINTER=msp430-none-elf
  77. for features in ${FEATURES_CHECK[@]}; do
  78. cargo +nightly build -Z build-std=core,alloc --target $TARGET_WITH_16BIT_POINTER --no-default-features --features=$features
  79. done
  80. }
  81. coverage() {
  82. for features in ${FEATURES_TEST[@]}; do
  83. cargo llvm-cov --no-report --no-default-features --features "$features"
  84. done
  85. cargo llvm-cov report --lcov --output-path lcov.info
  86. }
  87. if [[ $1 == "test" || $1 == "all" ]]; then
  88. if [[ -n $2 ]]; then
  89. if [[ $2 == "msrv" ]]; then
  90. test $MSRV
  91. else
  92. test $2
  93. fi
  94. else
  95. for version in ${RUSTC_VERSIONS[@]}; do
  96. test $version
  97. done
  98. fi
  99. fi
  100. if [[ $1 == "check" || $1 == "all" ]]; then
  101. if [[ -n $2 ]]; then
  102. if [[ $2 == "msrv" ]]; then
  103. check $MSRV
  104. else
  105. check $2
  106. fi
  107. else
  108. for version in ${RUSTC_VERSIONS[@]}; do
  109. check $version
  110. done
  111. fi
  112. fi
  113. if [[ $1 == "clippy" || $1 == "all" ]]; then
  114. clippy
  115. fi
  116. if [[ $1 == "build_16bit" || $1 == "all" ]]; then
  117. build_16bit
  118. fi
  119. if [[ $1 == "coverage" || $1 == "all" ]]; then
  120. coverage
  121. fi
  122. if [[ $1 == "netsim" || $1 == "all" ]]; then
  123. netsim
  124. fi