Refactors environment variable handling
Moves environment variable definitions to ensure they are available before the docker container is created, resolving issues related to undefined variables during container execution. Also, simplifies the playwright report merging process by streamlining the execution of commands within the docker container.
This commit is contained in:
parent
44541ba00c
commit
cd02d42da1
1 changed files with 24 additions and 24 deletions
|
|
@ -153,32 +153,32 @@ jobs:
|
|||
echo "URL '$port' contains 'localhost'. Extracting port... "
|
||||
port=$(echo "$port" | sed -E 's/.*:([0-9]+).*/\1/')
|
||||
echo "Port is '$port'"
|
||||
TARGET_URL="$TARGET_URL"
|
||||
JIRA_CARD_NUMBER="$JIRA_CARD_NUMBER"
|
||||
FILTER="$FILTER"
|
||||
PLAYWRIGHT_PATH="${{ parameters.playwrightTestsPath }}"
|
||||
SERVE_PATH="${{ parameters.npmServePath }}"
|
||||
SHARD_NUMBER=$(shardNumber)
|
||||
TOTAL_SHARDS=$(totalShards)
|
||||
container_id=$(docker create \
|
||||
--ipc=host \
|
||||
--env-file "${{ parameters.envFileName }}" \
|
||||
-e TARGET_URL="$TARGET_URL" \
|
||||
-e JIRA_CARD_NUMBER="$JIRA_CARD_NUMBER" \
|
||||
-e FILTER="$FILTER" \
|
||||
-e PLAYWRIGHT_PATH="${{ parameters.playwrightTestsPath }}" \
|
||||
-e SERVE_PATH="${{ parameters.npmServePath }}" \
|
||||
-e SHARD_NUMBER=$(shardNumber) \
|
||||
-e TOTAL_SHARDS=$(totalShards) \
|
||||
${{ parameters.dockerImageName }}:${{ parameters.imageTag }} \
|
||||
npx concurrently -k -n 'server,playwright' \
|
||||
"npm --prefix $SERVE_PATH run serve -- --port=$port" \
|
||||
"npx --prefix $PLAYWRIGHT_PATH wait-on $TARGET_URL && npx --prefix $PLAYWRIGHT_PATH playwright test $PLAYWRIGHT_PATH --shard=$SHARD_NUMBER/$TOTAL_SHARDS --reporter=list,blob $FILTER" \
|
||||
)
|
||||
else
|
||||
TARGET_URL="$TARGET_URL"
|
||||
JIRA_CARD_NUMBER="$JIRA_CARD_NUMBER"
|
||||
FILTER="$FILTER"
|
||||
PLAYWRIGHT_PATH="${{ parameters.playwrightTestsPath }}"
|
||||
SERVE_PATH="${{ parameters.npmServePath }}"
|
||||
SHARD_NUMBER=$(shardNumber)
|
||||
TOTAL_SHARDS=$(totalShards)
|
||||
container_id=$(docker create \
|
||||
--ipc=host \
|
||||
--env-file "${{ parameters.envFileName }}" \
|
||||
-e TARGET_URL="$TARGET_URL" \
|
||||
-e JIRA_CARD_NUMBER="$JIRA_CARD_NUMBER" \
|
||||
-e FILTER="$FILTER" \
|
||||
-e PLAYWRIGHT_PATH=${{ parameters.playwrightTestsPath }} \
|
||||
-e SERVE_PATH=${{ parameters.npmServePath }} \
|
||||
-e SHARD_NUMBER=$(shardNumber) \
|
||||
-e TOTAL_SHARDS=$(totalShards) \
|
||||
${{ parameters.dockerImageName }}:${{ parameters.imageTag }} \
|
||||
npx --prefix $PLAYWRIGHT_PATH playwright test $PLAYWRIGHT_PATH --shard=$SHARD_NUMBER/$TOTAL_SHARDS --reporter=list,blob $FILTER \
|
||||
)
|
||||
|
|
@ -244,21 +244,21 @@ jobs:
|
|||
echo "Retrieved branch name: '$branch_name'"
|
||||
JIRA_CARD_NUMBER="${branch_name##*/}"
|
||||
echo "Extracted JIRA Card number: '$JIRA_CARD_NUMBER'"
|
||||
export PLAYWRIGHT_PATH="${{ parameters.playwrightTestsPath }}""
|
||||
container_id=$(docker create \
|
||||
--ipc=host \
|
||||
--env-file "${{ parameters.envFileName }}" \
|
||||
-e JIRA_CARD_NUMBER="$JIRA_CARD_NUMBER" \
|
||||
${{ parameters.dockerImageName }}:${{ parameters.imageTag }} \
|
||||
export PLAYWRIGHT_PATH=${{ parameters.playwrightTestsPath }} bash -c "
|
||||
echo 'Moving Playwright reports out of subfolders...'
|
||||
find ./playwright-reports/ -mindepth 2 -type f -exec mv {} ./playwright-reports/ \;
|
||||
echo 'Merging reports...'
|
||||
PLAYWRIGHT_JUNIT_OUTPUT_DIR='/app/test-results' PLAYWRIGHT_JUNIT_OUTPUT_NAME='junit_results.xml' npx --prefix $PLAYWRIGHT_PATH playwright merge-reports ./playwright-reports
|
||||
echo 'Contents of ortoni-report:' && ls ./ortoni-report
|
||||
echo 'Current dir: ' && pwd
|
||||
echo 'Contents of current dir: ' && ls
|
||||
echo 'Contents of /app/test-results' && ls /app/test-results
|
||||
")
|
||||
echo 'Moving Playwright reports out of subfolders...' \
|
||||
find ./playwright-reports/ -mindepth 2 -type f -exec mv {} ./playwright-reports/ \; \
|
||||
echo 'Merging reports...' \
|
||||
PLAYWRIGHT_JUNIT_OUTPUT_DIR='/app/test-results' PLAYWRIGHT_JUNIT_OUTPUT_NAME='junit_results.xml' npx --prefix $PLAYWRIGHT_PATH playwright merge-reports ./playwright-reports \
|
||||
echo 'Contents of ortoni-report:' && ls ./ortoni-report \
|
||||
echo 'Current dir: ' && pwd \
|
||||
echo 'Contents of current dir: ' && ls \
|
||||
echo 'Contents of /app/test-results' && ls /app/test-results \
|
||||
)
|
||||
# Start container and stream logs
|
||||
echo "Starting merge"
|
||||
docker start -a $container_id
|
||||
|
|
|
|||
Loading…
Reference in a new issue