Merge pull request #124 from theodorejb/switch-case #191
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: [push, pull_request] | |
jobs: | |
test: | |
runs-on: ${{ matrix.operating-system }} | |
env: | |
HTTPSERVER: localhost | |
HTTPURI: /tests/index.php?demo=server/server.php | |
HTTPSSERVER: localhost | |
HTTPSURI: /tests/index.php?demo=server/server.php | |
PROXYSERVER: localhost:8080 | |
# @todo check: is this necessary as well on GHA runners? | |
# was: "Travis currently compiles PHP with an oldish cURL/GnuTLS combination; | |
# to make the tests pass when Apache has a bogus SSL cert whe need the full set of options below." | |
HTTPSVERIFYHOST: 0 | |
HTTPSIGNOREPEER: 1 | |
SSLVERSION: 0 | |
DEBUG: 0 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# @see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners | |
# @todo run some tests on 'windows-latest' (needs test env setup scripts for windows to be developed) | |
- php: '8.4' | |
operating-system: ubuntu-24.04 | |
- php: '8.3' | |
operating-system: ubuntu-22.04 | |
- php: '8.2' | |
operating-system: ubuntu-22.04 | |
- php: '8.1' | |
operating-system: ubuntu-22.04 | |
- php: '8.0' | |
operating-system: ubuntu-22.04 | |
- php: '7.4' | |
operating-system: ubuntu-22.04 | |
# nb: the version of phpunit we use does not support code coverage generation on php 8 | |
code-coverage: true | |
- php: '7.3' | |
operating-system: ubuntu-22.04 | |
- php: '7.2' | |
operating-system: ubuntu-20.04 | |
- php: '7.1' | |
operating-system: ubuntu-20.04 | |
- php: '7.0' | |
operating-system: ubuntu-20.04 | |
- php: '5.6' | |
operating-system: ubuntu-20.04 | |
- php: '5.5' | |
operating-system: ubuntu-22.04 | |
- php: '5.4' | |
operating-system: ubuntu-20.04 | |
steps: | |
- name: checkout code | |
uses: actions/checkout@v3 | |
# Although this action is quite nice, we prefer to use the same script to set up php that we use for the | |
# docker image used for local testing. This allows us to make sure that script is always in good shape | |
#- name: set up php | |
# uses: shivammathur/setup-php@v2 | |
# with: | |
# php-version: ${{ matrix.php }} | |
# extensions: curl, dom, mbstring, xsl | |
# ini-values: 'cgi.fix_pathinfo=1, always_populate_raw_post_data=-1' | |
# #tools: ${{ matrix.phpunit-version }} | |
# coverage: ${{ matrix.code-coverage}} | |
- name: set up env | |
# @todo add env setup scripts for windows | |
run: | | |
chmod 755 ./tests/ci/setup/*.sh | |
sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/install_packages.sh | |
sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_perl.sh | |
sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_apache.sh | |
sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_privoxy.sh | |
sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_php.sh ${{ matrix.php }} | |
sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_composer.sh | |
# fix fs perms for recent Apache versions configuration (ie. starting from Jammy) | |
f="$(pwd)"; while [[ $f != / ]]; do sudo chmod +rx "$f"; f=$(dirname "$f"); done; | |
find . -type d -exec chmod +rx {} \; | |
find . -type f -exec chmod +r {} \; | |
# Avoid downloading composer deps on every workflow run. Is this useful for us? Caching the installation of | |
# php/apache/privoxy/perl would be more useful... | |
#- | |
# uses: actions/cache@v2 | |
# with: | |
# path: /tmp/composer-cache | |
# key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} | |
- name: install dependencies | |
run: 'composer install --no-progress' | |
- name: run tests and upload coverage info if needed | |
run: | | |
if [ -z "${{ matrix.code-coverage }}" ]; then | |
./vendor/bin/phpunit -v tests | |
else | |
./tests/ci/setup/setup_code_coverage.sh enable | |
./vendor/bin/phpunit -v --coverage-clover=coverage.clover tests | |
if [ -f coverage.clover ]; then | |
wget https://uploader.codecov.io/latest/linux/codecov && \ | |
chmod +x codecov && \ | |
./codecov -f coverage.clover | |
else | |
echo "WARNING: code coverage not generated. Is xdebug disabled?" | |
fi | |
fi | |
# @todo would it be useful to run a 2nd test with composer --prefer-lowest? After all the only dependencies we have are testing tools | |
- name: test python demo files | |
run: 'python3 demo/client/python/test.py' | |
- name: test perl demo files | |
run: 'perl demo/client/perl/test.pl' | |
# disabled for the moment (2023/02), as we get only noise from the scans... | |
#- name: Qodana scan | |
# uses: JetBrains/qodana-action@main | |
# env: | |
# QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} | |
- name: failure troubleshooting | |
if: ${{ failure() }} | |
run: | | |
#env | |
#php -i | |
#ps auxwww | |
#dpkg --list | grep php | |
#ps auxwww | grep fpm | |
#pwd | |
#sudo env | |
#systemctl list-units --all --type=service --no-pager | grep running | |
#systemctl status apache2.service | |
#ls -la /etc/apache2/mods-enabled | |
#ls -la /etc/apache2/conf-enabled | |
#ls -la /etc/apache2/mods-available | |
#ls -la /etc/apache2/conf-available | |
#ls -la /etc/apache2/sites-available/ | |
#sudo cat /etc/apache2/envvars | |
#sudo cat /etc/apache2/sites-available/000-default.conf | |
#ls -ltr /var/log | |
#ls -ltr /var/log/apache2 | |
if [ -d /var/log/privoxy ]; then sudo cat /var/log/privoxy/*; fi | |
if [ -d /var/log/apache2 ]; then sudo cat /var/log/apache2/error.log; fi | |
if [ -d /var/log/apache2 ]; then sudo cat /var/log/apache2/other_vhosts_access.log; fi | |
sudo cat /var/log/php*.log | |
# Whenever a change is pushed to this library, we run as well the tests of all known packages depending on it, | |
# so that we can catch any (involuntary) breakage. | |
# NB: if any are detected, do not forget to mark the current versions of dependents as incompatible in composer.json | |
test-dependencies: | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- dependency: phpxmlrpc/extras | |
#- dependency: phpxmlrpc/jsonrpc | |
- dependency: phpxmlrpc/polyfill-xmlrpc | |
steps: | |
# NB: unusually, but intentionally, we do _not_ download the code of this very own repo into the workspace! | |
- name: download dependency, build its test vm and run its tests against the current commit | |
run: | | |
# We test against the latest available release of dependents. | |
# Arguably, we could (also?) test against their master branch, in case some fixes were pushed there | |
# and not released yet, which make them work ok with us, but those tend to be tested when pushing | |
# to them (and we do not push to dependents changes which make them use an unreleased version | |
# of us anyway) | |
composer create-project --prefer-source --no-install --remove-vcs --stability=alpha "${{ matrix.dependency }}" . | |
# avoid rewriting 'source' line - we should figure out how to use negative lookahed... | |
sed -i -E -e 's|"phpxmlrpc/phpxmlrpc" *: *"source"|"phpxmlrpc/phpxmlrpc_": "source"|g' composer.json | |
sed -i -E -e 's|"phpxmlrpc/phpxmlrpc" *: *".+|"phpxmlrpc/phpxmlrpc": "dev-master#${{ github.ref_name }} as 4.999"|g' composer.json | |
sed -i -E -e 's|"phpxmlrpc/phpxmlrpc_" *: *"source"|"phpxmlrpc/phpxmlrpc": "source"|g' composer.json | |
# @todo either set COMPOSER_ROOT_VERSION env var, or inject `version` into composer.json, to allow | |
# composer to know that the top-level project is on `dev-master` | |
chmod 755 ./tests/ci/vm.sh | |
./tests/ci/vm.sh build | |
./tests/ci/vm.sh start | |
# this should not be necessary any more, as `start` waits for the app to be set up | |
#sleep 30 | |
./tests/ci/vm.sh runtests | |
# NB: we do not stop the container, nor clean up the current folder, as we rely on each matrix case | |
# being executed in its own runner instance | |
- name: failure troubleshooting | |
if: ${{ failure() }} | |
run: | | |
docker --version | |
docker ps | |
docker ps -a | |
./tests/ci/vm.sh top | |
#./tests/ci/vm.sh exec env | |
./tests/ci/vm.sh logs |