-
Notifications
You must be signed in to change notification settings - Fork 2
141 lines (118 loc) · 4.35 KB
/
visual_tests.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: visual tests
on:
push:
branches:
- develop
pull_request:
branches:
- develop
env:
NODE_VERSION: 16 # required for percy CLI
DB_NAME: geniza
DB_USER: geniza
DB_PASSWORD: geniza
DJANGO_ENV: test
jobs:
# Get commit message using HEAD^2 if the event is "pull_request".
# From https://github.community/t/accessing-commit-message-in-pull-request-event/17158/15
get_commit_msg:
name: Get commit message for pull requests
runs-on: ubuntu-latest
steps:
- name: Checkout commits up to and including HEAD^2
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get commit message
id: get_commit_message
run: |
if [[ '${{ github.event_name }}' == 'pull_request' ]]; then
echo ::set-output name=commit_message::$(git log --format=%B -n 1 HEAD^2)
fi
outputs:
commit_message: echo "${{ steps.get_commit_message.outputs.commit_message }}"
visual-tests:
name: Visual regression tests
runs-on: ubuntu-latest
needs: get_commit_msg # grab the output from this job for the commit message
# only run if the phrase "[run percy]" (including brackets) is present in the commit message
if: ${{ contains(needs.get_commit_msg.outputs.commit_message, '[run percy]') }}
services:
postgres:
image: postgres:12
env:
POSTGRES_DB: ${{ env.DB_NAME }}
POSTGRES_USER: ${{ env.DB_USER }}
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }}
ports:
- 5432:5432
solr:
image: solr:9.2
ports:
- 8983:8983
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Decrypt encrypted fonts zip
run: |
gpg --quiet --batch --yes --decrypt --passphrase="${{ secrets.GPG_PASSPHRASE }}" --output sitemedia/fonts.zip sitemedia/fonts.zip.gpg
- name: Unzip decrypted fonts zip
run: |
unzip -q -o sitemedia/fonts.zip -d sitemedia
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ hashFiles('package-lock.json') }}
npm-
- name: Install JS dependencies
run: npm ci
- name: Get Python version
run: echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('requirements/*.txt') }}
restore-keys: |
pip-${{ hashFiles('requirements/*.txt') }}
pip-
- name: Install dependencies
run: pip install -r requirements/test.txt
- name: Configure solr and create test core
run: |
docker cp solr_conf ${{ job.services.solr.id }}:/opt/solr/server/solr/configsets/geniza
docker exec --user root ${{ job.services.solr.id }} /bin/bash -c "chown -R solr:solr /opt/solr/server/solr/configsets/geniza"
docker exec -d ${{ job.services.solr.id }} cp -r /opt/solr/server/solr/configsets /var/solr/data
curl "http://localhost:8983/solr/admin/cores?action=CREATE&name=geniza&configSet=geniza"
# NOTE: command line core creation does not seem to actually use the configset
- name: Setup local_settings.py
run: python -c "import uuid; print('SECRET_KEY = \'%s\'' % uuid.uuid4())" >> geniza/settings/local_settings.py
- name: Run webpack to process scss/js
run: npm run build
- name: Migrate database
run: python manage.py migrate
- name: Load test site data
run: python manage.py create_test_site
- name: Update Solr index
run: python manage.py index
- name: Compile translation text
run: |
sudo apt install gettext
python manage.py compilemessages
- name: Build static assets
run: python manage.py collectstatic
- name: Take DOM snapshots and upload to Percy
run: npm run test:visual
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}