Repository navigation
154 lines (143 loc) · 5.42 KB
/
Copy pathrust.yml
File metadata and controls
154 lines (143 loc) · 5.42 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Rust
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check fmt
run: cargo fmt -- --check
msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.86.0
- run: cargo check
minimal-versions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install tools
run: cargo install cargo-hack cargo-minimal-versions
- name: Install nightly rust
uses: dtolnay/rust-toolchain@nightly
- name: Check with minimal versions
run: cargo minimal-versions check
- name: Check with minimal versions (serialize)
run: cargo minimal-versions check --features serialize
- name: Check with minimal versions (encoding)
run: cargo minimal-versions check --features encoding
- name: Check with minimal versions (async-tokio)
run: cargo minimal-versions check --features async-tokio
test:
strategy:
matrix:
platform: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.platform }}
# Set variable to enable coverage
env:
RUSTFLAGS: -C instrument-coverage
steps:
- uses: actions/checkout@v4
- name: Install coverage reporter (llvm-tools-preview)
if: runner.os == 'Linux'
run: rustup component add llvm-tools-preview
- name: Install coverage reporter (grcov)
if: runner.os == 'Linux'
run: cargo install grcov
- name: Build
run: cargo build
- name: Build benchmarks
run: cargo bench --no-run
- name: Build benchmarks (compare)
working-directory: compare
run: cargo bench --no-run
- name: Run tests + benchmarks
run: cargo test --all-features --benches --tests
- name: Run tests (no features)
env:
LLVM_PROFILE_FILE: coverage/no-features-%p-%m.profraw
run: cargo test --no-default-features
- name: Run tests (serialize)
env:
LLVM_PROFILE_FILE: coverage/serialize-%p-%m.profraw
run: cargo test --features serialize
- name: Run tests (serialize+encoding)
env:
LLVM_PROFILE_FILE: coverage/serialize-encoding-%p-%m.profraw
run: cargo test --features serialize,encoding
- name: Run tests (serialize+escape-html)
env:
LLVM_PROFILE_FILE: coverage/serialize-escape-html-%p-%m.profraw
run: cargo test --features serialize,escape-html
- name: Run tests (all features)
env:
LLVM_PROFILE_FILE: coverage/all-features-%p-%m.profraw
run: cargo test --all-features
- name: Run examples (no features)
run: |
cargo run --example getting_started
cargo run --example nested_readers
cargo run --example read_buffered
cargo run --example reader_patterns
cargo run --example read_nodes
cargo run --example custom_entities
cargo run --example writer
cargo run --example visitor
- name: Run examples (serialize)
run: |
cargo run --example serde_roundtrip --features serialize
cargo run --example read_nodes_serde --features serialize
cargo run --example flattened_enum --features serialize
- name: Run examples (encoding)
run: cargo run --example read_utf16 --features encoding
- name: Prepare coverage information for upload
if: runner.os == 'Linux'
run: |
grcov ./coverage \
-s . \
--binary-path ./target/debug/ \
--branch \
--ignore-not-existing \
--ignore 'tests/*' \
-o ./coverage.lcov
- name: Upload coverage to codecov.io
if: runner.os == 'Linux'
uses: codecov/codecov-action@v4
with:
files: ./coverage.lcov
flags: unittests
verbose: true
continue-on-error: true
# Check that tests that are sensitive to target are passed
x86:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install 32-bit target
run: rustup target add i686-unknown-linux-gnu
- name: Update install sources (for next step)
# To avoid problem
# E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
# See also this thread:
# https://github.com/actions/runner-images/issues/12599
run: sudo apt-get -y update
- name: Install 32-bit libs (for criterion)
# Criterion wants to compile something.
# Cargo builds criterion even when it is not required for those tests.
# Without those libs compilation failed with:
# error: linking with `cc` failed: exit status: 1
# |
# = note: LC_ALL="C" PATH="..." ...
# = note: /usr/bin/ld: cannot find Scrt1.o: No such file or directory
# /usr/bin/ld: cannot find crti.o: No such file or directory
# /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/11/libgcc.a when searching for -lgcc
# /usr/bin/ld: cannot find -lgcc: No such file or directory
# collect2: error: ld returned 1 exit status
# Fixed as suggested in this answer:
# https://stackoverflow.com/a/16016792/7518605
run: sudo apt install gcc-multilib
- name: Run some tests on 32-bit target
run: cargo test --target i686-unknown-linux-gnu --test issues
- name: Run some tests on 32-bit target (async-tokio)
run: cargo test --target i686-unknown-linux-gnu --features async-tokio --test async-tokio