Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2024-09-09_2 #8849

Merged
merged 106 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
e3bfa96
Temporary comment out all CI workflows, while iterating on e2e tests …
kogre Aug 13, 2024
6329b3b
Temporary run the e2e tests on every commit, but limit to 2 cases
kogre Aug 13, 2024
9201280
Enable docker layer caching
kogre Aug 13, 2024
de72552
e2e-setup-db step
kogre Aug 13, 2024
6420a3f
e2e-db-setup job
kogre Aug 13, 2024
225b28f
db-e2e-setup
kogre Aug 13, 2024
6f86ff1
db-e2e-setup
kogre Aug 13, 2024
b56b46a
db-e2e-setup
kogre Aug 13, 2024
030fe76
db-e2e-setup
kogre Aug 13, 2024
9e3e492
db-e2e-setup
kogre Aug 13, 2024
17712be
db-e2e-setup
kogre Aug 13, 2024
68afed3
db-e2e-setup
kogre Aug 13, 2024
d4c594d
db-e2e-setup
kogre Aug 13, 2024
2ea75c1
db-e2e-setup
kogre Aug 13, 2024
09fbd0a
db-e2e-setup
kogre Aug 13, 2024
ee08c93
db-e2e-setup
kogre Aug 14, 2024
cee373e
db-e2e-setup
kogre Aug 14, 2024
394e132
db-e2e-setup
kogre Aug 14, 2024
2253f30
db-e2e-setup
kogre Aug 14, 2024
5ee6e6b
db-e2e-setup
kogre Aug 14, 2024
6af02f3
db-e2e-setup
kogre Aug 14, 2024
e0c3845
db-e2e-setup
kogre Aug 14, 2024
0ab3217
db-e2e-setup
kogre Aug 14, 2024
667345a
db-e2e-setup
kogre Aug 14, 2024
269f5be
db-e2e-setup
kogre Aug 14, 2024
f2cb3e9
db-e2e-setup
kogre Aug 14, 2024
a76b71c
db-e2e-setup
kogre Aug 14, 2024
60bf40c
db-e2e-setup
kogre Aug 14, 2024
6c52184
db-e2e-setup
kogre Aug 14, 2024
ebabf95
db-e2e-setup
kogre Aug 14, 2024
428043f
db-e2e-setup
kogre Aug 14, 2024
162c842
db-e2e-setup
kogre Aug 14, 2024
8ce2540
db-e2e-setup
kogre Aug 14, 2024
46bb66c
db-e2e-setup
kogre Aug 14, 2024
437b775
Attempted fix for test timing data
kogre Aug 20, 2024
683bb11
Fixed wrong image names
kogre Aug 20, 2024
6083996
Test results using cypress-circleci-reporter
kogre Aug 20, 2024
0ba37d8
Smaller Docker image
kogre Aug 20, 2024
f9aba21
Run all specs, fix test report copy
kogre Aug 20, 2024
1b35abe
Disable layer caching for front, as it somehow does not invalidate Do…
kogre Aug 20, 2024
283731b
Fix storing test results
kogre Aug 20, 2024
4644961
Merge remote-tracking branch 'origin/master' into TAN-2500-ci-e2e-spe…
kogre Aug 20, 2024
12ea7db
Debug a single test case
kogre Aug 20, 2024
e60f895
Fixed timings type syntax
kogre Aug 20, 2024
96f481e
Fixed run syntax
kogre Aug 20, 2024
f88167a
Merge remote-tracking branch 'origin/master' into TAN-2500-ci-e2e-spe…
kogre Aug 22, 2024
8e399b2
Run all tests with new master
kogre Aug 22, 2024
ad16c5c
Parallelism
kogre Aug 22, 2024
319bf08
Run e2e BE requests through front-end proxy
kogre Aug 23, 2024
895739f
Fixed front command
kogre Aug 23, 2024
aa865ed
Increase parallelism
kogre Aug 23, 2024
463a9ab
Increased health check interval for web container
kogre Aug 23, 2024
0e7badf
Make cypress run through FE proxy too
kogre Aug 26, 2024
4460bb2
Setting NODE_ENV=test in order to try out insecure cookie
kogre Aug 26, 2024
ffd30c2
Fix NODE_ENV for test build
kogre Aug 28, 2024
210ffdf
Fix double slashes
kogre Aug 28, 2024
7fa06e9
Small tweaks
kogre Aug 28, 2024
6e7a085
Profile syntax
kogre Aug 28, 2024
dc40869
Merge remote-tracking branch 'origin/master' into TAN-2500-ci-e2e-spe…
kogre Aug 28, 2024
a77de6d
Use circleci test run instead of test split
kogre Aug 28, 2024
51a9446
change back to circleci tests split because of TTY error
kogre Aug 28, 2024
8f1c009
Remove hardcoded wait statements to test if flakiness is fixed
amanda-anderson Sep 2, 2024
6dee9a7
Remove duplicated intercepts (already in the saveReport function) to …
amanda-anderson Sep 2, 2024
9c7a6e6
Try cleaning up any existing reports first
amanda-anderson Sep 2, 2024
4997f59
Clean up any phase reports
amanda-anderson Sep 2, 2024
b46752e
Revert changes
amanda-anderson Sep 2, 2024
c1784e4
Merge in master
amanda-anderson Sep 2, 2024
06a4a55
Re-enable experimentalSessionAndOrigin to test if it fixes flakiness
amanda-anderson Sep 3, 2024
b3ceab4
Remove dependency on the intercept and add set experimentalSessionAnd…
amanda-anderson Sep 3, 2024
b09b475
Revert changes
amanda-anderson Sep 3, 2024
96fcb4f
Remove reports before creating new ones
amanda-anderson Sep 3, 2024
9df4d7a
Reset
amanda-anderson Sep 3, 2024
4ff9f27
Merge in master
amanda-anderson Sep 4, 2024
30115d0
Attempt downloading cypress and starting up BE in parallel
kogre Sep 4, 2024
b5c82c5
Merge branch 'TAN-2500-ci-e2e-speedup' of github.com:CitizenLabDotCo/…
kogre Sep 4, 2024
1f0a664
Fixed docker cypress pull
kogre Sep 4, 2024
a8e78b4
Pull image after secrets have been loaded
kogre Sep 4, 2024
3996fcc
Front DLC and build front-static image
kogre Sep 4, 2024
be7708e
Fix front command and avoid docker build
kogre Sep 4, 2024
1488396
Skip failing tests to verify timing info test splitting
kogre Sep 5, 2024
e75169c
Fix front-end building using old front-end version
kogre Sep 5, 2024
5a85244
Skip failing tests about report builder autosaving
amanda-anderson Sep 5, 2024
72f198c
Merge branch 'master' into TAN-2500-ci-e2e-speedup
amanda-anderson Sep 5, 2024
dae7d93
Fix failing email_consent test
amanda-anderson Sep 5, 2024
0b909c5
Use wait instead to test if fixes flakiness
amanda-anderson Sep 5, 2024
f6d7b16
Try clearing cookies
luucvanderzee Sep 5, 2024
086934a
Merge branch 'master' into TAN-2500-ci-e2e-speedup
amanda-anderson Sep 6, 2024
043c24a
Merge branch 'TAN-2500-ci-e2e-speedup' of github.com:CitizenLabDotCo/…
amanda-anderson Sep 6, 2024
878a100
Merge branch 'master' into TAN-2500-ci-e2e-speedup
luucvanderzee Sep 6, 2024
4eb7c06
Add start_period to health check
luucvanderzee Sep 9, 2024
ff8906f
Fix flaky email consent test
luucvanderzee Sep 9, 2024
e5eb823
Merge branch 'master' into TAN-2500-ci-e2e-speedup
luucvanderzee Sep 9, 2024
3d84b59
Fix circleci config
luucvanderzee Sep 9, 2024
c280440
Use new setup for manually-e2e-tests
luucvanderzee Sep 9, 2024
7e57644
Add back citizenlab-ee-environment for back docker image job
luucvanderzee Sep 9, 2024
def1dcc
Merge pull request #8667 from CitizenLabDotCo/TAN-2500-ci-e2e-speedup
luucvanderzee Sep 9, 2024
0ff73e3
Add console.logs to debug staging
luucvanderzee Sep 9, 2024
5802444
Remove logging
luucvanderzee Sep 9, 2024
5c44231
Merge pull request #8845 from CitizenLabDotCo/add-logging
luucvanderzee Sep 9, 2024
bd386ad
Use resolvedName instead of displayName
luucvanderzee Sep 9, 2024
08abeaf
Merge pull request #8846 from CitizenLabDotCo/remove-logging
luucvanderzee Sep 9, 2024
5a53e86
Unksip report builder tests
luucvanderzee Sep 9, 2024
219f6d0
Remove filters
luucvanderzee Sep 9, 2024
2740931
Make selector more specific and force click
luucvanderzee Sep 9, 2024
694eda6
Skip idea template one again
luucvanderzee Sep 9, 2024
38e516e
Merge pull request #8847 from CitizenLabDotCo/unskip-report-builder-t…
luucvanderzee Sep 9, 2024
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
174 changes: 103 additions & 71 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -677,57 +677,118 @@ jobs:
- run: npm run chromatic

# E2E TESTS
e2e-tests:
e2e-setup-db:
docker:
- image: cimg/base:2021.03
parallelism: 3
- image: cimg/base:2024.08
working_directory: ~/citizenlab
resource_class: medium+
resource_class: medium
steps:
- shallow-clone
- copy_secrets_from_lastpass
- setup_remote_docker
- setup_remote_docker:
docker_layer_caching: true
- run: docker login -u $DOCKER_USER -p $DOCKER_PASS
- run: |
cd e2e
# --parallel is weird https://github.com/docker/compose/issues/7901 but it seems to work.
# `docker compose` (w/o hythen) doesn't work atm "docker: 'compose' is not a docker command"
docker-compose build --parallel
docker compose run web bin/rails db:drop db:create db:schema:load
docker compose run web bin/rails "cl2_back:create_tenant[e2e.front,e2etests_template]"
- run: docker cp $(docker ps -lq):/cl2_back/public/uploads .
- run: |
cd e2e
docker-compose run web bin/rails db:drop db:create db:schema:load
docker-compose run web bin/rails "cl2_back:create_tenant[e2e.front,e2etests_template]"
docker cp -a $(docker compose ps -q postgres):/var/lib/postgresql/data ../postgresql-data
- run: |
docker tag e2e-web citizenlabdotco/back-e2e:$CIRCLE_SHA1
docker push citizenlabdotco/back-e2e:$CIRCLE_SHA1
- persist_to_workspace:
root: .
paths:
- postgresql-data
- uploads
- env_files

e2e-setup-front:
docker:
- image: cimg/base:2024.08
resource_class: large
working_directory: ~/citizenlab
steps:
- shallow-clone
- copy_secrets_from_lastpass
- setup_remote_docker:
docker_layer_caching: true
- run: docker login -u $DOCKER_USER -p $DOCKER_PASS
- run: |
cd e2e
docker compose run --build front npm run build:test
- run: docker cp $(docker ps -lq):/front/build .
- run: |
docker tag e2e-front citizenlabdotco/front-e2e:$CIRCLE_SHA1
- run: |
docker push citizenlabdotco/front-e2e:$CIRCLE_SHA1
- persist_to_workspace:
root: .
paths:
- build
e2e-tests:
docker:
- image: cimg/base:2024.08
parallelism: 16
working_directory: ~/citizenlab
resource_class: medium
steps:
- shallow-clone
- setup_remote_docker
- run: docker login -u $DOCKER_USER -p $DOCKER_PASS
- attach_workspace:
at: .
- run:
command: |
cd e2e
docker-compose up
cd e2e
docker compose -f docker-compose.yml -f docker-compose.test.yml pull cypress
background: true
# Wait until build is finished.
- run: |
sleep 10 # if we run `docker-compose run` immediately, it fails with "network is ambiguous (2 matches found on name)"
cd e2e
# we cannot access localhost:3000, so we call it from the container
# https://discuss.circleci.com/t/cannot-communicate-with-docker-container/27253/2
docker-compose run front curl --retry 2 --retry-delay 5 --retry-connrefused -v http://e2e.front:3000
docker compose -f docker-compose.yml -f docker-compose.test.yml up --no-start
- run: |
cd e2e
WEB_CONTAINER_ID=$(docker compose ps -a -q web)
FRONT_CONTAINER_ID=$(docker compose ps -a -q front)
POSTGRES_CONTAINER_ID=$(docker compose ps -a -q postgres)
docker cp ../uploads/. $WEB_CONTAINER_ID:/cl2_back/public/uploads
docker cp ../build $FRONT_CONTAINER_ID:/front/build
docker cp ../postgresql-data/. $POSTGRES_CONTAINER_ID:/var/lib/postgresql/data
- run: |
cd e2e
docker compose -f docker-compose.yml -f docker-compose.test.yml up -d --wait
- run:
command: |
cd e2e
docker compose -f docker-compose.yml -f docker-compose.test.yml logs -f
background: true
- run: |
cd front
mkdir -p reports
TESTFILES=$(circleci tests glob "cypress/e2e/**/*.cy.ts" | circleci tests split --split-by=timings)
TESTFILES=$(circleci tests glob "cypress/e2e/**/*.cy.ts" | circleci tests split --split-by=timings)
COMMA_SEPARATED_TESTFILES=$(echo $TESTFILES | sed 's/ /,/g')
echo $COMMA_SEPARATED_TESTFILES
cd ../e2e
docker-compose run --name cypress_run front npm run cypress:run -- --reporter junit --reporter-options "mochaFile=../front/reports/cypress.xml" --config baseUrl=http://e2e.front:3000 --spec ${COMMA_SEPARATED_TESTFILES}
# We run cypress tests in container, so we need to copy the results out.
- run: |
mkdir -p front/reports
docker cp cypress_run:/front/reports/cypress.xml front/reports/cypress.xml
docker compose -f docker-compose.yml -f docker-compose.test.yml --profile cypress run --name cypress_run \
cypress npm run cypress:run -- \
--reporter cypress-circleci-reporter \
--config baseUrl=http://e2e.front:3000 \
--spec ${COMMA_SEPARATED_TESTFILES}
- run:
command: |
docker cp cypress_run:/front/test_results .
when: always
- run:
command: docker cp cypress_run:/front/cypress/screenshots .
# If `when: always`, it fails on success with
# Error: No such container:path: cypress_run:/front/cypress/screenshots
when: on_fail
- store_test_results:
path: front/reports
path: test_results
- store_artifacts:
path: test_results
- store_artifacts:
path: screenshots

Expand Down Expand Up @@ -888,7 +949,7 @@ workflows:
branches:
only: production
- back-deploy-to-swarm:
name: Deploy to Europe (Frankfurt)
name: Deploy to Europe
requires:
- back-push-deployment-docker-image
filters:
Expand All @@ -900,19 +961,6 @@ workflows:
stack_name: cl2-prd-bnlx-stack
env_file: ".env-web"
cluster_name: "eu"
- back-deploy-to-swarm:
name: Deploy to Europe (Paris)
requires:
- back-push-deployment-docker-image
filters:
branches:
only:
- production
ssh_host: $CITIZENLAB_CLUSTER_IP_ADDRESS_PARIS
compose_file: docker-compose-production.yml
stack_name: cl2
env_file: ".env-web"
cluster_name: "paris"
- back-deploy-to-swarm:
name: Deploy to Canada
requires:
Expand Down Expand Up @@ -1064,10 +1112,21 @@ workflows:
manually-e2e-tests:
when: << pipeline.parameters.e2e >>
jobs:
- e2e-setup-db:
context:
- docker-hub-access
- lastpass
- e2e-setup-front:
context:
- docker-hub-access
- lastpass
- e2e-tests:
context:
- docker-hub-access
- lastpass
requires:
- e2e-setup-db
- e2e-setup-front

nightly-e2e-tests:
triggers:
Expand Down Expand Up @@ -1102,23 +1161,14 @@ workflows:
- slack-dev-notifications-tenant-templates
<<: *slack-fail-post-step-templates
- back-generate-tenant-templates:
name: "Europe (Frankfurt)"
name: "Europe (mainland)"
context:
- docker-hub-access
- citizenlab-ee-environment
- slack-dev-notifications-tenant-templates
<<: *slack-fail-post-step-templates
ssh_host: $CITIZENLAB_CLUSTER_IP_ADDRESS_EUROPE
env_file: ".env-web"
- back-generate-tenant-templates:
name: "Europe (Paris)"
context:
- docker-hub-access
- citizenlab-ee-environment
- slack-dev-notifications-tenant-templates
<<: *slack-fail-post-step-templates
ssh_host: $CITIZENLAB_CLUSTER_IP_ADDRESS_PARIS
env_file: ".env-web"
- back-generate-tenant-templates:
name: "South America"
context:
Expand Down Expand Up @@ -1163,8 +1213,7 @@ workflows:
<<: *slack-fail-post-step-templates
requires:
- back-build-docker-image
- "Europe (Frankfurt)"
- "Europe (Paris)"
- "Europe (mainland)"
- "South America"
- "Canada"
- "US West"
Expand Down Expand Up @@ -1203,23 +1252,14 @@ workflows:
- slack-dev-notifications-tenant-templates
<<: *slack-fail-post-step-templates
- back-generate-tenant-templates:
name: "Europe (Frankfurt)"
name: "Europe (mainland)"
context:
- docker-hub-access
- citizenlab-ee-environment
- slack-dev-notifications-tenant-templates
<<: *slack-fail-post-step-templates
ssh_host: $CITIZENLAB_CLUSTER_IP_ADDRESS_EUROPE
env_file: ".env-web"
- back-generate-tenant-templates:
name: "Europe (Paris)"
context:
- docker-hub-access
- citizenlab-ee-environment
- slack-dev-notifications-tenant-templates
<<: *slack-fail-post-step-templates
ssh_host: $CITIZENLAB_CLUSTER_IP_ADDRESS_PARIS
env_file: ".env-web"
- back-generate-tenant-templates:
name: "South America"
context:
Expand Down Expand Up @@ -1264,8 +1304,7 @@ workflows:
<<: *slack-fail-post-step-templates
requires:
- back-build-docker-image
- "Europe (Frankfurt)"
- "Europe (Paris)"
- "Europe (mainland)"
- "South America"
- "Canada"
- "US West"
Expand Down Expand Up @@ -1295,13 +1334,6 @@ workflows:
only:
- production
jobs:
- check-for-inconsistent-data:
<<: *slack-fail-post-step-inconsistent-data
name: "Europe (Paris)"
context:
- slack-dev-notifications-inconsistent-data
ssh_host: $CITIZENLAB_CLUSTER_IP_ADDRESS_PARIS
env_file: ".env-web"
- check-for-inconsistent-data:
<<: *slack-fail-post-step-inconsistent-data
name: "South America"
Expand Down Expand Up @@ -1364,4 +1396,4 @@ workflows:
- front-chromatic:
context:
- docker-hub-access
- chromatic
- chromatic
53 changes: 39 additions & 14 deletions .circleci/install_lpass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,46 @@ if ! git clone --depth 1 --branch "$version" "$repository" lastpass-cli; then
exit 1
fi


if [ ! -f /etc/lsb-release ]; then
echo "lsb-release missing, unlikely to be a Ubuntu system"
exit 1
fi
. /etc/lsb-release
if [ "$DISTRIB_RELEASE" == "22.04" ]; then
# Install the dependencies
apt-get update
apt-get --no-install-recommends -yqq install \
bash-completion \
build-essential \
cmake \
libcurl4 \
libcurl4-openssl-dev \
libssl-dev \
libxml2 \
libxml2-dev \
libssl1.1 \
pkg-config \
ca-certificates \
xclip
apt-get update
apt-get --no-install-recommends -yqq install \
bash-completion \
build-essential \
cmake \
libcurl4 \
libcurl4-openssl-dev \
libssl-dev \
libxml2 \
libxml2-dev \
pkg-config \
ca-certificates \
xclip
fi

if [ "$DISTRIB_RELEASE" != "22.04" ]; then
# Install the dependencies
apt-get update
apt-get --no-install-recommends -yqq install \
bash-completion \
build-essential \
cmake \
libcurl4 \
libcurl4-openssl-dev \
libssl-dev \
libxml2 \
libxml2-dev \
libssl1.1 \
pkg-config \
ca-certificates \
xclip
fi

# Build and install the LastPass CLI
cd lastpass-cli
Expand Down
46 changes: 46 additions & 0 deletions e2e/docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This files should be used in a chained way with
# `docker compose -f docker-compose.yml -f docker-compose.test.yml up`

version: "3.8"

services:
web:
image: citizenlabdotco/back-e2e:${CIRCLE_SHA1}
healthcheck:
test: ["CMD", "curl", "-f", "http://e2e-web:4000"]
interval: 2s
timeout: 1s
retries: 20
start_period: 30s

front:
image: citizenlabdotco/cl2-devops-front-e2e-static:latest
build:
context: ../front/.
dockerfile: Dockerfile-static-hosting
healthcheck:
test: ["CMD", "curl", "-f", "http://e2e.front:3000"]
interval: 2s
timeout: 1s
retries: 10
environment:
API_HOST: e2e-web
API_PORT: 4000
command: node server/production.js

postgres:
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
interval: 1s
timeout: 1s
retries: 10

cypress:
profiles: [cypress]
image: citizenlabdotco/front-e2e:${CIRCLE_SHA1}
environment:
API_HOST: e2e.front
API_PORT: 3000
env_file:
- "../env_files/front-safe.env"
- "../env_files/front-secret.env"
Loading