-
Notifications
You must be signed in to change notification settings - Fork 1
162 lines (136 loc) · 5.99 KB
/
end-to-end-test-suite.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: End-to-end tests
on:
push:
branches:
- main
paths-ignore:
- '**.md'
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: Debug with tmate
default: false
permissions:
contents: read
env:
# Allow ddev get to use a GitHub token to prevent rate limiting by tests
DDEV_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
end-to-end-test-suite:
strategy:
fail-fast: false
matrix:
# Last 2 patches for the current minor, and last patch for the previous minor, greatest php version
include:
- m2-version: '2.3.7-p4'
php-version: '7.4'
- m2-version: '2.4.5'
php-version: '8.1'
- m2-version: '2.4.6'
php-version: '8.2'
name: End-to-end test suite
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
runs-on: ubuntu-latest
env:
EXTENSION_PACKAGE_NAME: "crowdsec/magento2-module-engine"
EXTENSION_NAME: "CrowdSec_Engine"
EXTENSION_PATH: "crowdsec-engine"
steps:
- name: Install Magento 2 with DDEV
id: magento_install
uses: julienloizelet/[email protected]
with:
php_version: ${{ matrix.php-version }}
magento_version: ${{ matrix.m2-version }}
composer_auth: ${{ secrets.M2_COMPOSER_AUTH }}
magento_repository: "https://mirror.mage-os.org/"
- name: Add Redis and Memcached
run: |
ddev get ddev/ddev-redis
ddev get ddev/ddev-memcached
# override redis.conf
ddev get julienloizelet/ddev-tools
- name: Playwright
run: ddev get julienloizelet/ddev-playwright
- name: Clone M2 ${{ env.EXTENSION_NAME }} files
uses: actions/checkout@v3
with:
path: my-own-modules/${{ env.EXTENSION_PATH }}
- name: Validate composer.json
run: ddev composer validate --working-dir ./my-own-modules/${{ env.EXTENSION_PATH }}
- name: Prepare composer repositories
run: |
ddev composer config --unset repositories.0
ddev composer config repositories.0 '{"type": "path", "url":"my-own-modules/${{ env.EXTENSION_PATH }}/", "canonical": true}'
ddev composer config repositories.1 '{"type": "composer", "url":"https://repo.magento.com/", "exclude": ["${{ env.EXTENSION_PACKAGE_NAME }}", "magento/composer-dependency-version-audit-plugin"]}'
- name: Add ${{ env.EXTENSION_NAME }} as composer dependency
run: |
ddev composer require ${{ env.EXTENSION_PACKAGE_NAME }}:@dev --no-interaction
- name: Disable some extensions for 2.4.6
if: startsWith(matrix.m2-version, '2.4.6')
run: |
ddev magento module:disable Magento_AdminAdobeImsTwoFactorAuth
- name: Disable some extensions for 2.4
if: startsWith(matrix.m2-version, '2.4')
run: |
ddev magento module:disable Magento_TwoFactorAuth
ddev magento module:disable Magento_AdminNotification
- name: Make some workaround for 2.3.5
if: startsWith(matrix.m2-version, '2.3.5')
run: |
ddev magento module:disable Dotdigitalgroup_Chat
ddev magento module:disable Dotdigitalgroup_Email
- name: Enable extension
run: |
ddev magento deploy:mode:set developer
ddev magento module:enable ${{ env.EXTENSION_NAME }}
ddev magento setup:upgrade
ddev magento setup:static-content:deploy -f
- name: Prepare for playwright test
run: |
# Override the Playwright test folder
ddev get julienloizelet/ddev-crowdsec-php
cp .ddev/okaeli-add-on/magento2/custom_files/crowdsec/engine/docker-compose.override.yaml .ddev/docker-compose.override.yaml
ddev restart
# Add some fixture data
cp .ddev/okaeli-add-on/magento2/custom_files/varnish-profile.xml varnish-profile.xml
ddev magento setup:performance:generate-fixtures ./varnish-profile.xml
# Set base url in Playwright config
sed -i 's|CHANGE_BASE_URL|${{ steps.magento_install.outputs.m2_url }}|g' my-own-modules/${{ env.EXTENSION_PATH }}/Test/EndToEnd/.env.example
# Install Playwright
ddev playwright-install
# Copy some scripts for tests
cp .ddev/okaeli-add-on/magento2/custom_scripts/cronLaunch.php ${{ github.workspace }}/pub/cronLaunch.php
cp .ddev/okaeli-add-on/magento2/custom_scripts/crowdsec/engine/runActions.php ${{ github.workspace }}/pub/runActions.php
# Force machine_id and passord to avoid creation of a new machine every time a test is launched
curl -v "https://${{ env.M2_VERSION_CODE }}.ddev.site/runActions.php?action=store-credentials&id=${{ secrets.MACHINE_ID }}&password=${{ secrets.MACHINE_PASSWORD }}"
# Set Enroll key in config
ddev magento config:set crowdsec_engine/general/enrollment_key ${{ secrets.ENROLL_KEY }}
ddev magento cache:flush
- name: Run config test
run: ddev playwright test config
- name: Run detect pages scan test
run: ddev playwright test pages-scan
- name: Run detect user enum test
run: ddev playwright test user-enum
- name: Run cron test
run: ddev playwright test cron
- name: Run alert test
run: ddev playwright test alert
- name: Run reports test
run: ddev playwright test reports
- name: Keep Playwright report
uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report-${{ matrix.php-version }}-${{ matrix.m2-version }}
path: my-own-modules/${{ env.EXTENSION_PATH }}/Test/EndToEnd/playwright-report/
retention-days: 10
- name: Debug with tmate
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
github-token: ${{ secrets.GITHUB_TOKEN }}
timeout-minutes: 30
if: failure() && github.event.inputs.debug_enabled == 'true'