-
Notifications
You must be signed in to change notification settings - Fork 3
111 lines (95 loc) · 3.8 KB
/
visual.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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 theme 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 $THEME_FOLDER/
- name: Start project
working-directory: ${{ env.DRUPAL_ROOT }}
run: docker compose --profile testing up -d --wait && sleep 5
- name: Setup Drupal
working-directory: ${{ env.DRUPAL_ROOT }}
run: |
mkdir public/sites/default/files/styles -p && chmod 777 public/sites/default -R
gh run download -n latest.sql -D /tmp || true
if [ ! -f "latest.sql" ]; then
docker compose exec app bash -c "drush si minimal -y"
docker compose exec app bash -c "drush en helfi_test_content -y"
drush sql-dump --result-file=/tmp/latest.sql
echo "UPLOAD_SQL=1" >> $GITHUB_ENV
else
docker compose exec app bash -c "mysql --user=drupal --password=drupal --database=drupal --host=db --port=3306 -A < /tmp/latest.sql"
docker compose exec app bash -c "drush deploy"
fi
- uses: actions/upload-artifact@v4
if: ${{ env.UPLOAD_SQL == '1' }}
with:
name: latest.sql
path: /tmp/latest.sql
retention-days: 7
- name: Node setup
working-directory: ${{ env.THEME_FOLDER }}
run: |
export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install && npm install && npx playwright install
- name: Generate reference images
working-directory: ${{ env.THEME_FOLDER }}
run: |
gh run download -n bitmaps.zip -D /tmp || true
if [ ! -f "/tmp/bitmaps.zip" ] || [ "$GITHUB_REF" == "refs/heads/main" ]; then
npm run full-reference
echo "UPLOAD_BITMAP=1" >> $GITHUB_ENV
else
unzip /tmp/bitmaps.zip -d backstop_data/
fi
- uses: actions/upload-artifact@v4
with:
if: ${{ env.UPLOAD_BITMAP == '1' }}
name: bitmaps.zip
path: ${{ env.THEME_FOLDER }}/backstop_data/full/bitmaps_reference
- name: Export container logs
working-directory: ${{ env.DRUPAL_ROOT }}
run: docker compose logs app > /tmp/container.log
- name: Create an artifact from test report
uses: actions/upload-artifact@v3
if: always()
with:
name: results
path: |
${{ env.THEME_FOLDER }}/backstop_data/
/tmp/container.log
retention-days: 1