Skip to content

Commit

Permalink
Actioning quick pair review
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekCrannaford committed Oct 4, 2024
1 parent fbfb69e commit b48c4bd
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 18 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,12 @@ jobs:
done
# Pre-requisites Prepare Cmfive Environment
- name: Setup cmfive Test Environment
run: |
docker exec -t cmfive sh -c "chmod -R ugo=rwX /var/www/html*"

# Tests will assume playwright code is executable
# we should rely on deployment methods already to have provisioned:
# - name: Setup cmfive Test Environment
# run: |
# docker exec -t cmfive sh -c "chmod -R ugo=rwX /var/www/html*"

- name: Inject configs into cmfive Test Environment
run: |
Expand All @@ -145,7 +148,7 @@ jobs:
- name: Run Unit and Playwright tests
run: |
test/docker_run_tests.sh
sh test/docker_run_tests.sh --cosine_container cmfive
- name: Get container logs
if: ${{ failure() }} || ${{ success() }}
Expand All @@ -166,7 +169,7 @@ jobs:
if: ${{ failure() }} || ${{ success() }}
uses: actions/upload-artifact@v4
with:
name: test-output-${{matrix.node_version}}
name: test-output
path: |
boilerplate/storage/log/
boilerplate/test/playwright/test-results/
Expand Down
52 changes: 39 additions & 13 deletions test/docker_run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ set +e
# Node version can be specified, WARNING Playwright&Cosine will not be expected to support all node versions!
# usage: ./docker_run.sh --fresh
# usage: ./docker_run.sh --node_ver 18
# usage: ./docker_run.sh --cosine_container [default is 'cmfive']

freshen_all=""
test_node_version=""
cosine_container="cmfive"

while test $# != 0
do
Expand All @@ -20,21 +22,16 @@ do
--node_ver)
shift; test_node_version=$1 ;;
--) shift; break;;
--cosine_container)
shift; cosine_container=$1 ;;
--) shift; break;;
esac
shift
done

# Bootstrap this script in the Playwright container
if [ -z "$IS_PLAYWRIGHT_CONTAINER" ]; then
# Explicitly prep DB for testing:
echo "Backup and snaphsot DB with migrations"
docker exec -t cmfive bash -c "DB_HOST=mysql-8 DB_USERNAME=$DB_USERNAME DB_PASSWORD=$DB_PASSWORD DB_DATABASE=$DB_DATABASE DB_PORT=3306 php cmfive.php testDB setup"
DB_SETUP_EXIT_CODE=$?
if [ $DB_SETUP_EXIT_CODE -ne 0 ]; then
echo "Warning: Failed to setup test DB"
exit $DB_SETUP_EXIT_CODE
fi
echo "Success: Setup test DB"


# Get the directory of the script
TESTDIR=$(dirname -- "$( readlink -f -- "$0"; )";)
Expand All @@ -45,7 +42,7 @@ if [ -z "$IS_PLAYWRIGHT_CONTAINER" ]; then
PROJECTDIR="$(dirname "$PROJECTDIR")"
echo "PROJECTDIR: $PROJECTDIR"
echo "TESTDIR: $TESTDIR"
if [ "$PROJECTDIR" == "/" ]; then
if [ "$PROJECTDIR" = "/" ]; then
echo "Panic: docker-compose.yml not found, be sure to run this script from the test directory"
exit 2
fi
Expand All @@ -58,8 +55,36 @@ if [ -z "$IS_PLAYWRIGHT_CONTAINER" ]; then
docker compose up -d --wait
fi

system_is_at=$(readlink -f $PROJECTDIR/system)
echo ">> CONTAINER LABELS (BOILERPLATE) <<"
echo "===================================="
docker inspect --format='{{range $key, $value := .Config.Labels}}{{$key}}={{$value}}{{println}}{{end}}' cmfive
echo ">> CONTAINER LABELS (CORE COMMIT) <<"
echo "===================================="
echo "VENDOR DIRECTORY:"
docker exec -u root $cosine_container sh -c "cd composer/vendor/2pisoftware/cmfive-core && git log -1 --pretty=format:"CORE_HASH=\"%H\"%nCORE_COMMIT_MSG=\"%s\"%nCORE_REF=\"%D\"""
echo ""
if cd $system_is_at/.. ; then
echo ""
echo ">> TESTS ON BRANCH (CORE COMMIT) <<"
echo "===================================="
echo "MOUNTED CORE from $system_is_at: (this is mounted to /system)"
git log -1 --pretty=format:"CORE_HASH=\"%H\"%nCORE_COMMIT_MSG=\"%s\"%nCORE_REF=\"%D\""
echo ""
fi

# Explicitly prep DB for testing:
echo "Backup and snaphsot DB with migrations"
docker exec -u cmfive $cosine_container sh -c "DB_HOST=mysql-8 DB_USERNAME=$DB_USERNAME DB_PASSWORD=$DB_PASSWORD DB_DATABASE=$DB_DATABASE DB_PORT=3306 php cmfive.php testDB setup"
DB_SETUP_EXIT_CODE=$?
if [ $DB_SETUP_EXIT_CODE -ne 0 ]; then
echo "Warning: Failed to setup test DB"
exit $DB_SETUP_EXIT_CODE
fi
echo "Success: Setup test DB"

# First, Run Unit Tests
docker exec -u cmfive cmfive sh -c "DB_HOST=mysql-8 DB_USERNAME=$DB_USERNAME DB_PASSWORD=$DB_PASSWORD DB_DATABASE=$DB_DATABASE DB_PORT=3306 php cmfive.php tests unit all; exit \$?"
docker exec -u cmfive $cosine_container sh -c "DB_HOST=mysql-8 DB_USERNAME=$DB_USERNAME DB_PASSWORD=$DB_PASSWORD DB_DATABASE=$DB_DATABASE DB_PORT=3306 php cmfive.php tests unit all; exit \$?"
UNIT_TESTS_EXIT_CODE=$?
if [ $UNIT_TESTS_EXIT_CODE -ne 0 ]; then
echo "Unit tests failed: $UNIT_TESTS_EXIT_CODE"
Expand Down Expand Up @@ -126,12 +151,13 @@ wait_for_response() {

wait_for_response "http://localhost:3000" 60

chmod -R 755 .
# Tests will assume playwright code is executable
# we should rely on deployment methods already to have provisioned:
# chmod -R 755 .
whoami
locale
date


# if TEST_NODE_VERSION is set, adopt version

if [ ! -z $TEST_NODE_VERSION ]; then
Expand Down

0 comments on commit b48c4bd

Please sign in to comment.