Merge pull request #929 from Safelite/feature/INSR-2178
Only run Playwright test cases connected to linked JIRA card at PR time
This commit is contained in:
commit
c158c781d8
1 changed files with 26 additions and 23 deletions
|
|
@ -36,7 +36,7 @@ variables:
|
||||||
- name: imageTag
|
- name: imageTag
|
||||||
value: '$(Build.BuildId)'
|
value: '$(Build.BuildId)'
|
||||||
- name: totalShards
|
- name: totalShards
|
||||||
value: 4
|
value: 2
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
# PR's
|
# PR's
|
||||||
|
|
@ -58,10 +58,10 @@ stages:
|
||||||
shardNumber: 1
|
shardNumber: 1
|
||||||
shard2:
|
shard2:
|
||||||
shardNumber: 2
|
shardNumber: 2
|
||||||
shard3:
|
# shard3:
|
||||||
shardNumber: 3
|
# shardNumber: 3
|
||||||
shard4:
|
# shard4:
|
||||||
shardNumber: 4
|
# shardNumber: 4
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- task: Docker@2
|
- task: Docker@2
|
||||||
|
|
@ -74,6 +74,10 @@ stages:
|
||||||
arguments: '--no-cache --pull'
|
arguments: '--no-cache --pull'
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
|
branch_name=$(System.PullRequest.SourceBranch)
|
||||||
|
echo "Retrieved branch name: '$branch_name'"
|
||||||
|
jira_card_number="${branch_name##*/}"
|
||||||
|
echo "Extracted JIRA Card number: '$jira_card_number'"
|
||||||
# Create container and run tests
|
# Create container and run tests
|
||||||
container_id=$(docker create \
|
container_id=$(docker create \
|
||||||
--ipc=host \
|
--ipc=host \
|
||||||
|
|
@ -87,7 +91,7 @@ stages:
|
||||||
$(dockerImageName):$(imageTag) \
|
$(dockerImageName):$(imageTag) \
|
||||||
npx concurrently -k -n "server,playwright"\
|
npx concurrently -k -n "server,playwright"\
|
||||||
"sed -i \"s|^process\.env\.VUE_APP_CONSUMER_CF_DISTRO = .*|process\.env\.VUE_APP_CONSUMER_CF_DISTRO='https://digitalapi.test.safelite.io'|\" \"./vue.config.js\" && echo \"Updated config file to use TEST APIs\" && npm run serve -- --port=8080"\
|
"sed -i \"s|^process\.env\.VUE_APP_CONSUMER_CF_DISTRO = .*|process\.env\.VUE_APP_CONSUMER_CF_DISTRO='https://digitalapi.test.safelite.io'|\" \"./vue.config.js\" && echo \"Updated config file to use TEST APIs\" && npm run serve -- --port=8080"\
|
||||||
"npx wait-on http://localhost:8080 && npm run test:playwright -- --shard=$(shardNumber)/$(totalShards) --reporter=list,blob --grep \"@smoke | @Advanced\"")
|
"npx wait-on http://localhost:8080 && npm run test:playwright -- --shard=$(shardNumber)/$(totalShards) --reporter=list,blob --grep \"@$jira_card_number\"")
|
||||||
|
|
||||||
# Start container and stream logs
|
# Start container and stream logs
|
||||||
echo "Starting tests for shard $(shardNumber)..."
|
echo "Starting tests for shard $(shardNumber)..."
|
||||||
|
|
@ -107,8 +111,8 @@ stages:
|
||||||
|
|
||||||
# Check if tests failed
|
# Check if tests failed
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Tests failed in shard $(shardNumber)!"
|
echo "Tests failed in shard $(shardNumber) or tests don't exist for this shard number!"
|
||||||
exit 1
|
exit 0 # Suppress error. It will be visible in report.
|
||||||
fi
|
fi
|
||||||
displayName: 'Run Playwright Tests - Shard $(shardNumber)'
|
displayName: 'Run Playwright Tests - Shard $(shardNumber)'
|
||||||
|
|
||||||
|
|
@ -157,11 +161,11 @@ stages:
|
||||||
bash -c "echo \"Moving Playwright reports out of subfolders...\" &&
|
bash -c "echo \"Moving Playwright reports out of subfolders...\" &&
|
||||||
find ./playwright-reports/ -mindepth 2 -type f -exec mv {} ./playwright-reports/ \; &&
|
find ./playwright-reports/ -mindepth 2 -type f -exec mv {} ./playwright-reports/ \; &&
|
||||||
echo \"Merging reports...\" &&
|
echo \"Merging reports...\" &&
|
||||||
npx playwright merge-reports --reporter=ortoni-report ./playwright-reports
|
PLAYWRIGHT_JUNIT_OUTPUT_DIR='/app/test-results' PLAYWRIGHT_JUNIT_OUTPUT_NAME='junit_results.xml' npx playwright merge-reports --reporter=ortoni-report,junit ./playwright-reports
|
||||||
echo \"Contents of ortoni-report:\" && ls ./ortoni-report &&
|
echo \"Contents of ortoni-report:\" && ls ./ortoni-report &&
|
||||||
echo 'Current dir: ' && pwd
|
echo 'Current dir: ' && pwd
|
||||||
echo 'Contents of current dir: ' && ls
|
echo 'Contents of current dir: ' && ls
|
||||||
echo 'Contents of /app/devops/scripts' && ls /app/devops/scripts
|
echo 'Contents of /app/test-results' && ls /app/test-results
|
||||||
echo \"Writing report to Jira card '$jira_card_number'...\" &&
|
echo \"Writing report to Jira card '$jira_card_number'...\" &&
|
||||||
/app/devops/scripts/jira_writeback.sh add_comment \"$jira_card_number\" /app/ortoni-report/ortoni-report.html \"AUTOMATED TEST RUN: $(date)\" ")
|
/app/devops/scripts/jira_writeback.sh add_comment \"$jira_card_number\" /app/ortoni-report/ortoni-report.html \"AUTOMATED TEST RUN: $(date)\" ")
|
||||||
|
|
||||||
|
|
@ -172,12 +176,12 @@ stages:
|
||||||
# Create directory for test results
|
# Create directory for test results
|
||||||
echo "Creating test results directory..."
|
echo "Creating test results directory..."
|
||||||
mkdir -p $(System.DefaultWorkingDirectory)/ortoni-report
|
mkdir -p $(System.DefaultWorkingDirectory)/ortoni-report
|
||||||
|
mkdir -p $(System.DefaultWorkingDirectory)/test-results
|
||||||
|
|
||||||
# Copy test results from container
|
# Copy test results from container
|
||||||
echo "Copying test results..."
|
echo "Copying test results..."
|
||||||
docker cp $container_id:/app/ortoni-report/. $(System.DefaultWorkingDirectory)/ortoni-report
|
docker cp $container_id:/app/ortoni-report/. $(System.DefaultWorkingDirectory)/ortoni-report
|
||||||
# docker cp $container_id:/app/test-results/junit_results.xml $(System.DefaultWorkingDirectory)
|
docker cp $container_id:/app/test-results/junit_results.xml $(System.DefaultWorkingDirectory)/test-results
|
||||||
# TODO: Update to include junit results if necessary
|
|
||||||
|
|
||||||
# Remove container
|
# Remove container
|
||||||
echo "Cleaning up container..."
|
echo "Cleaning up container..."
|
||||||
|
|
@ -186,17 +190,16 @@ stages:
|
||||||
JIRA_API_KEY: $(JIRA_API_KEY)
|
JIRA_API_KEY: $(JIRA_API_KEY)
|
||||||
displayName: merge_and_publish_results_to_jira
|
displayName: merge_and_publish_results_to_jira
|
||||||
|
|
||||||
# TODO: Enable later when working on PR gate
|
- task: PublishTestResults@2
|
||||||
# - task: PublishTestResults@2
|
displayName: 'Publish test results'
|
||||||
# displayName: 'Publish test results'
|
inputs:
|
||||||
# inputs:
|
searchFolder: 'test-results'
|
||||||
# searchFolder: 'test-results'
|
testResultsFormat: 'JUnit'
|
||||||
# testResultsFormat: 'JUnit'
|
testResultsFiles: 'junit_results.xml'
|
||||||
# testResultsFiles: 'junit_results.xml'
|
mergeTestResults: true
|
||||||
# mergeTestResults: true
|
failTaskOnFailedTests: false
|
||||||
# failTaskOnFailedTests: false
|
testRunTitle: 'Playwright Tests'
|
||||||
# testRunTitle: 'Playwright Tests'
|
condition: succeededOrFailed()
|
||||||
# condition: succeededOrFailed()
|
|
||||||
|
|
||||||
- task: PublishPipelineArtifact@1
|
- task: PublishPipelineArtifact@1
|
||||||
displayName: 'Publish Merged Report'
|
displayName: 'Publish Merged Report'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue