forked from redaxo/redaxo
-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (125 loc) · 6.7 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
name: Visual Regression Testing
on:
push:
branches: [main, bugfix, temp]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
repository_dispatch:
types: [visual-test-command] # triggered by /visual-test PR comment
env:
writable: ${{ (github.event_name == 'repository_dispatch' || github.ref == 'refs/heads/temp' || github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') && 1 || 0 }}
permissions:
contents: read
jobs:
visual-tests:
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write # for Git to git apply
steps:
- name: Add action run link to trigger comment
uses: peter-evans/create-or-update-comment@v2
if: github.event_name == 'repository_dispatch'
with:
token: ${{ secrets.BOT_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
```
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
```
- name: Checkout
uses: actions/checkout@v3
if: env.writable == 1 && github.event_name != 'repository_dispatch'
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.BOT_TOKEN }}
- name: Checkout fork
uses: actions/checkout@v3
if: env.writable == 0
- name: Checkout on chat commnad
uses: actions/checkout@v3
if: github.event_name == 'repository_dispatch'
with:
token: ${{ secrets.BOT_TOKEN }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
ini-values: 'error_reporting=E_ALL, display_errors=On, display_startup_errors=On'
extensions: gd, pdo_mysql
coverage: none # disable xdebug, pcov
tools: cs2pr
- name: Init database
run: |
sudo /etc/init.d/mysql start
mysql -uroot -h127.0.0.1 -proot -e 'create database redaxo5;'
git apply .github/workflows/default.config.yml.github-action.diff
- name: Setup
run: |
php .tools/bin/setup
- name: Create user, update config
run: |
php redaxo/bin/console user:create myusername mypassword --admin --ansi
php redaxo/bin/console config:set error_email '[email protected]' --ansi
- name: Import mock data
run: |
mkdir -p $GITHUB_WORKSPACE/redaxo/data/addons/backup && cp -r .github/imports/inital-content-for-visual-tests.sql $GITHUB_WORKSPACE/redaxo/data/addons/backup/
cp -r .github/imports/media/* $GITHUB_WORKSPACE/media/
cp -f .github/imports/README.md $GITHUB_WORKSPACE/redaxo/src/addons/project/README.de.md
php redaxo/bin/console setup:run -n --lang=de_de --agree-license --db-password=root --db-setup=import --db-import=inital-content-for-visual-tests --admin-username=myusername --admin-password=mypassword --ansi
- name: Install packages
run: |
php redaxo/bin/console package:install phpmailer --ansi
php redaxo/bin/console package:install cronjob --ansi
php redaxo/bin/console package:install cronjob/article_status --ansi
php redaxo/bin/console package:install cronjob/optimize_tables --ansi
php redaxo/bin/console package:install debug --ansi
php redaxo/bin/console package:install structure/history --ansi
php redaxo/bin/console package:install structure/version --ansi
- name: Setup nodejs
uses: actions/setup-node@v3
with:
node-version: 19
- name: Setup Webserver
run: |
php -S localhost:8000 &
npm install puppeteer@6 pixelmatch pngjs fs mkdirp
- name: Take screenshots (differential)
if: github.event_name != 'repository_dispatch'
run: |
php redaxo/bin/console config:set setup true -t boolean --ansi
php redaxo/bin/console cache:clear --ansi
node .github/tests-visual/visual-record.js setup
php redaxo/bin/console config:set setup false -t boolean --ansi
php redaxo/bin/console cache:clear --ansi
node .github/tests-visual/visual-record.js
git diff --exit-code --name-only .github/tests-visual/
- name: Force regenerate all screenshots
if: github.event_name == 'repository_dispatch'
run: |
php redaxo/bin/console config:set setup true -t boolean --ansi
php redaxo/bin/console cache:clear --ansi
node .github/tests-visual/visual-record.js setup regenerate-all
php redaxo/bin/console config:set setup false -t boolean --ansi
php redaxo/bin/console cache:clear --ansi
node .github/tests-visual/visual-record.js regenerate-all
git diff --exit-code --name-only .github/tests-visual/
- name: Commit changed files
uses: stefanzweifel/git-auto-commit-action@v4
if: failure() && env.writable == 1
with:
commit_message: Update screenshots
commit_user_name: rex-bot
commit_user_email: [email protected]
file_pattern: .github/tests-visual/*
# repo dispatch needs the target branch
branch: ${{ github.head_ref }}
- name: Remove automerge label
uses: actions-ecosystem/action-remove-labels@v1
if: failure() && env.writable == 1
with:
github_token: ${{ secrets.BOT_TOKEN }}
labels: automerge