Skip to content

Commit

Permalink
feat: add playwright job (QLT-83) (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
effervescentia authored Nov 12, 2024
1 parent c5c8bf1 commit b9a75a2
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/executors/node/playwright-executor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
playwright-version:
type: string
docker: # run the steps with Docker.
- image: mcr.microsoft.com/playwright:v<< parameters.playwright-version >>-noble
resource_class: xlarge
24 changes: 15 additions & 9 deletions src/jobs/e2e/collect-e2e-logs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ parameters:
description: Path to the env_name file
default: "/home/circleci/voiceflow/env_name.txt"
executor:
description: Executor to run the command on
type: executor
default: default-executor
description: Executor to run the command on
type: executor
default: default-executor
smoke-test-jobs:
description: Comma separated list of smoke test jobs
type: string
default: "vfcommon/run-smoke-tests"
executor: << parameters.executor >>
steps:
- install-vfcli:
Expand Down Expand Up @@ -78,12 +82,14 @@ steps:
capture_logs
- run:
name: Wait for smoke-tests job to complete
command: |
# The waiter job keeps looping through to check if the smoke-tests job has been completed
while [[ $(curl --location --request GET "https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID/job" --header "Circle-Token: $CIRCLE_TOKEN"| jq -r '.items[]|select(.name == "vfcommon/run-smoke-tests")|.status' | grep -c "running") -gt 0 ]]
do
sleep 5
name: Wait for smoke test jobs to complete
command: |
# Loop through to check if each of the jobs have been completed
for job in $(echo "<< parameters.smoke-test-jobs >>" | tr "," "\n"); do
while [[ $(curl --location --request GET "https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID/job" --header "Circle-Token: $CIRCLE_TOKEN"| jq -r ".items[]|select(.name == \"$job\")|.status" | grep -c "running") -gt 0 ]]
do
sleep 5
done
done
- run: echo "All required jobs have now completed"
- run:
Expand Down
71 changes: 71 additions & 0 deletions src/jobs/smoke/run-playwright-smoke-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
executor:
name: playwright-executor
playwright-version: << parameters.playwright-version >>
parallelism: << parameters.parallelism >>

parameters:
playwright-version:
type: string
default: "1.48.2"
e2e-env-name:
type: string
default: ""
parallelism:
type: integer
default: 1
target-url:
type: string
default: ""
description: "use this to override the e2e-env-name and set the full creator-app URL"
branch-or-commit:
type: string
default: "master"
description: "the branch or commit of the automated-testing repo to checkout"
smoke-command:
type: string
default: "test:smoke:playwright"
env-name-path:
type: string
description: Path to the env_name file
default: "/home/circleci/voiceflow/env_name.txt"
steps:
- clone_repo:
github_repo_name: automated-testing
github_commit: << parameters.branch-or-commit >>
path_to_clone: ~/project
- install_node_modules:
avoid_post_install_scripts: false
cache_prefix: playwright-smoke-test
- restore_cache:
key: env_name_cache-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_WORKFLOW_ID }}
- run:
name: "Set Environment Variables"
command: |
# env_name.txt is used to store the e2e env name and passed to the smoke tests
# uses e2e-env-name if env_name.txt is 'null'
if [ ! -z "<< parameters.target-url >>" ]; then
echo 'export CREATOR_APP_URL=<< parameters.target-url >>' >> $BASH_ENV
elif [ -f << parameters.env-name-path >> ] && [ "$(cat << parameters.env-name-path >>)" != "null" ]; then
echo 'export CREATOR_APP_URL=https://creator-$(cat << parameters.env-name-path >>).br-2.development.voiceflow.com' >> $BASH_ENV
else
echo 'export CREATOR_APP_URL=https://creator-<< parameters.e2e-env-name >>.br-2.development.voiceflow.com' >> $BASH_ENV
fi
shell: /bin/bash
- run:
name: "Reference commit SHA"
command: git rev-parse HEAD >> commit.txt
- restore_cache:
# use the commit of the smoke-test-runner repo as the cache key
key: playwright-smoke-test-build-cache-{{ checksum "commit.txt" }}
- run:
name: Run Smoke Tests
command: yarn << parameters.smoke-command >>
- save_cache:
key: playwright-smoke-test-build-cache-{{ checksum "commit.txt" }}
paths:
- node_modules/.cache/turbo
- store_test_results:
path: tests/smoke-playwright/e2e.report.xml
- store_artifacts:
path: tests/smoke-playwright/test-results

2 changes: 1 addition & 1 deletion src/jobs/smoke/run-smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ steps:
path_to_clone: ~/project
- install_node_modules:
avoid_post_install_scripts: false
cache_prefix: smoke-test
cache_prefix: cypress-smoke-test
- restore_cache:
key: env_name_cache-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_WORKFLOW_ID }}
- run:
Expand Down

0 comments on commit b9a75a2

Please sign in to comment.