-
Notifications
You must be signed in to change notification settings - Fork 431
270 lines (232 loc) · 8.58 KB
/
test_and_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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
on:
pull_request:
push:
tags:
- "v*.*.*"
branches:
- master
- develop
schedule:
- cron: '30 3 * * *'
name: Build 🔨 + Test 👨🔧
jobs:
build: #---------------------------------------------------------------------
name: Build Phar
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v3
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
tools: composer
extensions: pcntl, curl, sqlite3, zip, dom, mbstring, json
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Set up Composer caching
uses: actions/cache@v3
env:
cache-name: cache-composer-dependencies
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies
run: |
cd "$GITHUB_WORKSPACE"
# Run composer install for master else update.
if [[ "$GITHUB_REF" = "refs/heads/master" ]] || [[ "$GITHUB_REF" = "refs/tags/"* ]]; then
composer install --no-dev --no-progress --no-interaction
else
sed -i 's/\(easyengine\/.*\):\ \".*\"/\1:\ \"dev-develop\"/' composer.json
composer update --prefer-dist --no-dev --no-progress --no-interaction
fi
- name: Setup EE version
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
run: |
cd "$GITHUB_WORKSPACE"
if [[ "$GITHUB_REF" != $DEPLOY_BRANCH ]]; then
CLI_VERSION=$(head -n 1 VERSION)
CLI_VERSION="$(echo $CLI_VERSION | xargs)"
CLI_VERSION+="-nightly-$(git rev-parse --short HEAD)"
echo $CLI_VERSION > VERSION
echo "$CLI_VERSION" > VERSION
fi
env:
DEPLOY_BRANCH: "refs/heads/master"
- name: Upload EE version
uses: actions/upload-artifact@v3
with:
name: cli_version
path: VERSION
- name: Build the Phar file
run: php -dphar.readonly=0 utils/make-phar.php easyengine.phar
- name: Check phar
run: sudo ./easyengine.phar cli info
- name: Upload built Phar file
uses: actions/upload-artifact@v3
with:
name: easyengine-phar
path: easyengine.phar
test: #----------------------------------------------------------------------
runs-on: ubuntu-latest
needs: [build]
name: Behat Tests - PHP ${{ matrix.php }}
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
steps:
- name: Check out source code
uses: actions/checkout@v3
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
coverage: none
tools: composer
extensions: pcntl, curl, sqlite3, zip, dom, mbstring, json
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Set up Composer caching
uses: actions/cache@v3
env:
cache-name: cache-composer-dependencies
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Update docker
run: |
sudo apt purge nginx nginx-common docker docker-engine docker.io docker-ce containerd runc
curl -fsSL https://get.docker.com/ | sudo bash
sudo systemctl restart docker.service
- name: Install docker-compose
run: |
sudo curl -L https://github.com/docker/compose/releases/download/v2.27.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Install dependencies
run: |
cd "$GITHUB_WORKSPACE"
# Run composer install for master else update.
if [[ "$GITHUB_REF" = "refs/heads/master" ]]; then
composer install --prefer-dist --no-progress --no-interaction
else
sed -i 's/\(easyengine\/.*\):\ \".*\"/\1:\ \"dev-develop\"/' composer.json
composer update --prefer-dist --no-progress --no-interaction
fi
- name: Test
shell: 'script -q -e -c "bash {0}"'
run: |
set -e
cd $GITHUB_WORKSPACE
sudo -E ./vendor/bin/behat
sub_commands=(
vendor/easyengine/site-command/features
vendor/easyengine/site-type-php/features
vendor/easyengine/site-type-wp/features
)
for command in "${sub_commands[@]}"; do
IFS='/' read -r -a array <<< "$command"
rm -rf features/*
rsync -av --delete $command/ features/ > /dev/null
for file in features/*.feature; do mv "$file" "${file%.feature}_${array[2]}.feature"; done
echo "Running tests for $command"
sudo -E ./vendor/bin/behat
done
env:
COMPOSE_INTERACTIVE_NO_CLI: 1
- name: Output logs
if: ${{ always() }}
run: |
[[ -f "/opt/easyengine/logs/install.log" ]] && cat /opt/easyengine/logs/install.log || echo 'No install log.'
[[ -f "/opt/easyengine/logs/ee.log" ]] && cat /opt/easyengine/logs/ee.log || echo 'No run log.'
deploy: #-----------------------------------------------------------------------
name: Deploy Phar
if: |
github.repository_owner == 'EasyEngine' &&
(github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')
runs-on: ubuntu-latest
needs: [build, test]
steps:
- name: Check out builds repository
uses: actions/checkout@v3
with:
repository: easyengine/easyengine-builds
token: ${{ secrets.BOT_TOKEN }}
- name: Download built Phar file
uses: actions/download-artifact@v3
with:
name: easyengine-phar
- name: Set file name
if: ${{ contains(github.ref, 'develop') }}
run: |
echo 'FILENAME=easyengine-nightly.phar' > $GITHUB_ENV
- name: Set file name for master branch
if: ${{ contains(github.ref, 'master') }}
run: |
echo 'FILENAME=easyengine.phar' > $GITHUB_ENV
- name: Move built Phar file into correct location
run: |
mv easyengine.phar phar/$FILENAME
- name: Make built Phar executable
run: |
chmod +x phar/$FILENAME
- name : Create hashes
run: |
md5sum phar/$FILENAME | cut -d ' ' -f 1 > phar/$FILENAME.md5
sha512sum phar/$FILENAME | cut -d ' ' -f 1 > phar/$FILENAME.sha512
- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add phar/$FILENAME phar/$FILENAME.md5 phar/$FILENAME.sha512
git commit -m "phar build: $GITHUB_REPOSITORY@$GITHUB_SHA"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.BOT_TOKEN }}
branch: master
repository: easyengine/easyengine-builds
release: #-----------------------------------------------------------------------
name: Create release
if: |
github.repository_owner == 'EasyEngine' &&
startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: [build, test]
steps:
- name: Check out source code
uses: actions/checkout@v3
- name: Download built Phar file
uses: actions/download-artifact@v3
with:
name: easyengine-phar
- name: Create hashes
run: |
md5sum easyengine.phar | cut -d ' ' -f 1 > easyengine.phar.md5
sha512sum easyengine.phar | cut -d ' ' -f 1 > easyengine.phar.sha512
- name: Authenticate gh-cli
run: echo ${{ secrets.BOT_TOKEN }} | gh auth login --with-token
- name: Generate changelog
run: bash utils/changelog.sh
- name: Get tag
id: tag
run: echo tag=${GITHUB_REF/refs\/tags\//} >> $GITHUB_OUTPUT
- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: changelog.txt
files: |
easyengine.phar
easyengine.phar.md5
easyengine.phar.sha512
draft: true
name: EasyEngine ${{ steps.tag.outputs.tag }}
token: ${{ secrets.GITHUB_TOKEN }}