Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/cypress-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,34 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Configure proper Docker layer caching
- name: Set up Docker Cache
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Build and start Docker containers
run: |
# Build with proper cache configuration
docker buildx build \
--cache-from=type=local,src=${{ github.workspace }}/.buildx-cache \
--cache-to=type=local,dest=${{ github.workspace }}/.buildx-cache-new,mode=max \
--load \
-f server/Dockerfile \
./server

# Move cache to prevent cache growth
rm -rf ${{ github.workspace }}/.buildx-cache
mv ${{ github.workspace }}/.buildx-cache-new ${{ github.workspace }}/.buildx-cache

# Start containers
docker compose -f docker-compose.yml -f docker-compose.test.yml --env-file test.env --profile postgres up -d --build
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1

- name: Health Check the Server http response
uses: jtalk/url-health-check-action@v4
Expand Down
95 changes: 64 additions & 31 deletions .github/workflows/jest-server-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,83 @@ on:
jobs:
jest-run:
runs-on: ubuntu-latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: PdwPNS2mDN73Vfbc
POSTGRES_DB: polis-test
POSTGRES_PORT: 5432
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: ${{ env.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ env.POSTGRES_DB }}
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres -d polis-test"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup env
run: |
cp example.env .env

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and start Docker containers
run: |
docker compose -f docker-compose.yml -f docker-compose.dev.yml --profile postgres up postgres -d --build


- uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
# Configure proper Docker layer caching
- name: Set up Docker Cache
uses: actions/cache@v3
with:
node-version: "18"
cache: "npm"
cache-dependency-path: server/package-lock.json
path: ${{ github.workspace }}/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Copy test.env to .env and configure for GHA service
run: |
cp test.env .env
echo "POSTGRES_HOST=172.17.0.1" >> .env
echo "DATABASE_URL=postgres://${{ env.POSTGRES_USER }}:${{ env.POSTGRES_PASSWORD }}@172.17.0.1:${{ env.POSTGRES_PORT }}/${{ env.POSTGRES_DB }}" >> .env

- name: Setup env in server
working-directory: server
- name: Build and start Docker containers (excluding Postgres)
run: |
cp example.env .env
# Build with proper cache configuration
docker buildx build \
--cache-from=type=local,src=${{ github.workspace }}/.buildx-cache \
--cache-to=type=local,dest=${{ github.workspace }}/.buildx-cache-new,mode=max \
--load \
-f server/Dockerfile \
./server

# Move cache to prevent cache growth
rm -rf ${{ github.workspace }}/.buildx-cache
mv ${{ github.workspace }}/.buildx-cache-new ${{ github.workspace }}/.buildx-cache

# Start containers - remove --profile postgres as GHA service handles postgres
docker compose -f docker-compose.yml -f docker-compose.test.yml up -d --build
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1

- name: Install dependencies
working-directory: server
run: npm install
- name: Run database migrations
env:
# Construct DATABASE_URL for the migration script
# using the same host (172.17.0.1) and credentials as the application
DATABASE_URL: postgres://${{ env.POSTGRES_USER }}:${{ env.POSTGRES_PASSWORD }}@172.17.0.1:${{ env.POSTGRES_PORT }}/${{ env.POSTGRES_DB }}
run: |
echo "Installing postgresql-client..."
sudo apt-get update -y
sudo apt-get install -y postgresql-client
echo "Running migrations..."
bash server/bin/run-migrations.sh

- name: Build & start server
working-directory: server
- name: Run Jest tests
run: |
npm run build
nohup npm run serve &

- name: Jest test
working-directory: server
run: npm run test
docker exec polis-test-server-1 npm test

- name: Stop Docker containers
if: always()
run: docker compose -f docker-compose.yml -f docker-compose.test.yml --env-file test.env --profile postgres down
run: docker compose -f docker-compose.yml -f docker-compose.test.yml --profile postgres down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ prod.env
xids.csv
preprod.env
.venv

**/CLAUDE.local.md
2 changes: 1 addition & 1 deletion client-participation/api/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
iframe.style.border = o.border || "1px solid #ccc";
iframe.style.borderRadius = o.border_radius || "4px";
iframe.style.padding = o.padding || "4px"; // 1px ensures that right border shows up on default wordpress theme
iframe.style.backgroundColor = "white";
iframe.style.backgroundColor = "#333";
// iframe.style.backgroundColor = "rgb(247, 247, 247)";
iframe.id = id;
iframe.setAttribute("data-test-id", "polis-iframe");
Expand Down
2 changes: 1 addition & 1 deletion client-participation/api/embedPreprod.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
iframe.style.border = o.border || "1px solid #ccc";
iframe.style.borderRadius = o.border_radius || "4px";
iframe.style.padding = o.padding || "4px"; // 1px ensures that right border shows up on default wordpress theme
iframe.style.backgroundColor = "white";
iframe.style.backgroundColor = "#333";
// iframe.style.backgroundColor = "rgb(247, 247, 247)";
iframe.id = id;
parent.appendChild(iframe);
Expand Down
1 change: 1 addition & 0 deletions client-participation/api/polisHost.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
iframe.height = o.height || 900;
iframe.style.border = "1px solid #ccc";
iframe.style.borderRadius = "4px";
iframe.style.backgroundColor = "#333";
parent.appendChild(iframe);
}

Expand Down
4 changes: 4 additions & 0 deletions client-participation/js/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ var translations = {
it: require("./strings/it.js"),
// Japanese
ja: require("./strings/ja.js"),
// Korean
ko_kr: require("./strings/ko_kr.js"),
// Dutch
nl: require("./strings/nl.js"),
// Portuguese
Expand Down Expand Up @@ -90,6 +92,8 @@ preloadHelper.acceptLanguagePromise.then(function() {
_.extend(strings, translations.en_us);
} else if (languageCode.match(/^ja/)) {
_.extend(strings, translations.ja);
} else if (languageCode.match(/^ko-KR/)) {
_.extend(strings, translations.ko_kr);
} else if (
languageCode.match(/^zh-CN/) ||
languageCode.match(/^zh-SG/) ||
Expand Down
Loading