Loads environment variables in Docker containers
Ensures environment variables defined in the env file are loaded into the Docker containers used for Playwright tests. This is achieved by sourcing the env file within the `docker create` command. Removes the unnecessary CI=true environment variable setting.
This commit is contained in:
parent
1f96ce255b
commit
07efa18134
2 changed files with 11 additions and 6 deletions
|
|
@ -1,5 +1,3 @@
|
||||||
FROM node:20
|
|
||||||
|
|
||||||
FROM mcr.microsoft.com/playwright:v1.48.0-noble
|
FROM mcr.microsoft.com/playwright:v1.48.0-noble
|
||||||
|
|
||||||
# Set the working directory in the container
|
# Set the working directory in the container
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,6 @@ jobs:
|
||||||
TOTAL_SHARDS=${{ parameters.totalShards }}
|
TOTAL_SHARDS=${{ parameters.totalShards }}
|
||||||
container_id=$(docker create \
|
container_id=$(docker create \
|
||||||
--ipc=host \
|
--ipc=host \
|
||||||
--env CI=true \
|
|
||||||
--env-file "${{ parameters.envFileName }}" \
|
--env-file "${{ parameters.envFileName }}" \
|
||||||
${{ parameters.dockerImageName }}:${{ parameters.imageTag }} \
|
${{ parameters.dockerImageName }}:${{ parameters.imageTag }} \
|
||||||
npx concurrently -k -n 'server,playwright' \
|
npx concurrently -k -n 'server,playwright' \
|
||||||
|
|
@ -177,12 +176,17 @@ jobs:
|
||||||
export SERVE_PATH="${{ parameters.npmServePath }}"
|
export SERVE_PATH="${{ parameters.npmServePath }}"
|
||||||
export SHARD_NUMBER=$(shardNumber)
|
export SHARD_NUMBER=$(shardNumber)
|
||||||
export TOTAL_SHARDS=${{ parameters.totalShards }}
|
export TOTAL_SHARDS=${{ parameters.totalShards }}
|
||||||
|
export ENV_FILE="${{ parameters.envFileName }}"
|
||||||
container_id=$(docker create \
|
container_id=$(docker create \
|
||||||
--ipc=host \
|
--ipc=host \
|
||||||
--env CI=true \
|
|
||||||
--env-file "${{ parameters.envFileName }}" \
|
--env-file "${{ parameters.envFileName }}" \
|
||||||
${{ parameters.dockerImageName }}:${{ parameters.imageTag }} \
|
${{ parameters.dockerImageName }}:${{ parameters.imageTag }} \
|
||||||
bash -c "PLAYWRIGHT_BLOB_OUTPUT_DIR='/app/blob-report' npx --prefix $PLAYWRIGHT_PATH playwright test $PLAYWRIGHT_PATH --config=$PLAYWRIGHT_PATH/playwright.config.ts --shard=$SHARD_NUMBER/$TOTAL_SHARDS --reporter=list,blob $FILTER" \
|
bash -c "
|
||||||
|
set -a
|
||||||
|
source $ENV_FILE
|
||||||
|
set +a
|
||||||
|
PLAYWRIGHT_BLOB_OUTPUT_DIR='/app/blob-report' npx --prefix $PLAYWRIGHT_PATH playwright test $PLAYWRIGHT_PATH --config=$PLAYWRIGHT_PATH/playwright.config.ts --shard=$SHARD_NUMBER/$TOTAL_SHARDS --reporter=list,blob $FILTER
|
||||||
|
" \
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
# Start container and stream logs
|
# Start container and stream logs
|
||||||
|
|
@ -250,12 +254,15 @@ jobs:
|
||||||
|
|
||||||
|
|
||||||
export JIRA_CARD_NUMBER="$JIRA_CARD_NUMBER"
|
export JIRA_CARD_NUMBER="$JIRA_CARD_NUMBER"
|
||||||
|
export ENV_FILE="${{ parameters.envFileName }}"
|
||||||
container_id=$(docker create \
|
container_id=$(docker create \
|
||||||
--ipc=host \
|
--ipc=host \
|
||||||
--env CI=true \
|
|
||||||
--env-file "${{ parameters.envFileName }}" \
|
--env-file "${{ parameters.envFileName }}" \
|
||||||
${{ parameters.dockerImageName }}:${{ parameters.imageTag }} \
|
${{ parameters.dockerImageName }}:${{ parameters.imageTag }} \
|
||||||
bash -c "
|
bash -c "
|
||||||
|
set -a
|
||||||
|
source $ENV_FILE
|
||||||
|
set +a
|
||||||
echo 'Moving Playwright reports out of subfolders...'
|
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 'Value of JIRA_CARD_NUMBER in bash -c command: $JIRA_CARD_NUMBER'
|
echo 'Value of JIRA_CARD_NUMBER in bash -c command: $JIRA_CARD_NUMBER'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue