@@ -10,18 +10,58 @@ jobs:
1010
1111 runs-on : ${{ matrix.platform }}
1212
13+ # Set variable to enable coverage
14+ env :
15+ RUSTFLAGS : -C instrument-coverage
16+
1317 steps :
18+ - name : Install coverage reporter (llvm-tools-preview)
19+ if : runner.os == 'Linux'
20+ run : rustup component add llvm-tools-preview
21+ - name : Install coverage reporter (grcov)
22+ if : runner.os == 'Linux'
23+ run : cargo install grcov
1424 - uses : actions/checkout@v1
1525 - name : Build
1626 run : cargo build
1727 - name : Run tests (no features)
28+ env :
29+ LLVM_PROFILE_FILE : coverage/no-features-%p-%m.profraw
1830 run : cargo test --no-default-features
1931 - name : Run tests (serialize)
32+ env :
33+ LLVM_PROFILE_FILE : coverage/serialize-%p-%m.profraw
2034 run : cargo test --features serialize
21- - name : Run tests (encoding+serialize)
22- run : cargo test --features encoding,serialize
23- - name : Run tests (escape-html+serialize)
24- run : cargo test --features escape-html,serialize
35+ - name : Run tests (serialize+encoding)
36+ env :
37+ LLVM_PROFILE_FILE : coverage/serialize-encoding-%p-%m.profraw
38+ run : cargo test --features serialize,encoding
39+ - name : Run tests (serialize+escape-html)
40+ env :
41+ LLVM_PROFILE_FILE : coverage/serialize-escape-html-%p-%m.profraw
42+ run : cargo test --features serialize,escape-html
43+ - name : Prepare coverage information for upload
44+ if : runner.os == 'Linux'
45+ # --token is required by grcov, but not required by coveralls.io, so pass
46+ # something to get it work. See https://github.com/mozilla/grcov/issues/833
47+ run : |
48+ grcov ./coverage \
49+ -s . \
50+ --binary-path ./target/debug/ \
51+ --branch \
52+ --ignore-not-existing \
53+ --ignore 'tests/*' \
54+ -t coveralls+ \
55+ --token ? \
56+ -o ./coveralls.json
57+ - name : Upload coverage to codecov.io
58+ if : runner.os == 'Linux'
59+ uses : codecov/codecov-action@v2
60+ with :
61+ files : ./coveralls.json
62+ flags : unittests
63+ verbose : true
64+ continue-on-error : true
2565 - name : Check fmt
2666 run : cargo fmt -- --check
2767
0 commit comments