forked from TYPO3-Solr/ext-solr
-
Notifications
You must be signed in to change notification settings - Fork 0
244 lines (237 loc) · 9.47 KB
/
ci.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
name: build
on:
push:
branches: [ main, release-12.0.x, release-11.6.x, release-11.5.x, task/*_compatibility ]
tags:
- "**"
pull_request:
branches: [ main, release-12.0.x, release-11.6.x, release-11.5.x, task/*_compatibility ]
env:
CI_BUILD_DIRECTORY: '/home/runner/work/ext-solr/ext-solr/.Build'
LOCAL_IMAGE_NAME: 'solrci-image:latest'
LOCAL_CONTAINER_NAME: 'solrci-container'
TESTING_SOLR_PORT: 8983
LOCAL_VOLUME_NAME: 'solrci-volume'
LOCAL_VOLUME_PATH: '/home/runner/work/ext-solr/ext-solr/.Build/data-solr'
jobs:
ci_bootstrapping:
name: "Build and test docker image + Collect build matrix"
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.collect_build_matrix.outputs.matrix }}
steps:
# Workaround for issue with actions/checkout "wrong PR commit checkout":
# See:
# ** https://github.com/actions/checkout/issues/299#issuecomment-677674415
# ** https://github.com/actions/checkout/issues/1359#issuecomment-1631503791
-
name: Checkout current state of Pull Request
if: github.event_name == 'pull_request'
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
-
name: Checkout current state of Branch
if: github.event_name == 'push'
uses: actions/checkout@v3
# End: Workaround for issue with actions/checkout...
-
name: "Resolve target branch of pull request."
if: github.event_name == 'pull_request'
run: |
echo "BRANCH_NAME=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV
-
name: "Resolve branch name on push in branch of repository."
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
run: |
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
-
# We want to pass tests before the tag/release can be pushed to TER.
# This step resolves the branch name of the tag to use, to be able to collect proper build matrix values.
name: "Resolve branch name on release/tag in branch of repository."
if: startsWith(github.ref, 'refs/tags/')
# //[!0-9]/ in script below removes possible "v" prefix from major part,
# to prevent errors or make it possible to create tags with "v" or other prefixes.
run: |
export RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}
export MAJOR_MINOR_VERSIONS_STRING=$(v=( ${RELEASE_VERSION//./ } ) && echo "${v[0]//[!0-9]/}.${v[1]}")
export BRANCH_NAME=release-"$MAJOR_MINOR_VERSIONS_STRING".x
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
-
name: Collect build matrix
id: collect_build_matrix
run: |
export matrix=$(cat .github/workflows/ci-matrix.json | jq --raw-output .\"${{ env.BRANCH_NAME }}\")
echo "Base ref is $GITHUB_BASE_REF"
echo "BRANCH_NAME="$BRANCH_NAME
echo -e "matrix : "
echo $matrix
echo "matrix=$(echo $matrix)" >> $GITHUB_OUTPUT
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Build Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Docker/SolrServer/Dockerfile
tags: solrci-image:latest
outputs: type=docker,dest=/tmp/solrci-image.tar
-
name: Test Image
run: |
pwd
ls -la ../
docker load --input /tmp/solrci-image.tar
docker image ls -a
./Build/Test/cibuild_docker.sh
-
name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: solrci-image
path: /tmp/solrci-image.tar
tests:
runs-on: ubuntu-latest
needs: ci_bootstrapping
continue-on-error: ${{ contains(matrix.TYPO3, '-dev') }}
strategy:
matrix: ${{fromJson(needs.ci_bootstrapping.outputs.matrix)}}
env:
TYPO3_DATABASE_NAME: 'typo3_ci'
TYPO3_DATABASE_HOST: '127.0.0.1'
TYPO3_DATABASE_USERNAME: 'root'
TYPO3_DATABASE_PASSWORD: 'root'
TYPO3_VERSION: ${{ matrix.TYPO3 }}
name: TYPO3 ${{ matrix.TYPO3 }} on PHP ${{ matrix.PHP }}
steps:
# Workaround for issue with actions/checkout "wrong PR commit checkout". See: ci_bootstrapping job
-
name: Checkout current state of Pull Request
if: github.event_name == 'pull_request'
uses: actions/checkout@v3
with:
fetch-depth: 2
ref: ${{ github.event.pull_request.head.sha }}
-
name: Checkout current state of Branch
if: github.event_name == 'push'
uses: actions/checkout@v3
with:
fetch-depth: 2
# End: Workaround for issue with actions/checkout...
-
name: Mount RAMFS
run: |
mkdir -p ${{ env.CI_BUILD_DIRECTORY }}
sudo mount -t tmpfs -o size=1G none ${{ env.CI_BUILD_DIRECTORY }}
sudo mkdir -p ${{ env.CI_BUILD_DIRECTORY }}/data-{solr,mysql} \
&& sudo chown $USER ${{ env.CI_BUILD_DIRECTORY }}/data-mysql \
&& sudo chown 8983:8983 ${{ env.CI_BUILD_DIRECTORY }}/data-solr
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Download solrci-image from "ci_bootstrapping" job
uses: actions/download-artifact@v3
with:
name: solrci-image
path: /tmp
-
name: 'Start Docker: Solr, MySQL'
run: |
docker load --input /tmp/solrci-image.tar
docker run --name "MySQL-CI" -v ${{ env.CI_BUILD_DIRECTORY }}/data-mysql:/var/lib/mysql -p 3306:3306 \
-e MYSQL_DATABASE=$TYPO3_DATABASE_NAME \
-e MYSQL_ROOT_PASSWORD=$TYPO3_DATABASE_PASSWORD \
-d mysql:8.0 mysqld --default-authentication-plugin=mysql_native_password
sudo chmod g+w "$LOCAL_VOLUME_PATH"
docker volume create --name "$LOCAL_VOLUME_NAME" --opt type=none --opt device="$LOCAL_VOLUME_PATH" --opt o=bind
docker run --rm --name="$LOCAL_CONTAINER_NAME" -d -p 127.0.0.1:8983:8983 -v "$LOCAL_VOLUME_NAME":"/var/solr" "$LOCAL_IMAGE_NAME"
docker ps
rm /tmp/solrci-image.tar
-
name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.PHP }}
coverage: pcov
tools: composer:2.5.5
-
name: CI-Bootstrap
run: |
./Build/Test/bootstrap.sh --skip-solr-install
echo "Current Size of EXT:Solr build Artefacts before run: " \
&& sudo du -sh "${{ env.CI_BUILD_DIRECTORY }}"
-
name: CI-Build
run: |
./Build/Test/cibuild.sh
echo "Current Size of EXT:Solr build Artefacts after run: " \
&& sudo du -sh "${{ env.CI_BUILD_DIRECTORY }}" \
&& sudo du -sh ${{ env.CI_BUILD_DIRECTORY }}/*
-
name: Upload code coverage to Scrutinizer
run: |
ocular code-coverage:upload --format=php-clover coverage.unit.clover
ocular code-coverage:upload --format=php-clover coverage.integration.clover
-
name: Clean up
run: |
docker stop "MySQL-CI" 2>&1
docker stop "$LOCAL_CONTAINER_NAME" 2>&1
sudo rm -Rf ${{ env.CI_BUILD_DIRECTORY }}/Web/typo3temp/* \
${{ env.CI_BUILD_DIRECTORY }}/data-mysql \
${{ env.CI_BUILD_DIRECTORY }}/data-solr
publish:
name: Publish new version to TER
needs: tests
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-20.04
env:
TYPO3_API_TOKEN: ${{ secrets.TYPO3_API_TOKEN }}
steps:
-
name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
-
name: Check tag
run: |
TAGGED_VERSION=$(echo "${{ github.ref }}" | awk '{print tolower($0)}')
if ! [[ "${TAGGED_VERSION}" =~ ^refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}((-pre)?-(alpha|beta|rc)(-?[0-9]{1,3})?)?$ ]]; then
>&2 echo -e "Non-stable releases can not be published to TER. The tag ${TAGGED_VERSION} is invalid for TER."
exit 0
fi
-
name: Resolve PHP version to use
run: |
export PHP_VERSION_TO_USE=$(cat Resources/Private/Php/ComposerLibraries/composer.json | jq --raw-output '.config.platform.php')
echo "PHP_VERSION_TO_USE=$PHP_VERSION_TO_USE" >> $GITHUB_ENV
-
name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION_TO_USE }}
extensions: intl, mbstring, json, zip, curl
tools: composer:v2
-
name: Install tailor
run: composer global require typo3/tailor --prefer-dist --no-progress
-
name: Publish EXT:solr to TER
run: |
export RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}
export TER_COMMENT=$(git tag -n99 -l "$RELEASE_VERSION" | sed "s/^[0-9.]*[ ]*//g")
if [[ -z "${TER_COMMENT// }" ]]; then
export TER_COMMENT="Released version $RELEASE_VERSION of EXT:solr"
fi
echo "Following message will be printed in TER as release description:"
echo -e "$TER_COMMENT"
if ! composer extension-build; then
>&2 echo -e "Something went wrong on bulding EXT:solr for NON-Composer mode. Please look in the job."
exit 13
fi
php ~/.composer/vendor/bin/tailor ter:publish --comment "$TER_COMMENT" "$RELEASE_VERSION"