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
name: CI
on:
push:
pull_request:
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Run shellcheck
run: shellcheck demo/build.sh npm/build.sh
rust:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install C dependencies
run: |
sudo apt-get update
sudo apt-get install -y libzbar-dev libzbar0 zbar-tools
- name: Verify zbarimg installation
run: |
which zbarimg
zbarimg --version
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
- name: Check formatting
run: cargo fmt --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run tests
run: cargo test
# Reports coverage; it does not gate the build. A threshold would mostly
# measure how much of the ported C is reachable from the fixtures we happen
# to have, which is not a number worth failing a PR over. The summary is
# here so a reviewer can see what a change does to it.
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
# zbarimg cross-checks are skipped when it is missing, which would
# quietly shrink the covered paths.
- name: Install C dependencies
run: |
sudo apt-get update
sudo apt-get install -y zbar-tools
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Report coverage
run: |
cargo llvm-cov --summary-only | tee coverage.txt
{
echo '## Coverage'
echo '```'
cat coverage.txt
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
# The crate advertises building with only the symbologies you need, so every
# feature subset has to keep compiling. Scoped to `--lib`, which is what a
# dependent consumes: the test targets assume the default features.
#
# Compile errors only, no `-D warnings`. A subset that leaves a decoder out
# legitimately leaves its shared helpers unused, and gating those per
# symbology would cost more readability than the warnings are worth.
feature-matrix:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
# The bench features are excluded: bench_zbar_c needs the system zbar
# library and bench_rxing pulls a large dependency, and neither is
# something a dependent enables.
- name: Check each feature subset
run: cargo hack --each-feature --exclude-features bench_zbar_c,bench_rxing check --lib
wasm:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install wasm-pack
run: cargo install wasm-pack
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
- name: Build npm package
run: ./npm/build.sh
- name: Install test dependencies
run: npm ci
working-directory: npm
- name: Run WASM tests
run: npm test
working-directory: npm
- name: Build demo site
run: ./demo/build.sh