-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (135 loc) · 5.27 KB
/
build.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
name: Testing with OXID eShop-CE
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '0 6 * * 1'
jobs:
run_tests:
strategy:
matrix:
php: [ '8.1' ]
mysql: [ '8.0' ]
fail-fast: false
runs-on: ubuntu-latest
env:
ESHOP_DOCKER_SDK_REPOSITORY: https://github.com/OXID-eSales/docker-eshop-sdk.git
SHOP_CE_REPOSITORY: https://github.com/OXID-eSales/oxideshop_ce.git
SHOP_CE_DEFAULT_BRANCH: b-8.0.x
SHOP_INSTALL_DIR: eshop_ce
DOCKER_SETUP_DIR: source
steps:
- name: Add environment variables
run: |
SHOP_ROOT_DIR="/var/www/$SHOP_INSTALL_DIR"
RUN_PHP="docker-compose run -T -w $SHOP_ROOT_DIR php"
TWIG_ROOT="/var/www/$SHOP_INSTALL_DIR/vendor/oxid-esales/twig-component"
echo "SHOP_ROOT_DIR=$SHOP_ROOT_DIR" >> $GITHUB_ENV
echo "RUN_PHP=$RUN_PHP" >> $GITHUB_ENV
echo "TWIG_ROOT=$TWIG_ROOT" >> $GITHUB_ENV
- name: Clone Docker Eshop SDK
run: |
git clone --depth 1 $ESHOP_DOCKER_SDK_REPOSITORY --branch master --single-branch .
- name: Define eShop-CE branch for cloning
run: |
if [[ $(git ls-remote --heads $SHOP_CE_REPOSITORY ${{ github.ref_name }}) ]]; then
SHOP_CE_BRANCH=${{ github.ref_name }};
else
SHOP_CE_BRANCH=$SHOP_CE_DEFAULT_BRANCH;
fi
echo "SHOP_CE_BRANCH=$SHOP_CE_BRANCH" >> $GITHUB_ENV
- name: Clone the shop
run: |
git clone --depth 1 $SHOP_CE_REPOSITORY --branch $SHOP_CE_BRANCH --single-branch $DOCKER_SETUP_DIR/$SHOP_INSTALL_DIR
- name: Prepare container configuration
run: |
make setup
make addbasicservices
perl -pi\
-e "s#PHP_VERSION=.*#PHP_VERSION='${{ matrix.php }}'#g;"\
-e "s#MYSQL_VERSION=.*#MYSQL_VERSION='${{ matrix.mysql }}'#g;"\
.env
perl -pi\
-e 's#display_errors =.*#display_errors = false#g;'\
-e 'print "xdebug.max_nesting_level=1000\n\n";'\
-e 'print "error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_WARNING\n"'\
containers/php/custom.ini
perl -pi\
-e 's#/var/www/#$SHOP_ROOT_DIR/source/#g;'\
containers/httpd/project.conf
- name: Start containers
run: |
make up
$RUN_PHP \
composer config preferred-install.oxid-esales/* source
- name: Require twig component by tag
if: github.ref_type == 'tag'
run: |
$RUN_PHP \
composer require oxid-esales/twig-component:${{ github.ref_name }} --no-update
- name: Require twig component (${{ github.ref_name }})
if: github.ref_type != 'tag'
run: |
$RUN_PHP \
composer require oxid-esales/twig-component:dev-${{ github.ref_name }} --no-update
- name: Run Composer install
run: |
$RUN_PHP \
composer require squizlabs/php_codesniffer
$RUN_PHP \
composer install --no-interaction
- name: Prepare for PHP_CS check
run: |
cd source/eshop_ce/vendor/oxid-esales/twig-component
git diff --name-only origin/${{ github.ref_name }} HEAD~1 | grep '\.php$' >changed-files.txt || true
if [[ -f "changed-files.txt" && -s "changed-files.txt" ]]; then
perl -pi -e "s#^#$TWIG_ROOT/#" changed-files.txt
if [[ -f "changed-files.txt" && -s "changed-files.txt" ]]; then
cd ../../../../../
$RUN_PHP \
vendor/bin/phpcs \
--standard=psr12 \
--ignore=tests/*/Fixtures/* \
--exclude=Generic.Files.LineLength \
--file-list=$TWIG_ROOT/changed-files.txt 2>&1 \
| tee php_codesniff_log.txt || true
rm source/eshop_ce/vendor/oxid-esales/twig-component/changed-files.txt
if grep -q -Ei 'fail|\\.\\=\\=|Warning|Notice|Deprecated|Fatal|Error' php_codesniff_log.txt;
then exit 1;
fi
fi
fi
- name: Run Install Shop
run: |
$RUN_PHP \
cp source/config.inc.php.dist source/config.inc.php
$RUN_PHP \
bin/oe-console oe:setup:shop \
--db-host mysql \
--db-port 3306 \
--db-name example \
--db-user root \
--db-password root \
--shop-url localhost.localhost \
--shop-directory $SHOP_ROOT_DIR/source/ \
--compile-directory $SHOP_ROOT_DIR/source/tmp/
- name: Run component tests
# Put PHPUnit logs to the eShop log folder
run: |
$RUN_PHP \
php vendor/bin/phpunit \
--configuration phpunit.xml \
--bootstrap source/bootstrap.php \
vendor/oxid-esales/twig-component/tests \
--testdox-text source/log/phpunit_log.txt
- name: Upload logged artifacts
uses: actions/upload-artifact@v3
with:
name: eshop_source_log_folder
path: ${{ env.DOCKER_SETUP_DIR }}/${{ env.SHOP_INSTALL_DIR }}/source/log/
retention-days: 7
if-no-files-found: error
- name: Stop containers
run: |
make down