-
Notifications
You must be signed in to change notification settings - Fork 2
148 lines (126 loc) · 6.44 KB
/
module_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
name: Tests
env:
COMPOSER_TOKEN: ${{ secrets.COMPOSER_TOKEN }}
PHP_VERSION: ${{ secrets.PHP_VERSION }}
MYSQL_HOST: ${{ secrets.MYSQL_HOST }}
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
MYSQL_USER: ${{ secrets.MYSQL_USER }}
MYSQL_PORT: ${{ secrets.MYSQL_PORT }}
ELASTIC_HOST: ${{ secrets.ELASTIC_HOST }}
ELASTIC_PORT: 9200
PACKAGIST_URL: ${{ secrets.PACKAGIST_URL }}
MAGENTO_VERSION: '2.4.2'
MODULE_NAME: 'vendic/magento2-postcode-nl'
on:
push:
branches:
- '**'
tags-ignore:
- '*.*.*'
jobs:
phpcs:
name: Code styling
runs-on: self-hosted
steps:
- name: Clean
run: |
if [ -f "/home/runner/.ssh/id_rsa" ]; then rm /home/runner/.ssh/id_rsa; fi
echo "Cleaning up previous run"
rm -rf "${{ github.workspace }}"
rm -rf $HOME/.ssh
mkdir -p "${{ github.workspace }}"
- uses: actions/checkout@v2
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ env.PHP_VERSION }}
tools: composer:v1,
extensions: gd, bcmath, soap, pdo_mysql, ctype, curl, dom, hash, iconv, intl, mbstring, openssl, simplexml, xsl, sockets, zip
env:
runner: self-hosted
- name: Create empty folders
run: |
mkdir -p app/etc
touch app/etc/vendor_path.php
- name: Setup composer repositories
run: |
composer config repositories.private-packagist composer ${{ env.PACKAGIST_URL }}
composer config repositories.packagist.org false
- name: Install composer dependencies
run: |
composer config --global --auth http-basic.repo.packagist.com token ${{ env.COMPOSER_TOKEN }}
composer install --prefer-dist
- name: Run phpcs
run: |
vendor/bin/phpcs --config-set installed_paths vendor/magento/magento-coding-standard/
vendor/bin/phpcs --standard=Magento2 ./ --ignore="*vendor/*"
integration:
name: Integration tests
runs-on: self-hosted
steps:
- name: Clean
run: |
if [ -f "/home/runner/.ssh/id_rsa" ]; then rm /home/runner/.ssh/id_rsa; fi
echo "Cleaning up previous run"
rm -rf "${{ github.workspace }}"
rm -rf $HOME/.ssh
mkdir -p "${{ github.workspace }}"
- uses: actions/checkout@v2
- uses: FranzDiebold/github-env-vars-action@v2
- name: Set DB name
run: |
# DB name
DB_NAME=$(< /dev/urandom tr -dc a-z | head -c9)
echo "DB_NAME=$DB_NAME" >> $GITHUB_ENV
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ env.PHP_VERSION }}
tools: composer:v1
extensions: gd, bcmath, soap, pdo_mysql, ctype, curl, dom, hash, iconv, intl, mbstring, openssl, simplexml, xsl, sockets, zip
env:
runner: self-hosted
- name: Create folder for Magento 2
run: |
mkdir magento2
chmod 775 magento2
- name: Setup composer authentication
run: |
composer config --global --auth http-basic.repo.packagist.com token ${{ env.COMPOSER_TOKEN }}
- name: Copy Magento 2 composer.json
run: |
cp .github/workflows/_files/composer.json magento2/composer.json
- name: Prepare test database
run: |
echo 'CREATE DATABASE IF NOT EXISTS ${{ env.DB_NAME }};' | mysql -h ${{ env.MYSQL_HOST }} -u${{ env.MYSQL_USER}} -p${{ env.MYSQL_PASSWORD }} --port=${{ env.MYSQL_PORT }}
- name: Prepare integration test config
run: |
sed -i -e "s/{{mysql-db-name}}/${{ env.DB_NAME }}/g" .github/workflows/_files/install-config-mysql.php
sed -i -e "s/{{mysql-host}}/${{ env.MYSQL_HOST }}:${{ env.MYSQL_PORT }}/g" .github/workflows/_files/install-config-mysql.php
sed -i -e "s/{{mysql-password}}/${{ env.MYSQL_PASSWORD }}/g" .github/workflows/_files/install-config-mysql.php
sed -i -e "s/{{mysql-user}}/${{ env.MYSQL_USER }}/g" .github/workflows/_files/install-config-mysql.php
sed -i -e "s/{{elasticsearch-host}}/${{ env.ELASTIC_HOST }}/g" .github/workflows/_files/install-config-mysql.php
sed -i -e "s/{{elasticsearch-port}}/${{ env.ELASTIC_PORT }}/g" .github/workflows/_files/install-config-mysql.php
mkdir -p magento2/dev/tests/integration/etc
cp .github/workflows/_files/install-config-mysql.php magento2/dev/tests/integration/etc/install-config-mysql.php
cat magento2/dev/tests/integration/etc/install-config-mysql.php
- name: Setup Magento 2
run: |
cd magento2
COMPOSER_MEMORY_LIMIT=-3 composer require magento/product-community-edition ${{ env.MAGENTO_VERSION }} --no-update
COMPOSER_MEMORY_LIMIT=-3 composer update
COMPOSER_MEMORY_LIMIT=-3 composer config minimum-stability dev
- name: Install module
run: |
cd magento2
COMPOSER_MEMORY_LIMIT=-3 composer require ${{ env.MODULE_NAME }}:dev-${{ env.CI_REF_NAME }}
- name: Run integration tests
run: |
cd magento2/dev/tests/integration
../../../vendor/bin/phpunit -c phpunit.xml.dist ../../../vendor/${{ env.MODULE_NAME }}
- name: Clean DB
if: ${{ always() }}
run: |
echo 'DROP DATABASE IF EXISTS ${{ env.DB_NAME }};' | mysql -h ${{ env.MYSQL_HOST }} -u${{ env.MYSQL_USER}} -p${{ env.MYSQL_PASSWORD }} --port=${{ env.MYSQL_PORT }}