Skip to content

Commit de5ce6e

Browse files
authored
Merge pull request #158 from laminas/feature/roave-backward-compatibility-check
Introduce `roave/backward-compatibility-check` and `@default` php version
2 parents fb9164e + ab912c8 commit de5ce6e

File tree

9 files changed

+2898
-108
lines changed

9 files changed

+2898
-108
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
setup/markdownlint/node_modules
2-
setup/staabm-annotate-pull-request-from-checkstyle/vendor

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor/

Dockerfile

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,6 @@ RUN cd /markdownlint \
2929
&& if node_modules/.bin/markdownlint-cli2 /test-files/dummy-ko-markdown-test-file.md; then exit 1; else exit 0; fi
3030

3131

32-
FROM composer AS staabm-annotate-pull-request-from-checkstyle
33-
34-
COPY setup/staabm-annotate-pull-request-from-checkstyle/composer.json \
35-
setup/staabm-annotate-pull-request-from-checkstyle/composer.lock \
36-
/staabm-annotate-pull-request-from-checkstyle/
37-
38-
RUN cd /staabm-annotate-pull-request-from-checkstyle \
39-
&& composer install \
40-
--no-dev \
41-
--classmap-authoritative
42-
43-
4432
FROM base-distro
4533

4634
LABEL "repository"="http://github.com/laminas/laminas-continuous-integration-action"
@@ -53,16 +41,18 @@ ENV COMPOSER_HOME=/usr/local/share/composer \
5341

5442
# This may look a bit long, but it's just a big `apt install` section, followed by a cleanup,
5543
# so that we get a single compact layer, with not too many layer overwrites.
56-
RUN apt update \
44+
RUN export OS_VERSION=$(cat /etc/os-release | grep VERSION_ID | cut -d '"' -f2) \
45+
&& apt update \
5746
&& apt upgrade -y \
5847
&& apt install -y --no-install-recommends \
5948
curl \
6049
gpg-agent \
6150
software-properties-common \
62-
&& (curl -sSL https://packages.microsoft.com/keys/microsoft.asc | apt-key add -) \
51+
&& (curl -sSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/microsoft.gpg) \
6352
&& add-apt-repository -y ppa:ondrej/php \
64-
&& add-apt-repository -y https://packages.microsoft.com/ubuntu/22.04/prod \
53+
&& curl -sSL https://packages.microsoft.com/config/ubuntu/$OS_VERSION/prod.list | tee /etc/apt/sources.list.d/microsoft.list \
6554
&& (curl -ssL https://deb.nodesource.com/setup_20.x | bash -) \
55+
&& apt update \
6656
&& apt install -y --no-install-recommends \
6757
# Base dependencies
6858
git \
@@ -76,7 +66,7 @@ RUN apt update \
7666
yamllint \
7767
zip \
7868
unzip \
79-
msodbcsql17 \
69+
msodbcsql18 \
8070
\
8171
php-pear \
8272
\
@@ -220,10 +210,6 @@ RUN apt update \
220210
php8.2-xml \
221211
php8.2-xsl \
222212
php8.2-zip \
223-
# Set default PHP version
224-
&& update-alternatives --set php /usr/bin/php8.0 \
225-
&& update-alternatives --set phpize /usr/bin/phpize8.0 \
226-
&& update-alternatives --set php-config /usr/bin/php-config8.0 \
227213
&& apt autoremove -y \
228214
&& apt clean
229215

@@ -245,12 +231,6 @@ COPY --from=install-markdownlint /markdownlint /markdownlint
245231
RUN ln -s /markdownlint/node_modules/.bin/markdownlint-cli2 /usr/local/bin/markdownlint
246232
COPY --from=install-markdownlint /markdownlint/markdownlint.json /etc/laminas-ci/markdownlint.json
247233

248-
249-
# Copy staabm/annotate-pull-request-from-checkstyle to this stage
250-
COPY --from=staabm-annotate-pull-request-from-checkstyle /staabm-annotate-pull-request-from-checkstyle /staabm-annotate-pull-request-from-checkstyle
251-
RUN ln -s /staabm-annotate-pull-request-from-checkstyle/vendor/bin/cs2pr /usr/local/bin/cs2pr
252-
253-
254234
# Add composer binary to the image
255235
COPY --from=composer /usr/bin/composer /usr/bin/composer
256236

@@ -263,6 +243,34 @@ COPY setup/markdownlint/problem-matcher.json /etc/laminas-ci/problem-matcher/mar
263243
COPY setup/phpunit/problem-matcher.json /etc/laminas-ci/problem-matcher/phpunit.json
264244

265245

246+
# Setup external tools
247+
COPY composer.json \
248+
composer.lock \
249+
/tools/
250+
251+
RUN cd /tools \
252+
# Install `ext-bcmath` as it seems to be a requirement for `roave/backward-compatibility-check`
253+
&& apt install -y php-bcmath \
254+
&& composer install \
255+
--classmap-authoritative
256+
257+
# Set default PHP version based on the `composer.json` `config.platform.php` setting
258+
RUN export DEFAULT_PHP_VERSION=$(jq -r '.config.platform.php | sub("(?<minor>[0-9.]).99$"; "\(.minor)")' /tools/composer.json) \
259+
# Cleanup composer files from external tools folder
260+
&& rm /tools/composer.* \
261+
&& update-alternatives --set php /usr/bin/php$DEFAULT_PHP_VERSION \
262+
&& update-alternatives --set phpize /usr/bin/phpize$DEFAULT_PHP_VERSION \
263+
&& update-alternatives --set php-config /usr/bin/php-config$DEFAULT_PHP_VERSION \
264+
&& update-alternatives --set phpdbg /usr/bin/phpdbg$DEFAULT_PHP_VERSION \
265+
&& echo "DEFAULT_PHP_VERSION=${DEFAULT_PHP_VERSION}" >> /etc/environment
266+
267+
# Copy staabm/annotate-pull-request-from-checkstyle to external-tools stage
268+
RUN ln -s /tools/vendor/bin/cs2pr /usr/local/bin/cs2pr
269+
270+
# Copy roave/backward-compatibility-check to this stage
271+
RUN ln -s /tools/vendor/bin/roave-backward-compatibility-check /usr/local/bin/roave-backward-compatibility-check
272+
273+
266274
RUN useradd -ms /bin/bash testuser
267275

268276
# Copy ubuntu setup

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ The container provides the following tools:
267267

268268
- [cs2pr](https://github.com/staabm/annotate-pull-request-from-checkstyle), which creates PR annotations from checkstyle output. If a tool you are using, such as `phpcs`, provides checkstyle output, you can pipe it to `cs2pr` to create PR annotations from errors/warnings/etc. raised.
269269

270+
- [roave-backward-compatibility-check](https://github.com/Roave/BackwardCompatibilityCheck), which checks the code for BC breakages and creates PR annotations in case something will break the exposed API.
271+
270272
- A `markdownlint` binary, via the [DavidAnson/markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2) package.
271273
A default configuration is provided that disables the following rules:
272274

composer.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "laminas/laminas-continuous-integration",
3+
"description": "Provides external tools for the CI container.",
4+
"license": "MIT",
5+
"config": {
6+
"platform": {
7+
"php": "8.2.99"
8+
}
9+
},
10+
"require": {
11+
"roave/backward-compatibility-check": "^8.3",
12+
"staabm/annotate-pull-request-from-checkstyle": "^1.8"
13+
}
14+
}

0 commit comments

Comments
 (0)