Skip to content

Commit

Permalink
Merge pull request #389 from c4dt/main
Browse files Browse the repository at this point in the history
Merge C4DT's developments into C4DT branch
  • Loading branch information
ineiti authored Oct 10, 2024
2 parents 739a78b + 5ca296c commit 0cfa3ac
Show file tree
Hide file tree
Showing 277 changed files with 8,163 additions and 3,668 deletions.
22 changes: 22 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This is an example .env file with default passwords and private keys.
# Do not use this in production or with any public-facing ports!
BACKEND_HOST=backend # name of the 'backend' container
BACKEND_PORT=5000 # port of the 'backend' container
COMPOSE_FILE=./docker-compose/docker-compose.yml # Docker Compose configuration file to use
DATABASE_HOST=db # name of the PostgreSQL container
DATABASE_PASSWORD=Ohw0phoa # choose any PostgreSQL password
DATABASE_PORT=5432 # port of the PostgreSQL container
DATABASE_USERNAME=dvoting
DB_PATH=dvoting # LMDB database path
DELA_PROXY_URL=http://172.19.44.254:8080 # IP and port of one of the DELA containers
FRONT_END_URL=http://127.0.0.1:3000 # the automated frontend tests expect this value do not change it
NODEPORT=2000 # DELA node port
# For public-facing services and production, this key needs to be changed!
PRIVATE_KEY=6aadf480d068ac896330b726802abd0da2a5f3824f791fe8dbd4cd555e80b809
PROXYPORT=8080 # DELA proxy port
PUBLIC_KEY=3e5fcaed4c5d79a8eccceeb087ee0a13b8f91d917ed62017a9cd28e13b228389
REACT_APP_DEV_LOGIN=true # debugging admin login /!\ disable in production /!\
REACT_APP_RANDOMIZE_VOTE_ID=true # randomize voter ID for debugging /!\ disable in production /!\
REACT_APP_SCIPER_ADMIN=123456 # debugging admin ID /!\ disable in production /!\
REACT_APP_BLOCKLIST= # comma-separad form IDs to hide from non-admin users
SESSION_SECRET=kaibaaF9 # choose any secret
9 changes: 6 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
Thank you for opening a pull request with this project, please also:

* [ ] add a brief description of your changes here
* [ ] assign a reviewer
* [ ] assign the PR to yourself, or to the person(s) working on it
* [ ] start in `draft` mode and `in progress` pipeline in the project (if applicable)
* [ ] once it's ready put it in the `Review` or `Ready4Merge` pipeline in the project (if applicable) and remove `draft`
* [ ] if applicable, add this PR to its related issue by one of the special keywords (https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue)
* [ ] if applicable, add this PR to its related issue by one of the special keywords [Closing keywords](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue)
* once it's ready
* [ ] put it in the `Review` or `Ready4Merge` pipeline in the project (if applicable)
* [ ] remove `draft`
* [ ] assign a reviewer
33 changes: 26 additions & 7 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,64 @@ on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
build-docker:
name: Build D-Voting Docker images
runs-on: ubuntu-22.04
env:
DockerTag: latest
push: ${{ (github.ref == 'refs/heads/main') && 'true' || 'false' }}

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set env
run: |
git describe --tags
echo "REACT_APP_VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
echo "REACT_APP_BUILD=$(git describe --tags)" >> $GITHUB_ENV
echo "REACT_APP_BUILD_TIME=$(date)" >> $GITHUB_ENV
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to GHCR
if: ${{ env.push == 'true' }}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Frontend
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfiles/Dockerfile.frontend
platforms: linux/amd64
push: true
tags: ghcr.io/c4dt/d-voting-frontend:latest
build-args: |
REACT_APP_VERSION
REACT_APP_BUILD
REACT_APP_BUILD_TIME
push: ${{ env.push }}
tags: ghcr.io/dedis/d-voting-frontend:${{ env.DockerTag }}
- name: Build Backend
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfiles/Dockerfile.backend
platforms: linux/amd64
push: true
tags: ghcr.io/c4dt/d-voting-backend:latest
push: ${{ env.push }}
tags: ghcr.io/dedis/d-voting-backend:${{ env.DockerTag }}
- name: Build D-Voting
uses: docker/build-push-action@v2
with:
context: .
target: build
file: Dockerfiles/Dockerfile.dela
platforms: linux/amd64
push: true
tags: ghcr.io/c4dt/d-voting-dela:latest
push: ${{ env.push }}
tags: ghcr.io/dedis/d-voting-dela:${{ env.DockerTag }}
8 changes: 4 additions & 4 deletions .github/workflows/go_dvoting_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ jobs:
name: Scenario
runs-on: ubuntu-latest
steps:
- name: Set up Go ^1.17
uses: actions/setup-go@v2
- name: Use Go 1.20
uses: actions/setup-go@v4
with:
go-version: ^1.17
go-version: '1.20'

- name: Install crypto util from Dela
run: |
git clone https://github.com/c4dt/dela.git
git clone https://github.com/dedis/dela.git
cd dela
go install ./cli/crypto
Expand Down
31 changes: 18 additions & 13 deletions .github/workflows/go_integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
name: Integration test
runs-on: ubuntu-latest
steps:
- name: Set up Go ^1.17
uses: actions/setup-go@v2
- name: Use Go 1.20
uses: actions/setup-go@v4
with:
go-version: ^1.17
go-version: '1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand All @@ -25,10 +25,10 @@ jobs:
name: Test bad vote
runs-on: ubuntu-latest
steps:
- name: Set up Go ^1.17
uses: actions/setup-go@v2
- name: Use Go 1.20
uses: actions/setup-go@v4
with:
go-version: ^1.17
go-version: '1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand All @@ -39,24 +39,29 @@ jobs:
name: Test crash
runs-on: ubuntu-latest
steps:
- name: Set up Go ^1.17
uses: actions/setup-go@v2
- name: Use Go 1.20
uses: actions/setup-go@v4
with:
go-version: ^1.17
go-version: '1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Run the crash test
run: go test -timeout 10m -run TestCrash ./integration/...
run: |
for a in $( seq 3 ); do
echo "Testing sequence $a"
go test -timeout 10m -run TestCrash ./integration/... && exit 0
done
exit 1
revote:
name: Test revote
runs-on: ubuntu-latest
steps:
- name: Set up Go ^1.17
uses: actions/setup-go@v2
- name: Use Go 1.20
uses: actions/setup-go@v4
with:
go-version: ^1.17
go-version: '1.20'

- name: Check out code into the Go module directory
uses: actions/checkout@v2
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/go_scenario_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ jobs:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Set up Go ^1.17
uses: actions/setup-go@v2
- name: Use Go 1.20
uses: actions/setup-go@v4
with:
go-version: ^1.17
go-version: '1.20'

- name: Install crypto util from Dela
run: |
git clone https://github.com/c4dt/dela.git
git clone https://github.com/dedis/dela.git
cd dela
go install ./cli/crypto
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/go_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ jobs:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Use Go >= 1.19
uses: actions/setup-go@v3
- name: Use Go 1.20
uses: actions/setup-go@v4
with:
go-version: '>=1.19'
go-version: '1.20'
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: Run lint
run: make lint

# TODO: https://github.com/dedis/d-voting/issues/392
# - name: Run lint
# run: make lint
#
- name: Run vet
run: make vet

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
- name: checkout
uses: actions/checkout@v3

- name: Use go
uses: actions/setup-go@v3
- name: Use Go 1.20
uses: actions/setup-go@v4
with:
go-version: '>=1.18'
go-version: '1.20'

- name: Install fpm
run: |
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,25 @@ Latest changes in each category go to the top
## [Unreleased]

### Added
- dev_login can change userId when clicking on the user in the upper right
- admin can now add users as voters
- New debugging variables in [local_vars.sh](./scripts/local_vars.sh)
- Changelog - please use it

### Changed
- for the Dockerfiles and docker-compose.yml, `DELA_NODE_URL` has been replaced with `DELA_PROXY_URL`,
which is the more accurate name.
- the actions in package.json for the frontend changed. Both are somewhat development mode,
as the webserver is not supposed to be used in production.
- `start`: starts in plain mode
- `start-https`: starts in HTTPS mode

### Deprecated
### Removed
### Fixed
- Proxy editing fixed: adding, modifying, deleting now works
- When fetching form and user updates, only do it when showing the activity
- Redirection when form doesn't exist and nicer error message
- File formatting and errors in comments
- Popup when voting and some voting translation fixes
- Fixed return error when voting
Expand Down
24 changes: 13 additions & 11 deletions Dockerfiles/Dockerfile.dela
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
FROM golang:1.20.6-bookworm AS base
RUN apt-get update && apt-get install git
# make sure we're using the same head as d-voting
RUN git clone https://github.com/c4dt/dela.git
WORKDIR /go/dela/cli/crypto
RUN go install
RUN apt-get update -y && apt-get install -y git
WORKDIR /go/d-voting
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .

FROM base AS build
COPY --from=base /go/dela .
COPY --from=base /go/d-voting .
ENV GOCACHE=/root/.cache/go-build
WORKDIR /go/d-voting/cli/dvoting
RUN go build
ENV PATH=/go/dela/cli/crypto:/go/d-voting/cli/dvoting:${PATH}
RUN --mount=type=cache,target="/root/.cache/go-build" go install
# make sure we're using the same head as d-voting
RUN --mount=type=cache,target="/root/.cache/go-build" cd $( go list -f '{{.Dir}}' go.dedis.ch/dela )/cli/crypto && go install

FROM golang:1.20.6-bookworm AS build
WORKDIR /usr/local/bin
COPY --from=base /go/bin/crypto .
COPY --from=base /go/bin/dvoting .
ENTRYPOINT ["/bin/bash", "-c", "dvoting --config /data/node start --postinstall --proxyaddr :$PROXYPORT --proxykey $PROXYKEY --listen tcp://0.0.0.0:2000 --public $PUBLIC_URL --routing tree --noTLS"]
CMD []
7 changes: 7 additions & 0 deletions Dockerfiles/Dockerfile.frontend
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@ ENV REACT_APP_NOMOCK=on
WORKDIR /web/frontend
COPY ../web/frontend .
RUN npm install
ARG REACT_APP_VERSION=unknown
ARG REACT_APP_BUILD=unknown
ARG REACT_APP_BUILD_TIME=after_2024_03
ENV REACT_APP_VERSION=$REACT_APP_VERSION
ENV REACT_APP_BUILD=$REACT_APP_BUILD
ENV REACT_APP_BUILD_TIME=$REACT_APP_BUILD_TIME

ENTRYPOINT ["npm"]
CMD ["start"]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version=$(shell git describe --abbrev=0 --tags || echo '0.0.0')
versionFlag="github.com/c4dt/d-voting.Version=$(version)"
versionFlag="github.com/dedis/d-voting.Version=$(version)"
versionFile=$(shell echo $(version) | tr . _)
timeFlag="github.com/c4dt/d-voting.BuildTime=$(shell date +'%d/%m/%y_%H:%M')"
timeFlag="github.com/dedis/d-voting.BuildTime=$(shell date +'%d/%m/%y_%H:%M')"

lint:
# Coding style static check.
Expand Down
Loading

0 comments on commit 0cfa3ac

Please sign in to comment.