Skip to content

Commit 4bea386

Browse files
committed
Use Dockerfile for reproducible Behat test environment
1 parent 3018777 commit 4bea386

3 files changed

Lines changed: 66 additions & 24 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# An approximately reproducible, but primarily isolated, environment for
2+
# running the acceptance tests:
3+
#
4+
# docker buildx build --file .github/pie-behaviour-tests/Dockerfile -t pie-behat-test .
5+
# docker run --volume .:/github/workspace -ti pie-behat-test
6+
FROM ubuntu:24.04
7+
8+
# Add the `unzip` package which PIE uses to extract .zip files
9+
RUN export DEBIAN_FRONTEND="noninteractive"; \
10+
set -eux; \
11+
apt-get update; \
12+
apt-get install -y --no-install-recommends \
13+
unzip curl jq wget g++ gcc make autoconf libtool bison re2c pkg-config \
14+
ca-certificates libxml2-dev libssl-dev; \
15+
update-ca-certificates ; \
16+
rm -rf /var/lib/apt/lists/*
17+
18+
# Compile PHP
19+
ARG PHP_VERSION=8.4
20+
RUN mkdir -p /usr/local/src/php; \
21+
cd /usr/local/src/php; \
22+
FULL_LATEST_VERSION=`curl -fsSL "https://www.php.net/releases/index.php?json&max=1&version=$PHP_VERSION" | jq -r '.[].source[]|select(.filename|endswith(".gz")).filename'`; \
23+
wget -O php.tgz "https://www.php.net/distributions/$FULL_LATEST_VERSION" ; \
24+
tar zxf php.tgz ; \
25+
rm php.tgz ; \
26+
ls -l ; \
27+
cd * ; \
28+
ls -l ; \
29+
./buildconf --force ; \
30+
./configure --without-sqlite3 --disable-pdo --disable-dom --disable-xml --disable-xmlreader --disable-xmlwriter --disable-json --with-openssl ; \
31+
make -j$(nproc) ; \
32+
make install
33+
34+
RUN touch /usr/local/lib/php.ini
35+
36+
COPY --from=ghcr.io/php/pie:bin /pie /usr/bin/pie
37+
RUN pie install xdebug/xdebug
38+
39+
WORKDIR /github/workspace
40+
41+
ENV USING_PIE_BEHAT_DOCKERFILE=1
42+
ENTRYPOINT ["php", "vendor/bin/behat"]
43+
CMD ["--no-snippets"]

.github/workflows/continuous-integration.yml

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -138,38 +138,18 @@ jobs:
138138
matrix:
139139
operating-system:
140140
- ubuntu-latest
141-
- windows-latest
142141
php-versions:
143142
- '8.1'
144143
- '8.2'
145144
- '8.3'
146145
- '8.4'
147-
- '8.5'
148146
steps:
149-
- name: Setup PHP
150-
uses: shivammathur/setup-php@v2
151-
with:
152-
php-version: ${{ matrix.php-versions }}
153-
extensions: none, intl, zip
154-
tools: composer
155-
env:
156-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157147
- uses: actions/checkout@v5
158-
- name: Testing
159-
run: |
160-
php -m
161-
bin/pie show --all
162-
which composer
163-
composer -v
164148
- uses: ramsey/composer-install@v3
165-
- name: Run Behat on Windows
166-
if: matrix.operating-system == 'windows-latest'
167-
run: vendor/bin/behat --no-snippets --tags="~@non-windows"
168-
env:
169-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
170-
- name: Run Behat on non-Windows
171-
if: matrix.operating-system != 'windows-latest'
172-
run: sudo vendor/bin/behat --no-snippets
149+
- name: Build
150+
run: docker buildx build --file .github/pie-behaviour-tests/Dockerfile --build-arg PHP_VERSION=${{ matrix.php-versions }} -t pie-behat-test .
151+
- name: Run Behat
152+
run: docker run --volume .:/github/workspace pie-behat-test
173153
env:
174154
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
175155

behat.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@
88
use Behat\Config\Suite;
99
use Php\PieBehaviourTest\CliContext;
1010

11+
if (getenv('USING_PIE_BEHAT_DOCKERFILE') !== '1') {
12+
echo <<<'HELP'
13+
⚠️ ⚠️ ⚠️ STOP! ⚠️ ⚠️ ⚠️
14+
15+
This test suite tinkers with your system, and has lots of expectations about
16+
the system it is running on, so we HIGHLY recommend you run it using the
17+
provided Dockerfile:
18+
19+
docker buildx build --file .github/actions/pie-behaviour-tests/Dockerfile -t pie-behat-test .
20+
docker run --volume .:/github/workspace -ti pie-behat-test
21+
22+
If you are really sure, and accept that the test suite installs/uninstalls
23+
stuff from your system, and might break your stuff, set
24+
USING_PIE_BEHAT_DOCKERFILE=1 in your environment.
25+
26+
HELP;
27+
exit(1);
28+
}
29+
1130
$profile = (new Profile('default'))
1231
->withSuite(
1332
(new Suite('default'))

0 commit comments

Comments
 (0)