Skip to content

Commit 0cfa3ac

Browse files
authored
Merge pull request #389 from c4dt/main
Merge C4DT's developments into C4DT branch
2 parents 739a78b + 5ca296c commit 0cfa3ac

File tree

277 files changed

+8163
-3668
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

277 files changed

+8163
-3668
lines changed

.env.example

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This is an example .env file with default passwords and private keys.
2+
# Do not use this in production or with any public-facing ports!
3+
BACKEND_HOST=backend # name of the 'backend' container
4+
BACKEND_PORT=5000 # port of the 'backend' container
5+
COMPOSE_FILE=./docker-compose/docker-compose.yml # Docker Compose configuration file to use
6+
DATABASE_HOST=db # name of the PostgreSQL container
7+
DATABASE_PASSWORD=Ohw0phoa # choose any PostgreSQL password
8+
DATABASE_PORT=5432 # port of the PostgreSQL container
9+
DATABASE_USERNAME=dvoting
10+
DB_PATH=dvoting # LMDB database path
11+
DELA_PROXY_URL=http://172.19.44.254:8080 # IP and port of one of the DELA containers
12+
FRONT_END_URL=http://127.0.0.1:3000 # the automated frontend tests expect this value do not change it
13+
NODEPORT=2000 # DELA node port
14+
# For public-facing services and production, this key needs to be changed!
15+
PRIVATE_KEY=6aadf480d068ac896330b726802abd0da2a5f3824f791fe8dbd4cd555e80b809
16+
PROXYPORT=8080 # DELA proxy port
17+
PUBLIC_KEY=3e5fcaed4c5d79a8eccceeb087ee0a13b8f91d917ed62017a9cd28e13b228389
18+
REACT_APP_DEV_LOGIN=true # debugging admin login /!\ disable in production /!\
19+
REACT_APP_RANDOMIZE_VOTE_ID=true # randomize voter ID for debugging /!\ disable in production /!\
20+
REACT_APP_SCIPER_ADMIN=123456 # debugging admin ID /!\ disable in production /!\
21+
REACT_APP_BLOCKLIST= # comma-separad form IDs to hide from non-admin users
22+
SESSION_SECRET=kaibaaF9 # choose any secret

.github/pull_request_template.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
Thank you for opening a pull request with this project, please also:
22

33
* [ ] add a brief description of your changes here
4-
* [ ] assign a reviewer
4+
* [ ] assign the PR to yourself, or to the person(s) working on it
55
* [ ] start in `draft` mode and `in progress` pipeline in the project (if applicable)
6-
* [ ] once it's ready put it in the `Review` or `Ready4Merge` pipeline in the project (if applicable) and remove `draft`
7-
* [ ] 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)
6+
* [ ] 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)
7+
* once it's ready
8+
* [ ] put it in the `Review` or `Ready4Merge` pipeline in the project (if applicable)
9+
* [ ] remove `draft`
10+
* [ ] assign a reviewer

.github/workflows/build-docker.yml

+26-7
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,64 @@ on:
44
push:
55
branches:
66
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened, ready_for_review]
79

810
jobs:
911
build-docker:
1012
name: Build D-Voting Docker images
1113
runs-on: ubuntu-22.04
14+
env:
15+
DockerTag: latest
16+
push: ${{ (github.ref == 'refs/heads/main') && 'true' || 'false' }}
17+
1218
steps:
1319
- name: Checkout
1420
uses: actions/checkout@v2
21+
with:
22+
fetch-depth: 0
23+
- name: Set env
24+
run: |
25+
git describe --tags
26+
echo "REACT_APP_VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
27+
echo "REACT_APP_BUILD=$(git describe --tags)" >> $GITHUB_ENV
28+
echo "REACT_APP_BUILD_TIME=$(date)" >> $GITHUB_ENV
1529
- name: Set up Docker Buildx
1630
id: buildx
1731
uses: docker/setup-buildx-action@v1
1832
- name: Login to GHCR
33+
if: ${{ env.push == 'true' }}
1934
uses: docker/login-action@v1
2035
with:
2136
registry: ghcr.io
2237
username: ${{ github.repository_owner }}
2338
password: ${{ secrets.GITHUB_TOKEN }}
39+
2440
- name: Build Frontend
2541
uses: docker/build-push-action@v2
2642
with:
2743
context: .
2844
file: Dockerfiles/Dockerfile.frontend
2945
platforms: linux/amd64
30-
push: true
31-
tags: ghcr.io/c4dt/d-voting-frontend:latest
46+
build-args: |
47+
REACT_APP_VERSION
48+
REACT_APP_BUILD
49+
REACT_APP_BUILD_TIME
50+
push: ${{ env.push }}
51+
tags: ghcr.io/dedis/d-voting-frontend:${{ env.DockerTag }}
3252
- name: Build Backend
3353
uses: docker/build-push-action@v2
3454
with:
3555
context: .
3656
file: Dockerfiles/Dockerfile.backend
3757
platforms: linux/amd64
38-
push: true
39-
tags: ghcr.io/c4dt/d-voting-backend:latest
58+
push: ${{ env.push }}
59+
tags: ghcr.io/dedis/d-voting-backend:${{ env.DockerTag }}
4060
- name: Build D-Voting
4161
uses: docker/build-push-action@v2
4262
with:
4363
context: .
44-
target: build
4564
file: Dockerfiles/Dockerfile.dela
4665
platforms: linux/amd64
47-
push: true
48-
tags: ghcr.io/c4dt/d-voting-dela:latest
66+
push: ${{ env.push }}
67+
tags: ghcr.io/dedis/d-voting-dela:${{ env.DockerTag }}

.github/workflows/go_dvoting_test.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ jobs:
1212
name: Scenario
1313
runs-on: ubuntu-latest
1414
steps:
15-
- name: Set up Go ^1.17
16-
uses: actions/setup-go@v2
15+
- name: Use Go 1.20
16+
uses: actions/setup-go@v4
1717
with:
18-
go-version: ^1.17
18+
go-version: '1.20'
1919

2020
- name: Install crypto util from Dela
2121
run: |
22-
git clone https://github.com/c4dt/dela.git
22+
git clone https://github.com/dedis/dela.git
2323
cd dela
2424
go install ./cli/crypto
2525

.github/workflows/go_integration_tests.yml

+18-13
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111
name: Integration test
1212
runs-on: ubuntu-latest
1313
steps:
14-
- name: Set up Go ^1.17
15-
uses: actions/setup-go@v2
14+
- name: Use Go 1.20
15+
uses: actions/setup-go@v4
1616
with:
17-
go-version: ^1.17
17+
go-version: '1.20'
1818

1919
- name: Check out code into the Go module directory
2020
uses: actions/checkout@v2
@@ -25,10 +25,10 @@ jobs:
2525
name: Test bad vote
2626
runs-on: ubuntu-latest
2727
steps:
28-
- name: Set up Go ^1.17
29-
uses: actions/setup-go@v2
28+
- name: Use Go 1.20
29+
uses: actions/setup-go@v4
3030
with:
31-
go-version: ^1.17
31+
go-version: '1.20'
3232

3333
- name: Check out code into the Go module directory
3434
uses: actions/checkout@v2
@@ -39,24 +39,29 @@ jobs:
3939
name: Test crash
4040
runs-on: ubuntu-latest
4141
steps:
42-
- name: Set up Go ^1.17
43-
uses: actions/setup-go@v2
42+
- name: Use Go 1.20
43+
uses: actions/setup-go@v4
4444
with:
45-
go-version: ^1.17
45+
go-version: '1.20'
4646

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

5050
- name: Run the crash test
51-
run: go test -timeout 10m -run TestCrash ./integration/...
51+
run: |
52+
for a in $( seq 3 ); do
53+
echo "Testing sequence $a"
54+
go test -timeout 10m -run TestCrash ./integration/... && exit 0
55+
done
56+
exit 1
5257
revote:
5358
name: Test revote
5459
runs-on: ubuntu-latest
5560
steps:
56-
- name: Set up Go ^1.17
57-
uses: actions/setup-go@v2
61+
- name: Use Go 1.20
62+
uses: actions/setup-go@v4
5863
with:
59-
go-version: ^1.17
64+
go-version: '1.20'
6065

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

.github/workflows/go_scenario_test.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ jobs:
1111
name: Tests
1212
runs-on: ubuntu-latest
1313
steps:
14-
- name: Set up Go ^1.17
15-
uses: actions/setup-go@v2
14+
- name: Use Go 1.20
15+
uses: actions/setup-go@v4
1616
with:
17-
go-version: ^1.17
17+
go-version: '1.20'
1818

1919
- name: Install crypto util from Dela
2020
run: |
21-
git clone https://github.com/c4dt/dela.git
21+
git clone https://github.com/dedis/dela.git
2222
cd dela
2323
go install ./cli/crypto
2424

.github/workflows/go_test.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@ jobs:
1010
name: Tests
1111
runs-on: ubuntu-latest
1212
steps:
13-
- name: Use Go >= 1.19
14-
uses: actions/setup-go@v3
13+
- name: Use Go 1.20
14+
uses: actions/setup-go@v4
1515
with:
16-
go-version: '>=1.19'
16+
go-version: '1.20'
1717
id: go
1818

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

22-
- name: Run lint
23-
run: make lint
24-
22+
# TODO: https://github.com/dedis/d-voting/issues/392
23+
# - name: Run lint
24+
# run: make lint
25+
#
2526
- name: Run vet
2627
run: make vet
2728

.github/workflows/releases.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
- name: checkout
1414
uses: actions/checkout@v3
1515

16-
- name: Use go
17-
uses: actions/setup-go@v3
16+
- name: Use Go 1.20
17+
uses: actions/setup-go@v4
1818
with:
19-
go-version: '>=1.18'
19+
go-version: '1.20'
2020

2121
- name: Install fpm
2222
run: |

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,25 @@ Latest changes in each category go to the top
99
## [Unreleased]
1010

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

1417
### Changed
18+
- for the Dockerfiles and docker-compose.yml, `DELA_NODE_URL` has been replaced with `DELA_PROXY_URL`,
19+
which is the more accurate name.
20+
- the actions in package.json for the frontend changed. Both are somewhat development mode,
21+
as the webserver is not supposed to be used in production.
22+
- `start`: starts in plain mode
23+
- `start-https`: starts in HTTPS mode
24+
1525
### Deprecated
1626
### Removed
1727
### Fixed
28+
- Proxy editing fixed: adding, modifying, deleting now works
29+
- When fetching form and user updates, only do it when showing the activity
30+
- Redirection when form doesn't exist and nicer error message
1831
- File formatting and errors in comments
1932
- Popup when voting and some voting translation fixes
2033
- Fixed return error when voting

Dockerfiles/Dockerfile.dela

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
FROM golang:1.20.6-bookworm AS base
2-
RUN apt-get update && apt-get install git
3-
# make sure we're using the same head as d-voting
4-
RUN git clone https://github.com/c4dt/dela.git
5-
WORKDIR /go/dela/cli/crypto
6-
RUN go install
2+
RUN apt-get update -y && apt-get install -y git
73
WORKDIR /go/d-voting
4+
COPY go.mod .
5+
COPY go.sum .
6+
RUN go mod download
87
COPY . .
9-
10-
FROM base AS build
11-
COPY --from=base /go/dela .
12-
COPY --from=base /go/d-voting .
8+
ENV GOCACHE=/root/.cache/go-build
139
WORKDIR /go/d-voting/cli/dvoting
14-
RUN go build
15-
ENV PATH=/go/dela/cli/crypto:/go/d-voting/cli/dvoting:${PATH}
10+
RUN --mount=type=cache,target="/root/.cache/go-build" go install
11+
# make sure we're using the same head as d-voting
12+
RUN --mount=type=cache,target="/root/.cache/go-build" cd $( go list -f '{{.Dir}}' go.dedis.ch/dela )/cli/crypto && go install
13+
14+
FROM golang:1.20.6-bookworm AS build
15+
WORKDIR /usr/local/bin
16+
COPY --from=base /go/bin/crypto .
17+
COPY --from=base /go/bin/dvoting .
1618
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"]
1719
CMD []

Dockerfiles/Dockerfile.frontend

+7
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,12 @@ ENV REACT_APP_NOMOCK=on
55
WORKDIR /web/frontend
66
COPY ../web/frontend .
77
RUN npm install
8+
ARG REACT_APP_VERSION=unknown
9+
ARG REACT_APP_BUILD=unknown
10+
ARG REACT_APP_BUILD_TIME=after_2024_03
11+
ENV REACT_APP_VERSION=$REACT_APP_VERSION
12+
ENV REACT_APP_BUILD=$REACT_APP_BUILD
13+
ENV REACT_APP_BUILD_TIME=$REACT_APP_BUILD_TIME
14+
815
ENTRYPOINT ["npm"]
916
CMD ["start"]

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version=$(shell git describe --abbrev=0 --tags || echo '0.0.0')
2-
versionFlag="github.com/c4dt/d-voting.Version=$(version)"
2+
versionFlag="github.com/dedis/d-voting.Version=$(version)"
33
versionFile=$(shell echo $(version) | tr . _)
4-
timeFlag="github.com/c4dt/d-voting.BuildTime=$(shell date +'%d/%m/%y_%H:%M')"
4+
timeFlag="github.com/dedis/d-voting.BuildTime=$(shell date +'%d/%m/%y_%H:%M')"
55

66
lint:
77
# Coding style static check.

0 commit comments

Comments
 (0)