forked from Brites101/electionguard-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
207 lines (168 loc) · 4.92 KB
/
Makefile
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
.PHONY: all openssl-fix install install-gmp install-gmp-mac install-gmp-linux install-gmp-windows install-mkdocs auto-lint validate test test-example bench coverage coverage-html coverage-xml coverage-erase generate-sample-data
CODE_COVERAGE ?= 90
OS ?= $(shell python -c 'import platform; print(platform.system())')
IS_64_BIT ?= $(shell python -c 'from sys import maxsize; print(maxsize > 2**32)')
SAMPLE_BALLOT_COUNT ?= 5
SAMPLE_BALLOT_SPOIL_RATE ?= 50
all: environment install build validate auto-lint coverage
environment:
@echo 🔧 ENVIRONMENT SETUP
make install-gmp
python -m pip install -U pip
pip3 install 'poetry==1.1.10'
poetry config virtualenvs.in-project true
poetry install
@echo 🚨 Be sure to add poetry to PATH
install:
@echo 🔧 INSTALL
poetry install
build:
@echo 🔨 BUILD
poetry build
poetry install
openssl-fix:
export LDFLAGS=-L/usr/local/opt/openssl/lib
export CPPFLAGS=-I/usr/local/opt/openssl/include
install-gmp:
@echo 📦 Install gmp
@echo Operating System identified as $(OS)
ifeq ($(OS), Linux)
make install-gmp-linux
endif
ifeq ($(OS), Darwin)
make install-gmp-mac
endif
ifeq ($(OS), Windows)
make install-gmp-windows
endif
ifeq ($(OS), Windows_NT)
make install-gmp-windows
endif
install-gmp-mac:
@echo 🍎 MACOS INSTALL
brew install gmp || true
brew install mpfr || true
brew install libmpc || true
install-gmp-linux:
@echo 🐧 LINUX INSTALL
sudo apt-get install libgmp-dev
sudo apt-get install libmpfr-dev
sudo apt-get install libmpc-dev
install-gmp-windows:
@echo 🏁 WINDOWS INSTALL
@echo 🚨 Ensure pyproject.toml has been modified to include appropriate local gmpy2 package 🚨
# install module with local gmpy2 package
ifeq ($(IS_64_BIT), True)
@echo 64 bit system detected
endif
ifeq ($(IS_64_BIT), False)
@echo 32 bit system detected
endif
lint:
@echo 💚 LINT
@echo 1.Pylint
poetry run pylint ./src/**/*.py ./tests/**/*.py
@echo 2.Black Formatting
poetry run black --check .
@echo 3.Mypy Static Typing
poetry run mypy src/electionguard stubs
@echo 4.Package Metadata
poetry build
poetry run twine check dist/*
@echo 5.Documentation
poetry run mkdocs build --strict
auto-lint:
@echo 💚 AUTO LINT
@echo Auto-generating __init__
poetry run mkinit src/electionguard --write --black
poetry run mkinit src/electionguard_tools --write --recursive --black
poetry run mkinit src/electionguard_verify --write --black
@echo Reformatting using Black
poetry run black .
make lint
validate:
@echo ✅ VALIDATE
@poetry run python -c 'import electionguard; print(electionguard.__package__ + " successfully imported")'
# Test
unit-tests:
@echo ✅ UNIT TESTS
poetry run pytest tests/unit
property-tests:
@echo ✅ PROPERTY TESTS
poetry run pytest tests/property
integration-tests:
@echo ✅ INTEGRATION TESTS
poetry run pytest tests/integration
test:
@echo ✅ ALL TESTS
make unit-tests
make property-tests
make integration-tests
test-example:
@echo ✅ TEST Example
poetry run python3 -m pytest -s tests/integration/test_end_to_end_election.py
test-integration:
@echo ✅ INTEGRATION TESTS
poetry run pytest tests/integration
# Coverage
coverage:
@echo ✅ COVERAGE
poetry run coverage run -m pytest
poetry run coverage report --fail-under=$(CODE_COVERAGE)
coverage-html:
poetry run coverage html -d coverage
coverage-xml:
poetry run coverage xml
coverage-erase:
@poetry run coverage erase
# Benchmark
bench:
@echo 📊 BENCHMARKS
poetry run python3 -s tests/bench/bench_chaum_pedersen.py
# Documentation
install-mkdocs:
pip install mkdocs
pip install mkdocs-jupyter
docs-serve:
poetry run mkdocs serve
docs-build:
poetry run mkdocs build
docs-deploy:
@echo 🚀 DEPLOY to Github Pages
poetry run mkdocs gh-deploy --force
docs-deploy-ci:
@echo 🚀 DEPLOY to Github Pages
poetry run mkdocs gh-deploy --force
dependency-graph:
poetry run pydeps --noshow --max-bacon 2 -o dependency-graph.svg src/electionguard
dependency-graph-ci:
sudo apt install graphviz
poetry run pydeps --noshow --max-bacon 2 -o dependency-graph.svg src/electionguard
# Sample Data
generate-sample-data:
poetry run python3 src/electionguard_tools/scripts/sample_generator.py -n $(SAMPLE_BALLOT_COUNT) -s $(SAMPLE_BALLOT_SPOIL_RATE)
# Publish
publish:
poetry publish
publish-ci:
@echo 🚀 PUBLISH
poetry publish --username __token__ --password $(PYPI_TOKEN)
publish-test:
poetry publish --repository testpypi
publish-test-ci:
@echo 🚀 PUBLISH TEST
poetry publish --repository testpypi --username __token__ --password $(TEST_PYPI_TOKEN)
publish-validate:
@echo ✅ VALIDATE
python3 -m pip install --no-deps electionguard
python3 -c 'import electionguard'
publish-validate-test:
@echo ✅ VALIDATE
python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps electionguard
python3 -c 'import electionguard'
# Release
release-zip-ci:
@echo 📁 ZIP RELEASE ARTIFACTS
mv dist electionguard
mv dependency-graph.svg electionguard
zip -r electionguard.zip electionguard