Skip to content
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
62 changes: 62 additions & 0 deletions .github/pie-behaviour-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# An approximately reproducible, but primarily isolated, environment for
# running the acceptance tests:
#
# GITHUB_TOKEN=$(composer config --global --auth github-oauth.github.com) docker buildx build --file .github/pie-behaviour-tests/Dockerfile --secret id=GITHUB_TOKEN,env=GITHUB_TOKEN -t pie-behat-test .
# docker run --volume .:/github/workspace -ti pie-behat-test
FROM alpine/git:v2.49.1 AS clone_ext_repo

RUN cd / && git clone https://github.com/asgrim/example-pie-extension.git

FROM boxproject/box:4.6.10 AS build_pie_phar

RUN apk add git
COPY . /app
RUN cd /app && touch creating_this_means_phar_will_never_be_verified && /box.phar compile

FROM ubuntu:24.04 AS default

# Add the `unzip` package which PIE uses to extract .zip files
RUN export DEBIAN_FRONTEND="noninteractive"; \
set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
unzip curl jq wget g++ gcc make autoconf libtool bison re2c pkg-config \
ca-certificates libxml2-dev libssl-dev; \
update-ca-certificates ; \
rm -rf /var/lib/apt/lists/*

# Compile PHP
ARG PHP_VERSION=8.4
RUN mkdir -p /usr/local/src/php; \
cd /usr/local/src/php; \
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'`; \
wget -O php.tgz "https://www.php.net/distributions/$FULL_LATEST_VERSION" ; \
tar zxf php.tgz ; \
rm php.tgz ; \
ls -l ; \
cd * ; \
ls -l ; \
./buildconf --force ; \
./configure --without-sqlite3 --disable-pdo --disable-dom --disable-xml --disable-xmlreader --disable-xmlwriter --disable-json --with-openssl ; \
make -j$(nproc) ; \
make install

RUN touch /usr/local/lib/php.ini

COPY --from=ghcr.io/php/pie:bin /pie /usr/local/bin/pie
RUN pie install xdebug/xdebug

COPY --from=clone_ext_repo /example-pie-extension /example-pie-extension

WORKDIR /github/workspace

COPY --from=composer /usr/bin/composer /usr/bin/composer
RUN --mount=type=secret,id=GITHUB_TOKEN,env=GITHUB_TOKEN \
composer config --global --auth github-oauth.github.com $GITHUB_TOKEN

COPY --from=build_pie_phar /app/pie.phar /usr/local/bin/pie
COPY --from=build_pie_phar /app/pie.phar /usr/local/bin/pie.original

ENV USING_PIE_BEHAT_DOCKERFILE=1
ENTRYPOINT ["php", "vendor/bin/behat"]
CMD ["--no-snippets"]
27 changes: 13 additions & 14 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,29 +138,28 @@ jobs:
matrix:
operating-system:
- ubuntu-latest
- windows-latest
php-versions:
- '8.1'
- '8.2'
- '8.3'
- '8.4'
- '8.5'
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
- uses: actions/checkout@v5
with:
php-version: ${{ matrix.php-versions }}
extensions: intl, sodium, zip
fetch-depth: 0
# Fixes `git describe` picking the wrong tag - see https://github.com/php/pie/issues/307
- run: git fetch --tags --force
# Ensure some kind of previous tag exists, otherwise box fails
- run: git describe --tags HEAD || git tag 0.0.0
- uses: ramsey/composer-install@v3
- name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: docker buildx build --file .github/pie-behaviour-tests/Dockerfile --secret id=GITHUB_TOKEN,env=GITHUB_TOKEN --build-arg PHP_VERSION=${{ matrix.php-versions }} -t pie-behat-test .
- name: Run Behat
run: docker run --volume .:/github/workspace pie-behat-test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v5
- uses: ramsey/composer-install@v3
- name: Run Behat on Windows
if: matrix.operating-system == 'windows-latest'
run: vendor/bin/behat --tags="~@non-windows"
- name: Run Behat on non-Windows
if: matrix.operating-system != 'windows-latest'
run: sudo vendor/bin/behat

coding-standards:
runs-on: ubuntu-latest
Expand Down
19 changes: 19 additions & 0 deletions behat.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@
use Behat\Config\Suite;
use Php\PieBehaviourTest\CliContext;

if (getenv('USING_PIE_BEHAT_DOCKERFILE') !== '1') {
echo <<<'HELP'
⚠️ ⚠️ ⚠️ STOP! ⚠️ ⚠️ ⚠️

This test suite tinkers with your system, and has lots of expectations about
the system it is running on, so we HIGHLY recommend you run it using the
provided Dockerfile:

docker buildx build --file .github/actions/pie-behaviour-tests/Dockerfile -t pie-behat-test .
docker run --volume .:/github/workspace -ti pie-behat-test

If you are really sure, and accept that the test suite installs/uninstalls
stuff from your system, and might break your stuff, set
USING_PIE_BEHAT_DOCKERFILE=1 in your environment.

HELP;
exit(1);
}

$profile = (new Profile('default'))
->withSuite(
(new Suite('default'))
Expand Down
12 changes: 12 additions & 0 deletions features/bundled-php-extensions.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature: Bundled PHP extensions can be installed

# pie install php/sodium
Example: An extension normally bundled with PHP can be installed
Given I have libsodium on my system
When I install the sodium extension with PIE
Then the extension should have been installed and enabled

Example: A bundled extension installed with PIE can be uninstalled
Given I have the sodium extension installed with PIE
When I run a command to uninstall an extension
Then the extension should not be installed anymore
15 changes: 13 additions & 2 deletions features/install-extensions.feature
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
Feature: Extensions can be installed with PIE

# pie download <ext>
Example: The latest version of an extension can be downloaded
When I run a command to download the latest version of an extension
Then the latest version should have been downloaded

# pie download <ext>:<version>
Scenario Outline: A version matching the requested constraint can be downloaded
When I run a command to download version "<constraint>" of an extension
Then version "<version>" should have been downloaded
Expand All @@ -13,11 +15,13 @@ Feature: Extensions can be installed with PIE
| 2.0.5 | 2.0.5 |
| ^2.0 | 2.0.5 |

# pie download <ext>:dev-main
@non-windows
Example: An in-development version can be downloaded on non-Windows systems
When I run a command to download version "dev-main" of an extension
Then version "dev-main" should have been downloaded

# pie build <ext>
Example: An extension can be built
When I run a command to build an extension
Then the extension should have been built
Expand All @@ -27,10 +31,17 @@ Feature: Extensions can be installed with PIE
When I run a command to build an extension
Then the extension should have been built

# pie build <ext> --with-some-options=foo
Example: An extension can be built with configure options
When I run a command to build an extension with configure options
Then the extension should have been built with options

Example: An extension can be installed
When I run a command to install an extension
# pie install <ext> --skip-enable-extension
Example: An extension can be installed without enabling
When I run a command to install an extension without enabling it
Then the extension should have been installed

# pie install <ext>
Example: An extension can be installed and enabled
When I run a command to install an extension
Then the extension should have been installed and enabled
7 changes: 7 additions & 0 deletions features/install-in-php-project.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: Extensions for a PHP project can be installed with PIE

# pie install
Example: PIE running in a PHP project suggests missing dependencies
Given I am in a PHP project that has missing extensions
When I run a command to install the extensions
Then I should see all the extensions are now installed
7 changes: 7 additions & 0 deletions features/install-in-pie-project.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: A PIE extension can be installed with PIE

# pie install
Example: Running PIE in a PIE project will install that PIE extension
Given I am in a PIE project
When I run a command to install the extension
Then the extension should have been installed and enabled
2 changes: 2 additions & 0 deletions features/manage-repositories.feature
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Feature: Package repositories can be managed with PIE

# pie repository:add ...
Example: A package repository can be added
Given no repositories have previously been added
When I add a package repository
Then I should see the package repository can be used by PIE

# pie repository:remove ...
Example: A package repository can be removed
Given I have previously added a package repository
When I remove the package repository
Expand Down
13 changes: 13 additions & 0 deletions features/platform-dependencies.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Feature: Platform dependencies are checked when installing

# pie info <ext>
Example: Extension platform dependencies are listed as dependencies
Given I do not have libsodium on my system
When I display information about the sodium extension with PIE
Then the information should show that libsodium is a missing dependency

# pie install <ext>
Example: Extension platform dependencies will warn the extension is missing a dependency
Given I do not have libsodium on my system
When I install the sodium extension with PIE
Then the extension fails to install due to the missing library
27 changes: 27 additions & 0 deletions features/self-update.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Feature: PIE can update itself and verify it is authentic

# pie self-update
Example: PIE can update itself
Given I have an old version of PIE
When I update PIE to the latest version
Then I should see I have been updated to the latest version

# pie self-verify
Example: PIE can verify its authenticity with gh
Given I have a pie.phar built on PHP's GitHub
And I have the gh cli command
When I verify my PIE installation
Then I should see it is verified

# pie self-verify
Example: PIE can verify its authenticity with openssl
Given I have a pie.phar built on PHP's GitHub
And I do not have the gh cli command
When I verify my PIE installation
Then I should see it is verified

# pie self-verify
Example: PIE will alert when its authenticity is not verified
Given I have a pie.phar built on a nasty hacker's machine
When I verify my PIE installation
Then I should see it has failed verification
3 changes: 2 additions & 1 deletion features/uninstall-extensions.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Feature: Extensions can be uninstalled with PIE

# pie uninstall <ext>
Example: An extension can be uninstalled
Given an extension was previously installed
Given an extension was previously installed and enabled
When I run a command to uninstall an extension
Then the extension should not be installed anymore
1 change: 1 addition & 0 deletions test/assets/example-php-project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor
9 changes: 9 additions & 0 deletions test/assets/example-php-project/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "php-pie-test-project/php-pie-test-project",
"description": "Example PHP project for test cases",
"type": "project",
"require": {
"php": "^8.0",
"ext-example_pie_extension": "^2.0"
}
}
21 changes: 21 additions & 0 deletions test/assets/example-php-project/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading