UHF-8762: Run visual regression tests #21
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
env: | |
SIMPLETEST_DB: mysql://drupal:drupal@db:3306/drupal | |
name: Visual regression tests | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Set variables | |
run: echo "DRUPAL_ROOT=$HOME/drupal" >> $GITHUB_ENV | |
- name: Parse $THEME_NAME from composer.json | |
run: echo "THEME_NAME=$(cat composer.json | jq -r .name | awk -F/ '{print $NF}')" >> $GITHUB_ENV | |
- name: Set module folder | |
run: echo "THEME_FOLDER=$DRUPAL_ROOT/public/themes/contrib/$THEME_NAME" >> $GITHUB_ENV | |
- name: Clone platform | |
run: | | |
git clone --depth=1 https://github.com/City-of-Helsinki/drupal-helfi-platform.git $DRUPAL_ROOT | |
rm -rf $DRUPAL_ROOT/.git | |
- name: Install and start Stonehenge | |
run: | | |
git clone -b 4.x https://github.com/druidfi/stonehenge.git ~/stonehenge | |
cd ~/stonehenge && make up | |
- name: Build project | |
working-directory: ${{ env.DRUPAL_ROOT }} | |
env: | |
COMPOSER_MIRROR_PATH_REPOS: 1 | |
run: | | |
composer config repositories.5 path $GITHUB_WORKSPACE | |
composer require drupal/$THEME_NAME -W | |
# We use COMPOSER_MIRROR_PATH_REPOS=1 to mirror local repository | |
# instead of symlinking it to make sure the code is available inside | |
# the app container. | |
cp -r $GITHUB_WORKSPACE/.git public/themes/contrib/$THEME_NAME/ | |
- name: Start project | |
working-directory: ${{ env.DRUPAL_ROOT }} | |
run: docker compose up -d --wait | |
- name: Wait for project to start | |
working-directory: ${{ env.DRUPAL_ROOT }} | |
run: | | |
counter=0 | |
until [ $counter -gt 5 ] | |
do | |
docker compose exec app bash -c "\$(drush sql:connect) -e '\q'" 2> /dev/null | |
if [ $? -eq 0 ]; then | |
break | |
fi | |
echo "Database is not up yet ..." | |
((counter++)) | |
sleep 2 | |
done | |
- name: Setup Drupal | |
working-directory: ${{ env.DRUPAL_ROOT }} | |
run: | | |
mkdir public/sites/default/files -p && chmod 777 public/sites/default -R | |
docker compose exec app bash -c "ls -la public/themes/contrib/hdbt" | |
docker compose exec app bash -c "drush si minimal -y" | |
docker compose exec app bash -c "drush en helfi_test_content -y" | |
- name: Run tests | |
working-directory: ${{ env.DRUPAL_ROOT }} | |
run: curl https://mysite.docker.so | |