Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce roave/backward-compatibility-check and @default php version #158

Merged
merged 6 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
setup/markdownlint/node_modules
setup/staabm-annotate-pull-request-from-checkstyle/vendor
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor/
60 changes: 34 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@ RUN cd /markdownlint \
&& if node_modules/.bin/markdownlint-cli2 /test-files/dummy-ko-markdown-test-file.md; then exit 1; else exit 0; fi


FROM composer AS staabm-annotate-pull-request-from-checkstyle

COPY setup/staabm-annotate-pull-request-from-checkstyle/composer.json \
setup/staabm-annotate-pull-request-from-checkstyle/composer.lock \
/staabm-annotate-pull-request-from-checkstyle/

RUN cd /staabm-annotate-pull-request-from-checkstyle \
&& composer install \
--no-dev \
--classmap-authoritative


FROM base-distro

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

# This may look a bit long, but it's just a big `apt install` section, followed by a cleanup,
# so that we get a single compact layer, with not too many layer overwrites.
RUN apt update \
RUN export OS_VERSION=$(cat /etc/os-release | grep VERSION_ID | cut -d '"' -f2) \
&& apt update \
&& apt upgrade -y \
&& apt install -y --no-install-recommends \
curl \
gpg-agent \
software-properties-common \
&& (curl -sSL https://packages.microsoft.com/keys/microsoft.asc | apt-key add -) \
&& (curl -sSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/microsoft.gpg) \
&& add-apt-repository -y ppa:ondrej/php \
&& add-apt-repository -y https://packages.microsoft.com/ubuntu/22.04/prod \
&& curl -sSL https://packages.microsoft.com/config/ubuntu/$OS_VERSION/prod.list | tee /etc/apt/sources.list.d/microsoft.list \
&& (curl -ssL https://deb.nodesource.com/setup_20.x | bash -) \
&& apt update \
&& apt install -y --no-install-recommends \
# Base dependencies
git \
Expand All @@ -76,7 +66,7 @@ RUN apt update \
yamllint \
zip \
unzip \
msodbcsql17 \
msodbcsql18 \
boesing marked this conversation as resolved.
Show resolved Hide resolved
\
php-pear \
\
Expand Down Expand Up @@ -220,10 +210,6 @@ RUN apt update \
php8.2-xml \
php8.2-xsl \
php8.2-zip \
# Set default PHP version
&& update-alternatives --set php /usr/bin/php8.0 \
&& update-alternatives --set phpize /usr/bin/phpize8.0 \
&& update-alternatives --set php-config /usr/bin/php-config8.0 \
&& apt autoremove -y \
&& apt clean

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


# Copy staabm/annotate-pull-request-from-checkstyle to this stage
COPY --from=staabm-annotate-pull-request-from-checkstyle /staabm-annotate-pull-request-from-checkstyle /staabm-annotate-pull-request-from-checkstyle
RUN ln -s /staabm-annotate-pull-request-from-checkstyle/vendor/bin/cs2pr /usr/local/bin/cs2pr


# Add composer binary to the image
COPY --from=composer /usr/bin/composer /usr/bin/composer

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


# Setup external tools
COPY composer.json \
composer.lock \
/tools/

RUN cd /tools \
# Install `ext-bcmath` as it seems to be a requirement for `roave/backward-compatibility-check`
&& apt install -y php-bcmath \
boesing marked this conversation as resolved.
Show resolved Hide resolved
&& composer install \
Ocramius marked this conversation as resolved.
Show resolved Hide resolved
--classmap-authoritative

# Set default PHP version based on the `composer.json` `config.platform.php` setting
RUN export DEFAULT_PHP_VERSION=$(jq -r '.config.platform.php | sub("(?<minor>[0-9.]).99$"; "\(.minor)")' /tools/composer.json) \
# Cleanup composer files from external tools folder
&& rm /tools/composer.* \
&& update-alternatives --set php /usr/bin/php$DEFAULT_PHP_VERSION \
&& update-alternatives --set phpize /usr/bin/phpize$DEFAULT_PHP_VERSION \
&& update-alternatives --set php-config /usr/bin/php-config$DEFAULT_PHP_VERSION \
&& update-alternatives --set phpdbg /usr/bin/phpdbg$DEFAULT_PHP_VERSION \
&& echo "DEFAULT_PHP_VERSION=${DEFAULT_PHP_VERSION}" >> /etc/environment

# Copy staabm/annotate-pull-request-from-checkstyle to external-tools stage
RUN ln -s /tools/vendor/bin/cs2pr /usr/local/bin/cs2pr

# Copy roave/backward-compatibility-check to this stage
RUN ln -s /tools/vendor/bin/roave-backward-compatibility-check /usr/local/bin/roave-backward-compatibility-check
boesing marked this conversation as resolved.
Show resolved Hide resolved


RUN useradd -ms /bin/bash testuser

# Copy ubuntu setup
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ The container provides the following tools:

- [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.

- [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.

- A `markdownlint` binary, via the [DavidAnson/markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2) package.
A default configuration is provided that disables the following rules:

Expand Down
14 changes: 14 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "laminas/laminas-continuous-integration",
"description": "Provides external tools for the CI container.",
"license": "MIT",
"config": {
"platform": {
"php": "8.2.99"
}
},
"require": {
"roave/backward-compatibility-check": "^8.3",
"staabm/annotate-pull-request-from-checkstyle": "^1.8"
}
}
Loading