Skip to content

Commit

Permalink
Add tally missing trustees feature (#202)
Browse files Browse the repository at this point in the history
* style: remove unused imports

* feat: add command to report missing trustees

* feat: implement missing trustee for dummy scheme

* feat: implement missing trustee for electionguard scheme

* feat: add missing trustee to elections sandbox

* feat: add missing trustees report to clients

* fix : minor fixes and improvements

* chore: bump versions

* doc: update changelog

* style: fix lint issues

* chore: bump python and EG versions

* fix: solve lint issues and broken tests

* chore: upload test server log for e2e tests

* test: don't use chrome for e2e tests

* chore: increate e2e tests consistency

* test: increase e2e timeout for compensation
  • Loading branch information
leio10 authored Sep 6, 2021
1 parent e22d715 commit 6456923
Show file tree
Hide file tree
Showing 78 changed files with 1,455 additions and 690 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.8-electionguard-1.2.0
FROM codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.11-electionguard-1.2.1
LABEL author="[email protected]"

# [Option] Install zsh
Expand All @@ -19,7 +19,7 @@ ARG USERNAME=automatic
ARG USER_UID=1000
ARG USER_GID=$USER_UID
COPY library-scripts/*.sh /tmp/library-scripts/
RUN apt-get update \
RUN apt-get update --allow-releaseinfo-change \
&& /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" \
# Use Docker script from script library to set things up
&& /bin/bash /tmp/library-scripts/docker-debian.sh "${ENABLE_NONROOT_DOCKER}" "/var/run/docker-host.sock" "/var/run/docker.sock" "${USERNAME}" \
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"forwardPorts": [8000],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "apt-get update && apt-get install -y libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb && make install build"
"postCreateCommand": "apt-get update --allow-releaseinfo-change && apt-get install -y libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb && make install build install_test_e2e"

// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "vscode"
Expand Down
20 changes: 10 additions & 10 deletions .devcontainer/library-scripts/common-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ apt-get-update-if-needed()
{
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update
apt-get update --allow-releaseinfo-change
else
echo "Skipping apt-get update."
fi
Expand Down Expand Up @@ -113,7 +113,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then
if [[ ! -z $(apt-cache --names-only search ^libssl1.1$) ]]; then
PACKAGE_LIST="${PACKAGE_LIST} libssl1.1"
fi

# Install appropriate version of libssl1.0.x if available
LIBSSL=$(dpkg-query -f '${db:Status-Abbrev}\t${binary:Package}\n' -W 'libssl1\.0\.?' 2>&1 || echo '')
if [ "$(echo "$LIBSSL" | grep -o 'libssl1\.0\.[0-9]:' | uniq | sort | wc -l)" -eq 0 ]; then
Expand All @@ -128,7 +128,7 @@ if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then

echo "Packages to verify are installed: ${PACKAGE_LIST}"
apt-get -y install --no-install-recommends ${PACKAGE_LIST} 2> >( grep -v 'debconf: delaying package configuration, since apt-utils is not installed' >&2 )

PACKAGES_ALREADY_INSTALLED="true"
fi

Expand All @@ -142,19 +142,19 @@ fi
# Ensure at least the en_US.UTF-8 UTF-8 locale is available.
# Common need for both applications and things like the agnoster ZSH theme.
if [ "${LOCALE_ALREADY_SET}" != "true" ] && ! grep -o -E '^\s*en_US.UTF-8\s+UTF-8' /etc/locale.gen > /dev/null; then
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen
LOCALE_ALREADY_SET="true"
fi

# Create or update a non-root user to match UID/GID.
if id -u ${USERNAME} > /dev/null 2>&1; then
# User exists, update if needed
if [ "${USER_GID}" != "automatic" ] && [ "$USER_GID" != "$(id -G $USERNAME)" ]; then
groupmod --gid $USER_GID $USERNAME
if [ "${USER_GID}" != "automatic" ] && [ "$USER_GID" != "$(id -G $USERNAME)" ]; then
groupmod --gid $USER_GID $USERNAME
usermod --gid $USER_GID $USERNAME
fi
if [ "${USER_UID}" != "automatic" ] && [ "$USER_UID" != "$(id -u $USERNAME)" ]; then
if [ "${USER_UID}" != "automatic" ] && [ "$USER_UID" != "$(id -u $USERNAME)" ]; then
usermod --uid $USER_UID $USERNAME
fi
else
Expand All @@ -164,7 +164,7 @@ else
else
groupadd --gid $USER_GID $USERNAME
fi
if [ "${USER_UID}" = "automatic" ]; then
if [ "${USER_UID}" = "automatic" ]; then
useradd -s /bin/bash --gid $USERNAME -m $USERNAME
else
useradd -s /bin/bash --uid $USER_UID --gid $USERNAME -m $USERNAME
Expand All @@ -179,7 +179,7 @@ if [ "${USERNAME}" != "root" ] && [ "${EXISTING_NON_ROOT_USER}" != "${USERNAME}"
fi

# ** Shell customization section **
if [ "${USERNAME}" = "root" ]; then
if [ "${USERNAME}" = "root" ]; then
USER_RC_PATH="/root"
else
USER_RC_PATH="/home/${USERNAME}"
Expand Down Expand Up @@ -240,7 +240,7 @@ CODESPACES_ZSH="$(cat \
<<'EOF'
__zsh_prompt() {
local prompt_username
if [ ! -z "${GITHUB_USER}" ]; then
if [ ! -z "${GITHUB_USER}" ]; then
prompt_username="@${GITHUB_USER}"
else
prompt_username="%n"
Expand Down
20 changes: 10 additions & 10 deletions .devcontainer/library-scripts/docker-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ apt-get-update-if-needed()
{
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update
apt-get update --allow-releaseinfo-change
else
echo "Skipping apt-get update."
fi
Expand All @@ -55,7 +55,7 @@ export DEBIAN_FRONTEND=noninteractive
# Install apt-transport-https, curl, lsb-release, gpg if missing
if ! dpkg -s apt-transport-https curl ca-certificates lsb-release > /dev/null 2>&1 || ! type gpg > /dev/null 2>&1; then
apt-get-update-if-needed
apt-get -y install --no-install-recommends apt-transport-https curl ca-certificates lsb-release gnupg2
apt-get -y install --no-install-recommends apt-transport-https curl ca-certificates lsb-release gnupg2
fi

# Install Docker / Moby CLI if not already installed
Expand All @@ -67,17 +67,17 @@ else
CODENAME=$(lsb_release -cs)
curl -s https://packages.microsoft.com/keys/microsoft.asc | (OUT=$(apt-key add - 2>&1) || echo $OUT)
echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-${DISTRO}-${CODENAME}-prod ${CODENAME} main" > /etc/apt/sources.list.d/microsoft.list
apt-get update
apt-get update --allow-releaseinfo-change
apt-get -y install --no-install-recommends moby-cli
else
curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT)
echo "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list
apt-get update
apt-get update --allow-releaseinfo-change
apt-get -y install --no-install-recommends docker-ce-cli
fi
fi

# Install Docker Compose if not already installed
# Install Docker Compose if not already installed
if type docker-compose > /dev/null 2>&1; then
echo "Docker Compose already installed."
else
Expand Down Expand Up @@ -105,13 +105,13 @@ if [ "${ENABLE_NONROOT_DOCKER}" = "false" ] || [ "${USERNAME}" = "root" ]; then
fi

# If enabling non-root access and specified user is found, setup socat and add script
chown -h "${USERNAME}":root "${TARGET_SOCKET}"
chown -h "${USERNAME}":root "${TARGET_SOCKET}"
if ! dpkg -s socat > /dev/null 2>&1; then
apt-get-update-if-needed
apt-get -y install socat
fi
tee /usr/local/share/docker-init.sh > /dev/null \
<< EOF
<< EOF
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
Expand Down Expand Up @@ -143,8 +143,8 @@ log()
echo -e "\n** \$(date) **" | sudoIf tee -a \${SOCAT_LOG} > /dev/null
log "Ensuring ${USERNAME} has access to ${SOURCE_SOCKET} via ${TARGET_SOCKET}"
# If enabled, try to add a docker group with the right GID. If the group is root,
# fall back on using socat to forward the docker socket to another unix socket so
# If enabled, try to add a docker group with the right GID. If the group is root,
# fall back on using socat to forward the docker socket to another unix socket so
# that we can set permissions on it without affecting the host.
if [ "${ENABLE_NONROOT_DOCKER}" = "true" ] && [ "${SOURCE_SOCKET}" != "${TARGET_SOCKET}" ] && [ "${USERNAME}" != "root" ] && [ "${USERNAME}" != "0" ]; then
SOCKET_GID=\$(stat -c '%g' ${SOURCE_SOCKET})
Expand All @@ -171,7 +171,7 @@ if [ "${ENABLE_NONROOT_DOCKER}" = "true" ] && [ "${SOURCE_SOCKET}" != "${TARGET_
log "Success"
fi
# Execute whatever commands were passed in (if any). This allows us
# Execute whatever commands were passed in (if any). This allows us
# to set this script to ENTRYPOINT while still executing the default CMD.
set +e
exec "\$@"
Expand Down
34 changes: 14 additions & 20 deletions .github/workflows/server-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: Build electionguard
runs-on: ubuntu-latest
container:
image: codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.8-electionguard-1.2.0
image: codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.11-electionguard-1.2.1
steps:
- uses: actions/[email protected]
with:
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
runs-on: ubuntu-latest
if: ${{ needs.check_python_to_js_cache.outputs.cache-hit != 'true' }}
container:
image: codegram/pyodide-electionguard:pyodide-0.16.1-electionguard-1.2.0
image: codegram/pyodide-electionguard:pyodide-0.16.1-electionguard-1.2.1
steps:
- uses: actions/[email protected]
with:
Expand Down Expand Up @@ -121,7 +121,7 @@ jobs:
needs: build_python_to_js
runs-on: ubuntu-latest
container:
image: codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.8-electionguard-1.2.0
image: codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.11-electionguard-1.2.1
services:
postgres:
image: postgres:11
Expand Down Expand Up @@ -234,7 +234,7 @@ jobs:
needs: [check_python_to_js_cache, build_python_to_js]
runs-on: ubuntu-latest
container:
image: codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.8-electionguard-1.2.0
image: codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.11-electionguard-1.2.1
services:
postgres:
image: postgres:11
Expand Down Expand Up @@ -314,26 +314,20 @@ jobs:
cd bulletin_board/server
bundler exec rails db:create
bundler exec rails db:migrate
- name: Install Chrome
- name: Install e2e tests dependencies
run: |
sudo apt-get update
sudo apt-get install -y unzip xvfb libxi6 libgconf-2-4
sudo curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add
sudo echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
sudo apt-get -y update
sudo apt-get -y install google-chrome-stable
wget https://chromedriver.storage.googleapis.com/90.0.4430.24/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo mv chromedriver /usr/bin/chromedriver
sudo chown root:root /usr/bin/chromedriver
sudo chmod +x /usr/bin/chromedriver
make install_test_e2e
- name: Run e2e tests
run: |
cd bulletin_board/server
npm run e2e:install
bundle exec rails s -e test -p 5017 &
make serve_test &
sleep 5
npm run e2e:tests -- --browser chrome --headless
make test_e2e
- name: Upload artifacts (server logs)
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: test server logs
path: bulletin_board/server/log/
- name: Upload artifacts (screenshots)
if: ${{ always() }}
uses: actions/upload-artifact@v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ env:
CI: "true"
SIMPLECOV: "true"
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
PYTHON_VERSION: "3.8.8"

defaults:
run:
Expand All @@ -23,6 +22,8 @@ jobs:
tests:
name: Test code
runs-on: ubuntu-latest
container:
image: codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.11-electionguard-1.2.1
steps:
- uses: rokroskar/[email protected]
if: "github.ref != 'refs/heads/develop'"
Expand All @@ -32,9 +33,6 @@ jobs:
with:
fetch-depth: 1
submodules: true
- uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Add Poetry to path
run: echo "$HOME/.poetry/bin" >> $GITHUB_PATH
- name: Install dependencies
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## Added

- The bulletin board client now includes a `report_missing_trustee` method to report the absence of a trustee during the Tally phase.

## [0.21.2] - 2021-05-28

## [0.21.1] - 2021-04-23
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This stage builds the python-wrapper package
FROM codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.8-electionguard-1.2.0 as python-wrapper-builder
FROM codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.11-electionguard-1.2.1 as python-wrapper-builder
LABEL author="[email protected]"

# Add Makefiles
Expand All @@ -17,7 +17,7 @@ ADD voting_schemes/electionguard/python-wrapper /code/voting_schemes/electiongua
RUN cd /code && make build_electionguard_python_wrapper

# This stage builds the pyodide packages for the previous python packages
FROM codegram/pyodide-electionguard:pyodide-0.16.1-electionguard-1.2.0 as python-to-js-builder
FROM codegram/pyodide-electionguard:pyodide-0.16.1-electionguard-1.2.1 as python-to-js-builder
LABEL author="[email protected]"

ENV PYODIDE_PACKAGES "electionguard,bulletin_board-electionguard"
Expand All @@ -43,15 +43,15 @@ RUN make
RUN cp -rf /code/voting_schemes/electionguard/python-to-js/override/* /src/pyodide/build/

# This stage builds the bulletin-board application
FROM codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.8-electionguard-1.2.0
FROM codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.11-electionguard-1.2.1
LABEL author="[email protected]"

# Environment variables
ENV SECRET_KEY_BASE 1234
ENV RAILS_ENV production

# Install system dependencies
RUN apt-get update && \
RUN apt-get update --allow-releaseinfo-change && \
apt-get install -y postgresql postgresql-client postgresql-contrib libpq-dev \
redis-server memcached imagemagick ffmpeg mupdf mupdf-tools libxml2-dev && \
rm -rf /var/lib/apt/lists/*
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile.web
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This stage builds the python-wrapper package
FROM codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.8-electionguard-1.2.0 as python-wrapper-builder
FROM codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.11-electionguard-1.2.1 as python-wrapper-builder
LABEL author="[email protected]"

# Add Makefiles
Expand All @@ -17,7 +17,7 @@ ADD voting_schemes/electionguard/python-wrapper /code/voting_schemes/electiongua
RUN cd /code && make build_electionguard_python_wrapper

# This stage builds the pyodide packages for the previous python packages
FROM codegram/pyodide-electionguard:pyodide-0.16.1-electionguard-1.2.0 as python-to-js-builder
FROM codegram/pyodide-electionguard:pyodide-0.16.1-electionguard-1.2.1 as python-to-js-builder
LABEL author="[email protected]"

ENV PYODIDE_PACKAGES "electionguard,bulletin_board-electionguard"
Expand All @@ -43,15 +43,15 @@ RUN make
RUN cp -rf /code/voting_schemes/electionguard/python-to-js/override/* /src/pyodide/build/

# This stage builds the bulletin-board application
FROM codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.8-electionguard-1.2.0
FROM codegram/ruby-node-python-electionguard:ruby-2.6.6-node-15-python-3.8.11-electionguard-1.2.1
LABEL author="[email protected]"

# Environment variables
ENV SECRET_KEY_BASE 1234
ENV RAILS_ENV production

# Install system dependencies
RUN apt-get update && \
RUN apt-get update --allow-releaseinfo-change && \
apt-get install -y postgresql postgresql-client postgresql-contrib libpq-dev \
redis-server memcached imagemagick ffmpeg mupdf mupdf-tools libxml2-dev && \
rm -rf /var/lib/apt/lists/*
Expand Down
4 changes: 2 additions & 2 deletions bulletin_board/js-client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bulletin_board/js-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codegram/decidim-bulletin_board",
"version": "0.21.2",
"version": "0.21.3",
"description": "",
"main": "src/index.js",
"scripts": {
Expand Down
Loading

0 comments on commit 6456923

Please sign in to comment.