Repository navigation
142 lines (130 loc) · 5.94 KB
/
Copy pathintegration-tests.yml
File metadata and controls
142 lines (130 loc) · 5.94 KB
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
name: Magento 2 Integration Tests
on:
push:
branches: [main, master]
tags: ['*']
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
detect:
name: Detect integration tests
runs-on: ubuntu-latest
outputs:
has_tests: ${{ steps.check.outputs.has_tests }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
sparse-checkout: Test/Integration
- name: Check for integration tests
id: check
shell: bash
run: |
if [ -d "$GITHUB_WORKSPACE/Test/Integration" ]; then
echo "has_tests=true" >> "$GITHUB_OUTPUT"
else
echo "::notice::No integration tests found in Test/Integration, skipping"
echo "has_tests=false" >> "$GITHUB_OUTPUT"
fi
integration-tests:
name: Magento 2 Integration Tests
needs: detect
if: needs.detect.outputs.has_tests == 'true'
runs-on: ubuntu-latest
timeout-minutes: ${{ fromJSON(vars.INTEGRATION_JOB_TIMEOUT || '45') }}
container:
image: yireo/magento2installed:${{ vars.MAGENTO_VERSION || '2.4.8-p5' }}
credentials: ${{ secrets.DOCKERHUB_USERNAME && fromJSON(format('{{"username":"{0}","password":"{1}"}}', secrets.DOCKERHUB_USERNAME, secrets.DOCKERHUB_TOKEN)) || null }}
options: --user root
env:
MAGENTO_VERSION: ${{ vars.MAGENTO_VERSION || '2.4.8-p5' }}
COMPOSER_CACHE_DIR: /tmp/composer-cache
services:
mysql:
image: yireo/mariadb:10
credentials: ${{ secrets.DOCKERHUB_USERNAME && fromJSON(format('{{"username":"{0}","password":"{1}"}}', secrets.DOCKERHUB_USERNAME, secrets.DOCKERHUB_TOKEN)) || null }}
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: magento2
MYSQL_PASSWORD: magento2
MYSQL_DATABASE: magento2
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=10
opensearch:
image: yireo/opensearch:latest
credentials: ${{ secrets.DOCKERHUB_USERNAME && fromJSON(format('{{"username":"{0}","password":"{1}"}}', secrets.DOCKERHUB_USERNAME, secrets.DOCKERHUB_TOKEN)) || null }}
env:
'discovery.type': single-node
OPENSEARCH_JAVA_OPTS: "-Xms256m -Xmx256m"
OPENSEARCH_INITIAL_ADMIN_PASSWORD: "admin"
options: --health-cmd="curl localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" --health-interval=10s --health-timeout=5s --health-retries=10
redis:
image: redis:7
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 10
steps:
- name: Checkout sources
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Cleanup PHP
run: rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
- name: Apply Magento patches
shell: bash
run: |
cd /tmp/magento
for PATCH in patches/39216.diff patches/40410.diff; do
if [ ! -f "$PATCH" ]; then
echo "Patch $PATCH not found, skipping"
elif git apply -R --check "$PATCH" 2>/dev/null; then
echo "Patch $PATCH already applied"
else
git apply "$PATCH"
echo "Applied patch $PATCH"
fi
done
- name: Setting up module variables
shell: bash
run: |
COMPOSER_NAME=$(jq -er '.name' composer.json)
MAGENTO_MODULE=$(jq -er '.module_name' MODULE.json)
[[ "$COMPOSER_NAME" =~ ^[a-z0-9_.-]+/[a-z0-9_.-]+$ ]] || { echo "::error::Invalid composer name"; exit 1; }
[[ "$MAGENTO_MODULE" =~ ^[A-Za-z0-9]+_[A-Za-z0-9]+$ ]] || { echo "::error::Invalid module name"; exit 1; }
echo "COMPOSER_NAME=$COMPOSER_NAME" >> "$GITHUB_ENV"
echo "MAGENTO_MODULE=$MAGENTO_MODULE" >> "$GITHUB_ENV"
- name: Configure Composer
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
LOKI_REPO_USERNAME: ${{ secrets.LOKI_REPO_USERNAME }}
LOKI_REPO_PASSWORD: ${{ secrets.LOKI_REPO_PASSWORD }}
MAGENTO_MARKETPLACE_PUBLIC_KEY: ${{ secrets.MAGENTO_MARKETPLACE_PUBLIC_KEY }}
MAGENTO_MARKETPLACE_PRIVATE_KEY: ${{ secrets.MAGENTO_MARKETPLACE_PRIVATE_KEY }}
GITHUB_TOKEN: ${{ github.token }}
run: bash "$GITHUB_WORKSPACE/.github/workflows/composer-setup.sh"
- name: Restore Composer cache
if: github.event.pull_request.head.repo.fork != true && !env.ACT
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: /tmp/composer-cache
key: composer-integration-${{ env.MAGENTO_VERSION }}-${{ hashFiles('composer.json') }}
restore-keys: |
composer-integration-${{ env.MAGENTO_VERSION }}-
- name: Add module source
run: |
cp -R "$GITHUB_WORKSPACE" /tmp/magento/package-source
cd /tmp/magento
composer config repositories.local-source path package-source/
composer require -n --prefer-dist -- "${COMPOSER_NAME}:@dev" yireo/magento2-integration-test-helper
- name: Run Magento 2 Integration Tests
shell: bash
run: |
cd /tmp/magento
bin/magento module:enable --all
cd /tmp/magento/dev/tests/integration/
cp -R "$GITHUB_WORKSPACE"/.github/workflows/integration-tests/* .
if php ../../../vendor/bin/phpunit --atleast-version 10; then
cp phpunit10.xml phpunit.xml
elif php ../../../vendor/bin/phpunit --atleast-version 9; then
cp phpunit9.xml phpunit.xml
fi
MAGENTO_MODULE_FOLDER="vendor/${COMPOSER_NAME}" php -d memory_limit=-1 ../../../vendor/bin/phpunit -c phpunit.xml "../../../vendor/${COMPOSER_NAME}/Test/Integration"