-
Notifications
You must be signed in to change notification settings - Fork 0
478 lines (451 loc) · 17.2 KB
/
integration.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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
on: [push, pull_request]
name: Integration tests
jobs:
build:
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-D warnings"
CARGO_UNSTABLE_SPARSE_REGISTRY: true
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly
- name: Create Cargo.lock file
run: cargo generate-lockfile
- name: Cache Cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: cargo-registry-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-registry-${{ hashFiles('Cargo.toml') }}
cargo-registry
- name: Check Cargo version
run: cargo -V > cargo.version.txt
- name: Cache Cargo target
uses: actions/cache@v3
with:
path: target
key: cargo-target-release-${{ hashFiles('cargo.version.txt') }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-target-release-${{ hashFiles('cargo.version.txt') }}-${{ hashFiles('Cargo.toml') }}
cargo-target-release-${{ hashFiles('cargo.version.txt') }}
- name: Build STV-rs
run: cargo build --release
- name: Build histogram
run: cargo build --release --example histogram
- name: Build remove_nicknames
run: cargo build --release --example remove_nicknames
- name: Build shuffle_ballots
run: cargo build --release --example shuffle_ballots
- uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: |
target/release/stv-rs
target/release/examples/histogram
target/release/examples/remove_nicknames
target/release/examples/shuffle_ballots
if-no-files-found: error
- name: Generate random ballots
run: |
cargo run --release --example random_ballots
mv rand_hypergeometric_100k.blt testdata/ballots/random/
- uses: actions/upload-artifact@v3
with:
name: large-test-files
path: |
testdata/ballots/random/rand_hypergeometric_100k.blt
if-no-files-found: error
help_tests:
needs: build
strategy:
matrix:
file:
- short_help
- help
- meek_help
- plurality_help
- version
include:
- file: short_help
flags: "-h"
- file: help
flags: "--help"
- file: meek_help
flags: "meek --help"
- file: plurality_help
flags: "plurality --help"
- file: version
flags: "--version"
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build-artifacts
path: target/release/
- name: Prepare STV-rs binary
run: chmod +x target/release/stv-rs
- name: Check output
run: |
target/release/stv-rs ${{ matrix.flags }} | diff -s man/${{ matrix.file }}.txt -
meek_tests:
needs: build
strategy:
matrix:
file:
- equal_preference/equal_preference
- equal_preference/equal_preference_droop
- equal_preference/equal_preference_equalize
- negative_surplus/below_quota
- random/rand_2x10
- random/rand_5x4
- random/rand_hypergeometric
- random/rand_hypergeometric_10k
- random/rand_hypergeometric_100k
- recursive_descent/transfer
- recursive_descent/transfer_is_blocked
- ties/tie_break_explicit
- ties/tie_break_implicit
- skewed
- vegetables
parallel:
- false
- true
include:
- droop: true
- file: random/rand_hypergeometric_10k
droop: false
- file: random/rand_hypergeometric_100k
droop: false
- file: skewed
droop: false
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build-artifacts
path: target/release/
- uses: actions/download-artifact@v3
with:
name: large-test-files
path: testdata/ballots/random/
- name: Install Droop
if: ${{ matrix.parallel == true }}
run: git clone https://github.com/jklundell/droop
- name: Prepare STV-rs binary
run: chmod +x target/release/stv-rs
- name: Check STV-rs output (ballot from stdin)
run: |
target/release/stv-rs --arithmetic fixed9 meek --parallel=${{ matrix.parallel }} < testdata/ballots/${{ matrix.file }}.blt | diff -s testdata/meek/${{ matrix.file }}.fixed9.log -
- name: Check STV-rs output (ballot from CLI)
run: |
target/release/stv-rs --arithmetic fixed9 --input testdata/ballots/${{ matrix.file }}.blt meek --parallel=${{ matrix.parallel }} | diff -s testdata/meek/${{ matrix.file }}.fixed9.log -
- name: Check STV-rs output (equalized counting)
run: |
target/release/stv-rs --arithmetic fixed9 --input testdata/ballots/${{ matrix.file }}.blt meek --parallel=${{ matrix.parallel }} --equalize | diff -s testdata/meek/${{ matrix.file }}.equalize.fixed9.log -
- name: Check Droop output
if: matrix.droop == true && matrix.parallel == true
run: |
sed -i "s/Implementation: STV-rs/Droop package: droop v0.14/g" testdata/meek/${{ matrix.file }}.fixed9.log
python3 droop/Droop.py meek fixed precision=9 omega=6 defeat_batch=none testdata/ballots/${{ matrix.file }}.blt 2> droop.err | diff -s testdata/meek/${{ matrix.file }}.fixed9.log -
echo -n "" | diff -s - droop.err
plurality_tests:
needs: build
strategy:
matrix:
file:
- random/rand_2x10
- random/rand_5x4
- random/rand_hypergeometric
- random/rand_hypergeometric_10k
- random/rand_hypergeometric_100k
- vegetables
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build-artifacts
path: target/release/
- uses: actions/download-artifact@v3
with:
name: large-test-files
path: testdata/ballots/random/
- name: Prepare STV-rs binary
run: chmod +x target/release/stv-rs
- name: Check STV-rs output
run: |
target/release/stv-rs --arithmetic fixed9 plurality < testdata/ballots/${{ matrix.file }}.blt | diff -s testdata/plurality_block_voting/${{ matrix.file }}.fixed9.log -
histogram_tests:
needs: build
strategy:
matrix:
file:
- bigint/ballot_count_overflows
- bigint/ballot_sum_overflows
- bigint/rand_hypergeometric_many
- equal_preference/equal_preference
- random/rand_2x10
- random/rand_5x4
- random/rand_hypergeometric
- random/rand_hypergeometric_10k
- random/rand_hypergeometric_100k
- vegetables
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build-artifacts
path: target/release/
- uses: actions/download-artifact@v3
with:
name: large-test-files
path: testdata/ballots/random/
- name: Prepare histogram binary
run: chmod +x target/release/examples/histogram
- name: Check histogram output
run: |
target/release/examples/histogram < testdata/ballots/${{ matrix.file }}.blt | diff -s testdata/histogram/${{ matrix.file }}.csv -
surplus_tests:
needs: build
strategy:
matrix:
file:
- negative_surplus/below_quota
parallel:
- false
- true
include:
- file: negative_surplus/below_quota
output: negative_surplus/force_positive_surplus
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build-artifacts
path: target/release/
- name: Prepare STV-rs binary
run: chmod +x target/release/stv-rs
- name: Check STV-rs output
run: |
target/release/stv-rs --arithmetic fixed9 --input testdata/ballots/${{ matrix.file }}.blt meek --parallel=${{ matrix.parallel }} --force-positive-surplus | diff -s testdata/meek/${{ matrix.output }}.fixed9.log -
numeric_tests:
needs: build
strategy:
matrix:
file:
- equal_preference
- vegetables.keep_withdrawn
- vegetables.remove_withdrawn
include:
- file: equal_preference
src: equal_preference/equal_preference
flags: ""
- file: vegetables.keep_withdrawn
src: vegetables
flags: ""
- file: vegetables.remove_withdrawn
src: vegetables
flags: "--remove-withdrawn-candidates"
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build-artifacts
path: target/release/
- name: Install Droop
if: ${{ matrix.flags == '' }}
run: git clone https://github.com/jklundell/droop
- name: Prepare remove_nicknames binary
run: chmod +x target/release/examples/remove_nicknames
- name: Check numeric ballot
run: |
target/release/examples/remove_nicknames ${{ matrix.flags }} < testdata/ballots/${{ matrix.src }}.blt | diff -s testdata/numeric/${{ matrix.file }}.blt -
- name: Check Droop output
if: ${{ matrix.flags == '' }}
run: |
sed -i "s/Implementation: STV-rs/Droop package: droop v0.14/g" testdata/meek/${{ matrix.src }}.fixed9.log
python3 droop/Droop.py meek fixed precision=9 omega=6 defeat_batch=none testdata/numeric/${{ matrix.file }}.blt 2> droop.err | diff -s testdata/meek/${{ matrix.src }}.fixed9.log -
echo -n "" | diff -s - droop.err
shuffle_tests:
needs: build
strategy:
matrix:
file:
- rand_sorted_by_product
- rand_sorted_lexicographically
- rand_sorted_by_lexico_product
- rand_10k_sorted_by_product
- rand_10k_sorted_lexicographically
- rand_10k_sorted_by_lexico_product
include:
- file: rand_sorted_by_product
src: random/rand_hypergeometric
strategy: "product"
- file: rand_sorted_lexicographically
src: random/rand_hypergeometric
strategy: "lexicographic"
- file: rand_sorted_by_lexico_product
src: random/rand_hypergeometric
strategy: "lexico-product"
- file: rand_10k_sorted_by_product
src: random/rand_hypergeometric_10k
strategy: "product"
- file: rand_10k_sorted_lexicographically
src: random/rand_hypergeometric_10k
strategy: "lexicographic"
- file: rand_10k_sorted_by_lexico_product
src: random/rand_hypergeometric_10k
strategy: "lexico-product"
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build-artifacts
path: target/release/
- name: Prepare shuffle_ballots binary
run: chmod +x target/release/examples/shuffle_ballots
- name: Check shuffled ballot
run: |
target/release/examples/shuffle_ballots --strategy=${{ matrix.strategy }} < testdata/ballots/${{ matrix.src }}.blt | diff -s testdata/shuffle_ballots/${{ matrix.file }}.blt -
bigint_tests:
needs: build
strategy:
matrix:
file:
- bigint/ballot_count_overflows
- bigint/ballot_sum_overflows
- bigint/rand_hypergeometric_many
parallel:
- false
- true
include:
- error_suffix: ""
- equalize: false
- file: bigint/ballot_sum_overflows
parallel: true
error_suffix: ".parallel"
- file: bigint/rand_hypergeometric_many
equalize: true
fail-fast: false
runs-on: ubuntu-latest
env:
RAYON_NUM_THREADS: 1
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build-artifacts
path: target/release/
- name: Prepare STV-rs binary
run: chmod +x target/release/stv-rs
- name: Check STV-rs output
if: ${{ matrix.equalize == false }}
run: |
target/release/stv-rs --arithmetic fixed9 --input testdata/ballots/${{ matrix.file }}.blt meek --parallel=${{ matrix.parallel }} > stv.log 2> stv.err || true
diff -s testdata/meek/${{ matrix.file }}.fixed9.log stv.log
diff -s testdata/meek/${{ matrix.file }}.fixed9${{ matrix.error_suffix }}.err stv.err
- name: Check STV-rs output (big integer)
if: ${{ matrix.equalize == false }}
run: |
target/release/stv-rs --arithmetic bigfixed9 --input testdata/ballots/${{ matrix.file }}.blt meek --parallel=${{ matrix.parallel }} > stv.log 2> stv.err || true
diff -s testdata/meek/${{ matrix.file }}.bigfixed9.log stv.log
diff -s testdata/meek/${{ matrix.file }}.bigfixed9.err stv.err
- name: Check STV-rs output (equalized counting)
if: ${{ matrix.equalize == true }}
run: |
target/release/stv-rs --arithmetic fixed9 --input testdata/ballots/${{ matrix.file }}.blt meek --equalize --parallel=${{ matrix.parallel }} > stv.log 2> stv.err || true
diff -s testdata/meek/${{ matrix.file }}.equalize.fixed9.log stv.log
diff -s testdata/meek/${{ matrix.file }}.equalize.fixed9${{ matrix.error_suffix }}.err stv.err
- name: Check STV-rs output (equalized counting, big integer)
if: ${{ matrix.equalize == true }}
run: |
target/release/stv-rs --arithmetic bigfixed9 --input testdata/ballots/${{ matrix.file }}.blt meek --equalize --parallel=${{ matrix.parallel }} > stv.log 2> stv.err || true
diff -s testdata/meek/${{ matrix.file }}.equalize.bigfixed9.log stv.log
diff -s testdata/meek/${{ matrix.file }}.equalize.bigfixed9.err stv.err
crash_fixed9_tests:
needs: build
strategy:
matrix:
file:
- crashes/crash
- crashes/minimal
- crashes/minimal10
- crashes/rand_geometric
parallel:
- false
- true
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build-artifacts
path: target/release/
- name: Prepare STV-rs binary
run: chmod +x target/release/stv-rs
- name: Check STV-rs output
run: |
target/release/stv-rs --arithmetic fixed9 --input testdata/ballots/${{ matrix.file }}.blt meek --parallel=${{ matrix.parallel }} --force-positive-surplus | diff -s testdata/meek/${{ matrix.file }}.fixed9.log -
- name: Check STV-rs output (equalized counting)
run: |
target/release/stv-rs --arithmetic fixed9 --input testdata/ballots/${{ matrix.file }}.blt meek --parallel=${{ matrix.parallel }} --force-positive-surplus --equalize | diff -s testdata/meek/${{ matrix.file }}.equalize.fixed9.log -
crash_approx_tests:
needs: build
strategy:
matrix:
file:
- crashes/elect_too_many
parallel:
- false
- true
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build-artifacts
path: target/release/
- name: Prepare STV-rs binary
run: chmod +x target/release/stv-rs
- name: Check STV-rs output
run: |
target/release/stv-rs --arithmetic approx --input testdata/ballots/${{ matrix.file }}.blt meek --parallel=${{ matrix.parallel }} | diff -s testdata/meek/${{ matrix.file }}.approx.log -
- name: Check STV-rs output (equalized counting)
run: |
target/release/stv-rs --arithmetic approx --input testdata/ballots/${{ matrix.file }}.blt meek --parallel=${{ matrix.parallel }} --equalize | diff -s testdata/meek/${{ matrix.file }}.equalize.approx.log -
crash_droop_tests:
strategy:
matrix:
file:
- crashes/crash
- crashes/elect_too_many
- crashes/minimal
- crashes/minimal10
- crashes/rand_geometric
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Droop
run: git clone https://github.com/jklundell/droop
- name: Check that Droop fails
run: |
python3 droop/Droop.py meek fixed precision=9 omega=6 defeat_batch=none testdata/ballots/${{ matrix.file }}.blt > droop.log 2> droop.err || true
diff -s testdata/meek/${{ matrix.file }}.droop.err droop.err
echo -n "" | diff -s - droop.log