Skip to content

Commit

Permalink
qa: migrate to Laminas CI workflow for GHA
Browse files Browse the repository at this point in the history
This patch adopts the Laminas CI workflow, following some prototyping (and the release) for the 1.1.0 release of the CI container to allow for pre/post run scripts.

This patch provides the following:

- `.laminas-ci/pre-run.sh`:
  - exits early if not for a PHPUnit job
  - installs the CI version of the PHPUnit configuration
  - installs apache2 and the php-fpm relevant to the current PHP version
  - enables required apache2 modules
  - provides php-fpm and apache configuration for running tests against
    - found in `laminas-ci/{site.conf,proxy.conf}`
  - starts the php-fpm and apache2 services
- `.laminas-ci/post-run.sh`:
  - exits early if not for a PHPUnit job
  - if a non-zero exit status was provided, it cats the apache2 access and error logs

Signed-off-by: Matthew Weier O'Phinney <[email protected]>
  • Loading branch information
weierophinney committed Feb 18, 2021
1 parent 38b7ebd commit 079a410
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 120 deletions.
1 change: 0 additions & 1 deletion .ci/php5.6.ini

This file was deleted.

21 changes: 0 additions & 21 deletions .ci/site.conf

This file was deleted.

33 changes: 33 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Continuous Integration"

on:
pull_request:
push:
branches:
- '[0-9]+.[0-9]+.x'
- 'refs/pull/*'
tags:

jobs:
matrix:
name: Generate job matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Gather CI configuration
id: matrix
uses: laminas/laminas-ci-matrix-action@v1

qa:
name: QA Checks
needs: [matrix]
runs-on: ${{ matrix.operatingSystem }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.matrix.outputs.matrix) }}
steps:
- name: ${{ matrix.name }}
uses: laminas/laminas-continuous-integration-action@v1
with:
job: ${{ matrix.job }}
45 changes: 45 additions & 0 deletions .laminas-ci/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true">
<coverage includeUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="laminas-http Test Suite">
<directory>./test/</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>disable</group>
</exclude>
</groups>
<php>
<ini name="date.timezone" value="UTC"/>
<!-- OB_ENABLED should be enabled for some tests to check if all
functionality works as expected. Such tests include those for
Laminas\Soap and Laminas\Session, which require that headers not be sent
in order to work. -->
<env name="TESTS_LAMINAS_OB_ENABLED" value="false"/>
<!-- Laminas\Http\Client tests
To enable the dynamic Laminas\Http\Client tests, you will need to
symbolically link or copy the files in test/Client/_files to a
directory under your web server(s) document root and set this
constant to point to the URL of this directory. -->
<env name="TESTS_LAMINAS_HTTP_CLIENT_BASEURI" value="http://127.0.0.1"/>
<env name="TESTS_LAMINAS_HTTP_CLIENT_ONLINE" value="true"/>
<!-- Laminas\Http\Client\Proxy tests
HTTP proxy to be used for testing the Proxy adapter. Set to a
string of the form 'host:port'. Set to null to skip HTTP proxy
tests. -->
<env name="TESTS_LAMINAS_HTTP_CLIENT_HTTP_PROXY" value="127.0.0.1:8081"/>
<env name="TESTS_LAMINAS_HTTP_CLIENT_HTTP_PROXY_USER" value=""/>
<env name="TESTS_LAMINAS_HTTP_CLIENT_HTTP_PROXY_PASS" value=""/>

<env name="TESTS_LAMINAS_HTTP_CLIENT_NOTRESPONDINGURI" value="http://127.1.1.0:1234"/>
</php>
</phpunit>

14 changes: 14 additions & 0 deletions .laminas-ci/post-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

EXIT_STATUS=$1
JOB=$4
COMMAND=$(echo "${JOB}" | jq -r '.command')

if [[ "${EXIT_STATUS}" == "0" || ! ${COMMAND} =~ phpunit ]]; then
exit 0
fi

cat /var/log/apache2/error.log
cat /var/log/apache2/access.log
48 changes: 48 additions & 0 deletions .laminas-ci/pre-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

set -e

TEST_USER=$1
WORKSPACE=$2
JOB=$3

COMMAND=$(echo "${JOB}" | jq -r '.command')

if [[ ! ${COMMAND} =~ phpunit ]]; then
exit 0
fi

PHP_VERSION=$(echo "${JOB}" | jq -r '.php')

# Install CI version of phpunit config
cp .laminas-ci/phpunit.xml phpunit.xml

# Install dependendies
apt update -qq
apt install -y apache2 php${PHP_VERSION}-fpm

# Enable required modules
a2enmod rewrite actions proxy_fcgi setenvif alias
a2enconf php${PHP_VERSION}-fpm

# Setup and start php-fpm
echo "cgi.fix_pathinfo = 1" >> /etc/php/${PHP_VERSION}/fpm/php.ini
sed -i -e "s,www-data,${TEST_USER},g" /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf
sed -i -e "s,www-data,${TEST_USER},g" /etc/apache2/envvars
service php${PHP_VERSION}-fpm start

# configure apache virtual hosts
echo "ServerName 127.0.0.1" >> /etc/apache2/apache2.conf
cp -f .laminas-ci/site.conf /etc/apache2/sites-available/000-default.conf
sed -i -e "s?%BUILD_DIR%?${WORKSPACE}?g" /etc/apache2/sites-available/000-default.conf
sed -i -e "s?%PHP_VERSION%?${PHP_VERSION}?g" /etc/apache2/sites-available/000-default.conf

# enable TRACE
sed -i -e "s?TraceEnable Off?TraceEnable On?g" /etc/apache2/conf-available/security.conf

# configure proxy
a2enmod proxy proxy_http proxy_connect
cp -f .laminas-ci/proxy.conf /etc/apache2/sites-available/proxy.conf
a2ensite proxy
sed -i -e "s/Listen 80/Listen 80\nListen 8081/" /etc/apache2/ports.conf
service apache2 restart
3 changes: 3 additions & 0 deletions .ci/proxy.conf → .laminas-ci/proxy.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<VirtualHost *:8081>
ServerName 127.0.0.1
ServerAlias localhost

ProxyRequests On

ErrorLog ${APACHE_LOG_DIR}/error.log
Expand Down
16 changes: 16 additions & 0 deletions .laminas-ci/site.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<VirtualHost *:80>
ServerName 127.0.0.1
ServerAlias localhost
DocumentRoot %BUILD_DIR%/test/Client/_files

<Directory "%BUILD_DIR%/test/Client/_files">
Options FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>

<FilesMatch \.php$>
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
SetHandler "proxy:unix:/run/php/php%PHP_VERSION%-fpm.sock|fcgi://localhost"
</FilesMatch>
</VirtualHost>
98 changes: 0 additions & 98 deletions .travis.yml

This file was deleted.

0 comments on commit 079a410

Please sign in to comment.