-
Notifications
You must be signed in to change notification settings - Fork 1
127 lines (121 loc) · 4.81 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: CI Status
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
CARGO_TERM_COLOR: always
RUST_TEST_TIME_UNIT: 60,120
RUST_TEST_TIME_INTEGRATION: 60,120
RUST_TEST_TIME_DOCTEST: 60,120
jobs:
test:
name: test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
crate: [ libcoap-sys, libcoap-rs ]
dtls_backend: [ openssl, gnutls, tinydtls, mbedtls ]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: dtolnay/rust-toolchain@stable
with:
components: rust-src
toolchain: stable
- if: matrix.dtls_backend == 'gnutls'
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libgnutls28-dev libgnutls30
version: 1.0
- if: matrix.crate == 'libcoap-rs' && matrix.dtls_backend != 'gnutls'
run: cargo test -p ${{ matrix.crate }} --no-default-features --features dtls,tcp,vendored --features dtls_${{ matrix.dtls_backend }} --features dtls_${{ matrix.dtls_backend }}_vendored --no-fail-fast
- if: matrix.crate == 'libcoap-rs' && matrix.dtls_backend == 'gnutls'
run: cargo test -p ${{ matrix.crate }} --no-default-features --features dtls,tcp,vendored --features dtls_${{ matrix.dtls_backend }} --no-fail-fast
- if: matrix.crate == 'libcoap-sys' && matrix.dtls_backend != 'gnutls'
run: cargo test -p ${{ matrix.crate }} --features dtls,dtls_backend_${{ matrix.dtls_backend }},dtls_backend_${{ matrix.dtls_backend }}_vendored --no-fail-fast
- if: matrix.crate == 'libcoap-sys' && matrix.dtls_backend == 'gnutls'
run: cargo test -p ${{ matrix.crate }} --features dtls,dtls_backend_${{ matrix.dtls_backend }} --no-fail-fast
lint:
name: lint
runs-on: ubuntu-latest
strategy:
matrix:
crate: [ libcoap-sys, libcoap-rs ]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: giraffate/clippy-action@main
with:
reporter: 'github-check'
clippy_flags: -p ${{ matrix.crate }} --no-deps
level: warning
fail_on_error: true
tool_name: clippy (${{ matrix.crate }})
coverage:
name: coverage
runs-on: ubuntu-latest
outputs:
report: ${{ steps.cov-report.outputs.summary }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: baptiste0928/cargo-install@v3
with:
crate: cargo-tarpaulin
- run: cargo tarpaulin --no-fail-fast --workspace --verbose --features dtls,tcp,vendored --exclude-files libcoap-sys/tests,libcoap/tests --timeout 120 --out Xml
- id: cov-report
name: Produce the coverage report
uses: pulsastrix/coverage-action@always_generate_comment_body
with:
path: ./cobertura.xml
threshold: 80.0
fail: false
publish: false
diff: true
togglable-report: true
coverage-summary-title: "Code Coverage Report"
pr-comment:
name: pr-comment
runs-on: ubuntu-latest
if: ${{ always() && github.event_name == 'pull_request' }}
needs: [ lint, coverage ]
env:
LINT_OUTPUT: ${{ needs.lint.result }}
COV_OUTPUT: ${{ needs.coverage.outputs.report }}
steps:
- name: "Generate Markdown Report"
run: |
# Snippet taken from https://github.com/marocchino/sticky-pull-request-comment#append-after-comment-every-time-it-runs
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "report<<$EOF" >> "$GITHUB_ENV"
echo "# Workflow Status Report" >> "$GITHUB_ENV"
echo "Generated for commit ${{ github.sha }} on `date -u`." >> "$GITHUB_ENV"
echo "" >> "$GITHUB_ENV"
echo "[![CI Status](https://github.com/namib-project/libcoap-rs/actions/workflows/ci.yml/badge.svg?branch=${GITHUB_HEAD_REF})](https://github.com/namib-project/libcoap-rs/actions/workflows/ci.yml?query=branch%3A${GITHUB_HEAD_REF})" >> "$GITHUB_ENV"
echo "" >> "$GITHUB_ENV"
echo "## Linting Report" >> "$GITHUB_ENV"
echo "" >> "$GITHUB_OUTPUT"
echo "Clippy check result: $LINT_OUTPUT" >> "$GITHUB_ENV"
echo "" >> "$GITHUB_ENV"
echo "Refer to [the \"Files Changed\" tab](./${{ github.event.number }}/files/) for identified issues." >> "$GITHUB_ENV"
echo "" >> "$GITHUB_ENV"
echo "$COV_OUTPUT" >> "$GITHUB_ENV"
echo "$EOF" >> "$GITHUB_ENV"
- if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
message: ${{ env.report }}