-
Notifications
You must be signed in to change notification settings - Fork 4
183 lines (152 loc) · 7.89 KB
/
test.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
182
183
name: Test
on:
push:
branches:
- master
paths-ignore:
- '**/README.md'
pull_request:
branches:
- '**'
paths-ignore:
- '**/README.md'
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
byte_level:
name: Byte-level
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check file permissions
run: |
test "$(find ./ -type f -not -path './.git/*' -executable)" = "./install/bin/console"
- name: Check for byte order mark (BOM)
run: |
! git grep --perl-regexp -I -e '^\xEF\xBB\xBF'
- name: Find non-printable ASCII characters
run: |
! LC_ALL=C.UTF-8 git grep --perl-regexp --line-number -e '[^ -~]' -- '*\.php'
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.1']
steps:
- uses: actions/checkout@v3
- name: Setup PHP
id: setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip
tools: composer:v2
- name: Validate composer.json and composer.lock
run: composer validate
- name: Get composer cache directory
id: composer-cache
run: echo "dir="$(composer config cache-files-dir)"" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install composer dependencies
run: composer install
- name: Launch test suite
run: make test
project_installation_docker:
name: New project installation
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.1']
symfony: ['6.1', '6.2', '6.3']
steps:
- uses: FranzDiebold/github-env-vars-action@v2
- uses: actions/checkout@v3
with:
path: temp/sword-bundle
- name: Create temporary branch alias for master and feature branches
if: github.ref != 'refs/heads/master' && !startsWith(github.ref, 'refs/pull/')
run: |
cd temp/sword-bundle
composer config --unset extra.branch-alias.dev-master
composer config extra.branch-alias.dev-$CI_REF_NAME_SLUG 1.x-dev
- name: Create temporary branch alias for pull requests
if: startsWith(github.ref, 'refs/pull/')
run: |
cd temp/sword-bundle
composer config --unset extra.branch-alias.dev-master
composer config extra.branch-alias.dev-$CI_SHA 1.x-dev
- name: Setup PHP
id: setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, redis, sysvsem
tools: composer:v2, symfony
coverage: none
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create a new project
run: |
git config --global user.email "[email protected]"
git config --global user.name "Sword"
symfony new newproject --webapp --version="${{ matrix.symfony }}"
cd newproject
composer remove symfony/asset-mapper
cp -Rp . ../
cd ..
rm -rf newproject
rm composer.lock
rm -f docker-compose*
echo "APP_NAME=sword" >> .env
echo "PROJECT_DIR=${PWD##*/}" >> .env
echo "MAILER_DSN=smtp://mailer:25" >> .env
composer config --no-interaction minimum-stability dev
composer config --no-interaction prefer-stable true
composer config --no-interaction repositories.wordpress '{"type": "composer", "url": "https://wpackagist.org", "only": ["wpackagist-plugin/*", "wpackagist-theme/*"]}'
composer config --no-interaction repositories.sword path ./temp/sword-bundle
composer config --no-interaction allow-plugins.composer/installers true
composer config --no-interaction allow-plugins.composer/package-versions-deprecated true
composer config --no-interaction allow-plugins.johnpbloch/wordpress-core-installer true
composer config --no-interaction allow-plugins.ergebnis/composer-normalize true
composer config --no-interaction --json extra.installer-paths.wp/content/plugins/{\$name}/ '["type:wordpress-plugin"]'
composer config --no-interaction --json extra.installer-paths.wp/content/themes/{\$name}/ '["type:wordpress-theme"]'
composer config --no-interaction extra.symfony.allow-contrib true
composer config --no-interaction extra.wordpress-install-dir "wp/core"
composer require --no-interaction phpsword/sword-bundle johnpbloch/wordpress wpackagist-plugin/akismet wpackagist-theme/twentytwentytwo
composer require --no-interaction --dev ergebnis/composer-normalize roave/security-advisories:dev-latest
composer normalize --no-interaction
rm bin/console
cp vendor/phpsword/sword-bundle/install/docker-compose.yml docker-compose.yml
cp vendor/phpsword/sword-bundle/install/docker-compose.prod.yml docker-compose.prod.yml
cp vendor/phpsword/sword-bundle/install/bin/console bin/console
# Remove symlink and copy actual files so it gets copied later in the installer image
rm vendor/phpsword/sword-bundle
cd ./temp/sword-bundle
cp -Rp . ../../vendor/phpsword/sword-bundle
cd ../..
- name: Build Docker installer
run: |
wget https://raw.githubusercontent.com/phpsword/installer/master/.dockerignore
mkdir build
wget -O build/Dockerfile https://raw.githubusercontent.com/phpsword/installer/master/build/Dockerfile
wget -O build/docker-entrypoint.sh https://raw.githubusercontent.com/phpsword/installer/master/build/docker-entrypoint.sh
docker build --no-cache -t projectinstaller:latest -f ./build/Dockerfile .
- name: Create Docker environment
run: |
docker run --rm -t -e HOST_PWD="$PWD" \
-v "$PWD":/app -v /var/run/docker.sock:/var/run/docker.sock \
projectinstaller testproject -v
sleep 20
- name: Check that website is up and running
run: |
wget --no-check-certificate -O- https://testproject.localhost/
url=$(curl https://testproject.localhost -k -s -L -I -o /dev/null -w '%{url_effective}')
echo $url
[ "$url" = "https://testproject.localhost/wp-admin/install.php" ]