Use the README as documentation for the crate root. #547
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: [push, pull_request] | |
name: Integration tests | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
RUSTFLAGS: "-D warnings" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@nightly | |
- name: Create Cargo.lock file | |
run: cargo generate-lockfile | |
- name: Cache Cargo registry | |
uses: actions/cache@v4 | |
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 | tee cargo.version.txt | |
- name: Cache Cargo target | |
uses: actions/cache@v4 | |
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 --verbose --release | |
- name: Build histogram | |
run: cargo build --verbose --release --example histogram | |
- name: Build random_ballots | |
run: cargo build --verbose --release --example random_ballots | |
- name: Build remove_nicknames | |
run: cargo build --verbose --release --example remove_nicknames | |
- name: Build shuffle_ballots | |
run: cargo build --verbose --release --example shuffle_ballots | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifacts | |
path: | | |
target/release/stv-rs | |
target/release/examples/histogram | |
target/release/examples/random_ballots | |
target/release/examples/remove_nicknames | |
target/release/examples/shuffle_ballots | |
if-no-files-found: error | |
- name: Generate random ballots | |
run: | | |
target/release/examples/random_ballots --ballot-pattern hypergeometric20 --num-ballots 10000 --seed 43 --output testdata/ballots/random/rand_hypergeometric_10k.blt | |
target/release/examples/random_ballots --ballot-pattern hypergeometric20 --num-ballots 100000 --seed 43 --output testdata/ballots/random/rand_hypergeometric_100k.blt | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: large-test-files | |
path: | | |
testdata/ballots/random/rand_hypergeometric_10k.blt | |
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_short_help | |
flags: "meek -h" | |
- 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@v4 | |
- uses: actions/download-artifact@v4 | |
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 - | |
random_ballots_tests: | |
needs: build | |
strategy: | |
matrix: | |
file: | |
- bigint/rand_hypergeometric_many | |
- crashes/rand_geometric | |
- random/rand_2x10 | |
- random/rand_5x4 | |
- random/rand_hypergeometric | |
- random/rand_mixed_5k | |
include: | |
- cli: "" | |
- file: bigint/rand_hypergeometric_many | |
pattern: hypergeometric80 | |
num_ballots: 200 | |
cli: "--title=\"Vegetable contest with many candidates\"" | |
- file: crashes/rand_geometric | |
pattern: geometric20 | |
num_ballots: 1000 | |
- file: random/rand_2x10 | |
pattern: tuples2x10 | |
num_ballots: 1000 | |
- file: random/rand_5x4 | |
pattern: tuples5x4 | |
num_ballots: 1000 | |
- file: random/rand_hypergeometric | |
pattern: hypergeometric20 | |
num_ballots: 1000 | |
- file: random/rand_mixed_5k | |
pattern: mixed20 | |
num_ballots: 5000 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
path: target/release/ | |
- name: Prepare random_ballots binary | |
run: chmod +x target/release/examples/random_ballots | |
- name: Check generated ballot | |
run: | | |
target/release/examples/random_ballots --seed=43 --ballot-pattern=${{ matrix.pattern }} --num-ballots=${{ matrix.num_ballots }} ${{ matrix.cli }} | diff -s testdata/ballots/${{ matrix.file }}.blt - | |
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 | |
- random/rand_mixed_5k | |
- recursive_descent/transfer | |
- recursive_descent/transfer_is_blocked | |
- ties/tie_break_explicit | |
- ties/tie_break_implicit | |
- skewed | |
- vegetables | |
parallel: | |
- no | |
- rayon | |
- custom | |
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@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
path: target/release/ | |
- uses: actions/download-artifact@v4 | |
with: | |
name: large-test-files | |
path: testdata/ballots/random/ | |
- name: Install Droop | |
if: ${{ matrix.parallel == 'rayon' }} | |
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 == 'rayon' | |
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 | |
arithmetic_tests: | |
needs: build | |
strategy: | |
matrix: | |
file: | |
- crashes/elect_too_many | |
- random/rand_2x10 | |
- random/rand_5x4 | |
- random/rand_hypergeometric | |
- random/rand_mixed_5k | |
- vegetables | |
arithmetic: | |
- bigfixed9 | |
- approx | |
parallel: | |
- no | |
- rayon | |
- custom | |
exclude: | |
- file: crashes/elect_too_many | |
arithmetic: bigfixed9 | |
include: | |
- arithmetic: bigfixed9 | |
suffix: fixed9 | |
- arithmetic: approx | |
suffix: approx | |
fail-fast: false | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
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 ${{ matrix.arithmetic }} --input testdata/ballots/${{ matrix.file }}.blt meek --parallel=${{ matrix.parallel }} | diff -s testdata/meek/${{ matrix.file }}.${{ matrix.suffix }}.log - | |
- name: Check STV-rs output (equalized counting) | |
run: | | |
target/release/stv-rs --arithmetic ${{ matrix.arithmetic }} --input testdata/ballots/${{ matrix.file }}.blt meek --parallel=${{ matrix.parallel }} --equalize | diff -s testdata/meek/${{ matrix.file }}.equalize.${{ matrix.suffix }}.log - | |
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@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
path: target/release/ | |
- uses: actions/download-artifact@v4 | |
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 | |
- random/rand_mixed_5k | |
- vegetables | |
fail-fast: false | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts | |
path: target/release/ | |
- uses: actions/download-artifact@v4 | |
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: | |
- no | |
- rayon | |
- custom | |
include: | |
- file: negative_surplus/below_quota | |
output: negative_surplus/force_positive_surplus | |
fail-fast: false | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
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@v4 | |
- uses: actions/download-artifact@v4 | |
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_mixed_5k_sorted_alphabetically | |
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_mixed_5k_sorted_alphabetically | |
src: random/rand_mixed_5k | |
strategy: "alphabetic" | |
fail-fast: false | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
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: | |
- no | |
- rayon | |
- custom | |
include: | |
- error_suffix: "" | |
- equalize: false | |
- file: bigint/ballot_sum_overflows | |
parallel: rayon | |
error_suffix: ".rayon" | |
- file: bigint/ballot_sum_overflows | |
parallel: custom | |
error_suffix: ".custom" | |
- file: bigint/rand_hypergeometric_many | |
equalize: true | |
fail-fast: false | |
runs-on: ubuntu-latest | |
env: | |
RAYON_NUM_THREADS: 1 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
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 --num-threads=1 --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 --num-threads=1 --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 --num-threads=1 --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 --num-threads=1 --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: | |
- no | |
- rayon | |
- custom | |
fail-fast: false | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
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_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@v4 | |
- 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 |