-
Notifications
You must be signed in to change notification settings - Fork 9
181 lines (168 loc) · 6.01 KB
/
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
---
name: Test
on:
pull_request:
branches:
- "*"
jobs:
unit-tests:
runs-on: github-actions-runner-emarsys
permissions:
contents: "read"
strategy:
max-parallel: 1
fail-fast: false
matrix:
magento-versions:
["2.3.5ce", "2.4.0ce", "2.4.2ce", "2.4.4ce", "2.4.6ce"]
steps:
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Checkout code
shell: bash
run: |
sudo apt-get update
sudo apt-get install git -y
git clone --branch ${{ steps.extract_branch.outputs.branch }} https://github.com/emartech/magento2-extension.git
- name: Login to GitLab
uses: docker/login-action@v3
with:
registry: ${{ vars.REGISTRY_URL }}
username: ${{ secrets.GITLAB_USER }}
password: ${{ secrets.GITLAB_TOKEN }}
- name: Install system tools
shell: bash
run: |
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg -y
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-compose-plugin docker-buildx-plugin -y
- name: Build mage_node image
shell: bash
run: |
cd magento2-extension/dev
retries=3
count=0
until [ $count -ge $retries ]
do
DOCKER_BUILDKIT=1 docker build -f testv2/tools/docker/Dockerfile-mage-node --build-arg NPM_TOKEN=$NPM_TOKEN -t "mage_node" . && break
count=$((count+1))
echo "Retrying build mage_node image ($count/$retries)..."
sleep 30
done
if [ $count -ge $retries ]; then
echo "mage_node image building failed after $retries attempts."
exit 1
fi
env:
NPM_TOKEN: ${{ secrets.GITLAB_TOKEN }}
- name: Run unit test
shell: bash
run: |
cd magento2-extension
retries=3
count=0
until [ $count -ge $retries ]
do
bash dev/testv2/tools/scripts/run-unit.sh && break
count=$((count+1))
echo "Retrying unit tests ($count/$retries)..."
sleep 30
done
if [ $count -ge $retries ]; then
echo "unit tests failed after $retries attempts."
exit 1
fi
env:
VERSION: ${{ matrix.magento-versions }}
NPM_TOKEN: ${{ secrets.GITLAB_TOKEN }}
e2e-tests:
runs-on: github-actions-runner-emarsys
# needs: unit-tests
permissions:
contents: "read"
strategy:
max-parallel: 1
fail-fast: false
matrix:
magento-versions:
["2.3.5ce", "2.4.0ce", "2.4.2ce", "2.4.4ce", "2.4.6ce"]
steps:
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Checkout code
shell: bash
run: |
sudo apt-get update
sudo apt-get install git -y
git clone --branch ${{ steps.extract_branch.outputs.branch }} https://github.com/emartech/magento2-extension.git
- name: Login to GitLab
uses: docker/login-action@v3
with:
registry: ${{ vars.REGISTRY_URL }}
username: ${{ secrets.GITLAB_USER }}
password: ${{ secrets.GITLAB_TOKEN }}
- name: Install system tools
shell: bash
run: |
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg -y
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-compose-plugin docker-buildx-plugin -y
- name: Build mage_node image
shell: bash
run: |
cd magento2-extension/dev
retries=3
count=0
until [ $count -ge $retries ]
do
DOCKER_BUILDKIT=1 docker build -f testv2/tools/docker/Dockerfile-mage-node --build-arg NPM_TOKEN=$NPM_TOKEN -t "mage_node" . && break
count=$((count+1))
echo "Retrying build mage_node image ($count/$retries)..."
sleep 30
done
if [ $count -ge $retries ]; then
echo "mage_node image building failed after $retries attempts."
exit 1
fi
env:
NPM_TOKEN: ${{ secrets.GITLAB_TOKEN }}
- name: Run e2e test
shell: bash
run: |
cd magento2-extension
retries=3
count=0
until [ $count -ge $retries ]
do
bash dev/testv2/tools/scripts/run-e2e.sh && break
count=$((count+1))
echo "Retrying e2e tests ($count/$retries)..."
sleep 30
done
if [ $count -ge $retries ]; then
echo "e2e tests failed after $retries attempts."
exit 1
fi
env:
VERSION: ${{ matrix.magento-versions }}
NPM_TOKEN: ${{ secrets.GITLAB_TOKEN }}