-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: implement e2e tests workflow #227
base: next
Are you sure you want to change the base?
Changes from all commits
a90b705
ccb73f3
00e0c8b
e0f0c3e
ee2c74e
e5829f8
369850e
1069355
5dd138b
3a50758
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,52 @@ jobs: | |
VC test suite, ./packages/vc-test-suite/coverage/coverage-summary.json | ||
UNTP Playground, ./packages/untp-playground/coverage/coverage-summary.json | ||
|
||
- name: Start E2E docker compose | ||
run: SEEDING=true docker compose -f docker-compose.e2e.yml up -d | ||
|
||
- name: Ensure IDR Service Readiness and Health | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @huynguyen-hl, is there a reason why we aren't using the built-in docker-compose health check functionality? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you can see, when we run docker compose up, it pulls all the Docker images defined in the compose file and starts the services. The terminal/console will return the cursor to us, allowing us to run another command, regardless of whether health checks are set up for each service. However, in the background, docker compose up continues running to initialize all services. At this point, the next stepβrunning the E2E testsβwill be triggered. But how do the E2E tests determine whether the services have started successfully and passed their internal health checks as defined in the Docker Compose file? The docker compose up command does not wait until all services are fully running and healthy before returning control to us. So how can we ensure that all services are ready before running the E2E tests? |
||
run: | | ||
HEALTH_ENDPOINT="http://localhost:3000/health-check" | ||
MAX_ATTEMPTS=10 | ||
RETRY_INTERVAL=6 | ||
ATTEMPT_COUNTER=0 | ||
|
||
echo "Waiting for IDR service to become ready..." | ||
|
||
while true; do | ||
if curl --output /dev/null --silent --fail "$HEALTH_ENDPOINT"; then | ||
echo "IDR service is reachable." | ||
break | ||
fi | ||
|
||
ATTEMPT_COUNTER=$((ATTEMPT_COUNTER + 1)) | ||
|
||
if [[ "$ATTEMPT_COUNTER" -eq "$MAX_ATTEMPTS" ]]; then | ||
echo "Max attempts ($MAX_ATTEMPTS) reached. Service failed to start." | ||
exit 1 | ||
fi | ||
|
||
echo "Attempt $ATTEMPT_COUNTER/$MAX_ATTEMPTS failed. Retrying in $RETRY_INTERVAL seconds..." | ||
sleep "$RETRY_INTERVAL" | ||
done | ||
|
||
echo "Checking IDR service health status..." | ||
|
||
HEALTH_STATUS=$(curl -s "$HEALTH_ENDPOINT" | jq -r '.status') | ||
|
||
if [[ "$HEALTH_STATUS" != "OK" ]]; then | ||
echo "Health check failed. Expected status 'OK', but got '$HEALTH_STATUS'." | ||
exit 1 | ||
fi | ||
|
||
echo "IDR service health check passed successfully." | ||
|
||
- name: Run E2E tests | ||
run: yarn test:run-cypress | ||
|
||
- name: Stop docker compose | ||
run: docker compose -f docker-compose.e2e.yml down | ||
|
||
build_docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,52 @@ jobs: | |
- name: Run tests | ||
run: yarn test | ||
|
||
- name: Start E2E docker compose | ||
run: SEEDING=true docker compose -f docker-compose.e2e.yml up -d | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
|
||
- name: Ensure IDR Service Readiness and Health | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
run: | | ||
HEALTH_ENDPOINT="http://localhost:3000/health-check" | ||
MAX_ATTEMPTS=10 | ||
RETRY_INTERVAL=6 | ||
ATTEMPT_COUNTER=0 | ||
|
||
echo "Waiting for IDR service to become ready..." | ||
|
||
while true; do | ||
if curl --output /dev/null --silent --fail "$HEALTH_ENDPOINT"; then | ||
echo "IDR service is reachable." | ||
break | ||
fi | ||
|
||
ATTEMPT_COUNTER=$((ATTEMPT_COUNTER + 1)) | ||
|
||
if [[ "$ATTEMPT_COUNTER" -eq "$MAX_ATTEMPTS" ]]; then | ||
echo "Max attempts ($MAX_ATTEMPTS) reached. Service failed to start." | ||
exit 1 | ||
fi | ||
|
||
echo "Attempt $ATTEMPT_COUNTER/$MAX_ATTEMPTS failed. Retrying in $RETRY_INTERVAL seconds..." | ||
sleep "$RETRY_INTERVAL" | ||
done | ||
|
||
echo "Checking IDR service health status..." | ||
|
||
HEALTH_STATUS=$(curl -s "$HEALTH_ENDPOINT" | jq -r '.status') | ||
|
||
if [[ "$HEALTH_STATUS" != "OK" ]]; then | ||
echo "Health check failed. Expected status 'OK', but got '$HEALTH_STATUS'." | ||
exit 1 | ||
fi | ||
|
||
echo "IDR service health check passed successfully." | ||
|
||
- name: Run E2E tests | ||
run: yarn test:run-cypress | ||
|
||
- name: Stop docker compose | ||
run: docker compose -f docker-compose.e2e.yml down | ||
|
||
build_docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
after(() => { | ||
cy.task('resetData'); | ||
cy.task('clearObjectStore', { | ||
bucketName: Cypress.env('idrBucketName'), | ||
prefix: Cypress.env('idrGS1Prefix'), | ||
minioConfig: Cypress.env('idrMinioConfig'), | ||
}); | ||
Cypress.env('lastCredential', undefined); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
infra | ||
infra | ||
node_modules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will GitHub cache the docker image between each run? If so, we need to build the image so the new functionality is present in the containers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean that GitHub Actions has the capability to cache all Docker images defined in the docker-compose file? If so, I'm not sure about that. I believe it can cache a specific standalone Docker image, but I'm not sure if it applies to all images in a docker-compose setup.
If your idea isn't what I thought, please share more details. Thank you!