Skip to content

Commit 9a10ef2

Browse files
committed
Add Github action
1 parent e8a2ec6 commit 9a10ef2

File tree

5 files changed

+44
-2
lines changed

5 files changed

+44
-2
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Tally Elections Tool
2+
run-name: Test Tally Elections Tool
3+
on:
4+
pull_request:
5+
paths:
6+
- 'elections/tools/**'
7+
jobs:
8+
tally_test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- run: echo "The name of the branch is ${{ github.ref }} and the repository is ${{ github.repository }}."
12+
- uses: actions/setup-go@v5
13+
with:
14+
go-version: '1.24.x'
15+
- name: Check out repository
16+
uses: actions/checkout@v4
17+
- name: Run unit tests and fuzzer
18+
run: cd ${{ github.workspace }} && make fuzztimed

elections/tools/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ test:
2323
fuzz:
2424
go test -v -fuzz=Fuzz ./pkg/score/
2525

26+
.PHONY: fuzztimed
27+
fuzztimed:
28+
go test -v -fuzz=Fuzz -fuzztime=60s ./pkg/score/
29+
30+
.PHONY: fmt
31+
fmt:
32+
go fmt ./...
33+
2634
.PHONY: clean
2735
clean:
2836
rm -f ${ARTIFACTS}

elections/tools/README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,15 @@
33
This directory contains tooling used to conduct the annual gRPC Steering
44
Committee elections.
55

6-
TODO: Usage instructions
6+
First, write a config file using [the example config](examples/config.yaml) as a
7+
guide. If you have not changed the ballot format since the last election, the
8+
only change you will need to make is the list of candidates.
9+
10+
To generate a results markdown file given a CSV of ballots, use the following command:
11+
12+
```
13+
go run ./cmd/tally.go [VOTES_CSV] -c [CONFIG_FILE]
14+
```
15+
16+
This will generate a markdown file at `results.md` with the results of the
17+
election.

elections/tools/cmd/tally.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ func generateResultsMarkdown(candidates []string, responseCount int, winners, lo
152152

153153
sb.WriteString("## Instant Run-Off Elimination\n")
154154
sb.WriteString("Candidates were eliminated according to the Condorcet IRV method in the following order:\n")
155+
156+
if len(losers) == 0 {
157+
sb.WriteString("\n*no candidates were eliminated*\n")
158+
}
159+
155160
for _, loser := range losers {
156161
sb.WriteString(fmt.Sprintf("- %s\n", candidates[loser]))
157162
}

elections/tools/pkg/score/score_fuzz_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func lehmerCodeToRow(lehmer int, elementCount int) []int {
5656
}
5757

5858
func rowEncodingToRows(rowEncoding []byte, numCandidates, numVoters int) [][]int {
59-
// We'll draw `numVoters` permutations from the byte slice. If there are no remaining bytes, we will assume the next row is a 0.
59+
// We draw `numVoters` permutations from the byte slice. If there are no remaining bytes, we will assume the next row is a 0.
6060
// Each row will be a Lehmer Code represented by ceil(ceil(log_2(numCandidates!)) / 8) bytes.
6161

6262
// So we will draw no more than numVoters * ceil(ceil(log_2(numCandidates!)) / 8) bytes from the slice.

0 commit comments

Comments
 (0)