|
| 1 | +on: |
| 2 | + push: |
| 3 | + branches: |
| 4 | + - main |
| 5 | + pull_request: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + RUST_TEST_TIME_UNIT: 60,120 |
| 12 | + RUST_TEST_TIME_INTEGRATION: 60,120 |
| 13 | + RUST_TEST_TIME_DOCTEST: 60,120 |
| 14 | + |
| 15 | +jobs: |
| 16 | + test: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + crate: [libcoap-sys, libcoap-rs] |
| 22 | + dtls_backend: [openssl, gnutls, tinydtls] |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v3 |
| 25 | + with: |
| 26 | + submodules: true |
| 27 | + - uses: dtolnay/rust-toolchain@stable |
| 28 | + with: |
| 29 | + components: rust-src |
| 30 | + - if: matrix.dtls_backend == 'gnutls' |
| 31 | + uses: awalsh128/cache-apt-pkgs-action@latest |
| 32 | + with: |
| 33 | + packages: libgnutls28-dev libgnutls30 |
| 34 | + version: 1.0 |
| 35 | + - if: matrix.crate == 'libcoap-rs' |
| 36 | + run: cargo test -p ${{ matrix.crate }} --no-default-features --features dtls,tcp,vendored --features dtls_${{ matrix.dtls_backend }} --no-fail-fast -- -Z unstable-options --report-time --ensure-time |
| 37 | + - if: matrix.crate == 'libcoap-sys' |
| 38 | + run: cargo test -p ${{ matrix.crate }} --features dtls,dtls_backend_${{ matrix.dtls_backend }} --no-fail-fast -- -Z unstable-options --report-time --ensure-time |
| 39 | + |
| 40 | + lint: |
| 41 | + runs-on: ubuntu-latest |
| 42 | + strategy: |
| 43 | + matrix: |
| 44 | + crate: [libcoap-sys, libcoap-rs] |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v3 |
| 47 | + with: |
| 48 | + submodules: true |
| 49 | + - uses: dtolnay/rust-toolchain@stable |
| 50 | + with: |
| 51 | + components: clippy, rustfmt |
| 52 | + - uses: giraffate/clippy-action@main |
| 53 | + with: |
| 54 | + reporter: 'github-pr-check' |
| 55 | + clippy_flags: -p ${{ matrix.crate }} --no-deps |
| 56 | + level: warning |
| 57 | + tool_name: clippy (${{ matrix.crate }}) |
| 58 | + |
| 59 | + coverage: |
| 60 | + runs-on: ubuntu-latest |
| 61 | + strategy: |
| 62 | + fail-fast: false |
| 63 | + matrix: |
| 64 | + crate: [libcoap-rs] |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v3 |
| 67 | + with: |
| 68 | + submodules: true |
| 69 | + - uses: dtolnay/rust-toolchain@stable |
| 70 | + with: |
| 71 | + components: clippy, rustfmt |
| 72 | + - uses: baptiste0928/cargo-install@v2 |
| 73 | + with: |
| 74 | + crate: cargo-tarpaulin |
| 75 | + - run: cargo tarpaulin --no-fail-fast --workspace --verbose --features dtls,tcp,vendored --exclude-files libcoap-sys/tests,libcoap/tests --timeout 120 --out Xml |
| 76 | + |
| 77 | + with: |
| 78 | + filename: ./cobertura.xml |
| 79 | + badge: true |
| 80 | + fail_below_min: false |
| 81 | + format: markdown |
| 82 | + hide_branch_rate: false |
| 83 | + hide_complexity: true |
| 84 | + indicators: true |
| 85 | + output: file |
| 86 | + - run: | |
| 87 | + # Snippet taken from https://github.com/marocchino/sticky-pull-request-comment#append-after-comment-every-time-it-runs |
| 88 | + EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) |
| 89 | + echo "coverage_report<<$EOF" >> "$GITHUB_ENV" |
| 90 | + echo "### Code Coverage Report" >> "$GITHUB_ENV" |
| 91 | + echo "Generated for commit ${{ github.sha }} on `date -u`." >> "$GITHUB_ENV" |
| 92 | + cat code-coverage-results.md >> "$GITHUB_ENV" |
| 93 | + echo "$EOF" >> "$GITHUB_ENV" |
| 94 | + - if: github.event_name == 'pull_request' |
| 95 | + uses: marocchino/sticky-pull-request-comment@v2 |
| 96 | + with: |
| 97 | + message: ${{ env.coverage_report }} |
| 98 | + - run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY |
0 commit comments