d4d2fc92e5c9aca9fdbb84ac50777f1681f40b7c
[plcapi.git] / .github / workflows / ci.yml
1 name: CI
2
3 on: [push]
4
5 jobs:
6     test:
7         runs-on: ${{ matrix.operating-system }}
8         env:
9             HTTPSERVER: localhost
10             URI: /demo/server/server.php
11             HTTPSSERVER: localhost
12             HTTPSURI: /demo/server/server.php
13             PROXYSERVER: localhost:8080
14             # @todo check: is this necessary as well on GHA runners?
15             # was: Travis currently compiles PHP with an oldish cURL/GnuTLS combination;
16             # to make the tests pass when Apache has a bogus SSL cert whe need the full set of options below.
17             HTTPSVERIFYHOST: 0
18             HTTPSIGNOREPEER: 1
19             SSLVERSION: 0
20             DEBUG: 0
21         strategy:
22             fail-fast: false
23             matrix:
24                 # @see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
25                 # @todo fix: atm our tests fail when using ubuntu 20 (focal) and php 5.6 - 7.1, when using
26                 #       an ssl stream context for connecting to localhost via https
27                 operating-system: ['ubuntu-18.04'] # @todo add 'windows-latest'
28                 # @todo use an older version of phpunit to enable testing on php 5.3 - 5.5 . Also: we will most likely
29                 #       have to resort to using shivammathur/setup-php@v2 instead of sury's ppa to get php installed
30                 php: ['8.1', '8.0', '7.4', '7.3', '7.2', '7.1', '7.0', '5.6']
31         steps:
32             -
33                 uses: actions/checkout@v2
34             # Although this action is useful, we prefer to use the same script to set up php that we use for the
35             # docker image used for local testing. This allows us to make sure that script is always in good shape
36             #-
37             #    uses: shivammathur/setup-php@v2
38             #    with:
39             #        php-version: ${{ matrix.php }}
40             #        extensions: curl, dom, mbstring, xsl
41             #        ini-values: 'cgi.fix_pathinfo=1, always_populate_raw_post_data=-1'
42             #        #tools: phpunit/phpunit:a_version_compatible_with_php_5.3-5.5
43             #        # NB: this disables xdebug completely
44             #        coverage: none
45             -
46                 # @todo add env setup scripts for windows
47                 run: |
48                     chmod 755 ./tests/ci/setup/*.sh
49                     sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_perl.sh
50                     sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_apache.sh
51                     sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_privoxy.sh
52                     sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_php.sh ${{ matrix.php }}
53                     sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_composer.sh
54             # Avoid downloading composer deps on every workflow. Is this useful/working for us?
55             #-
56             #    uses: actions/cache@v2
57             #    with:
58             #        path: /tmp/composer-cache
59             #        key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
60             -
61                 run: 'composer install'
62             -
63                 if: ${{ matrix.php == '7.4' }}
64                 run: |
65                     ./tests/ci/setup/setup_code_coverage.sh enable
66                     ./vendor/bin/phpunit -v --coverage-clover=coverage.clover tests
67                     wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover
68             -
69                 if: ${{ matrix.php != '7.4' }}
70                 run: './vendor/bin/phpunit -v tests'
71             -
72                 run: 'python3 demo/client/python/test.py'
73             -
74                 run: 'perl demo/client/perl/test.pl'
75             -
76                 if: ${{ failure() }}
77                 run: |
78                     #env
79                     #php -i
80                     #ps auxwww
81                     #dpkg --list | grep php
82                     #ps auxwww | grep fpm
83                     #pwd
84                     #sudo env
85                     #systemctl status apache2.service
86                     #ls -la /etc/apache2/mods-enabled
87                     #ls -la /etc/apache2/conf-enabled
88                     #ls -la /etc/apache2/mods-available
89                     #ls -la /etc/apache2/conf-available
90                     #ls -la /etc/apache2/sites-available/
91                     #sudo cat /etc/apache2/envvars
92                     #sudo cat /etc/apache2/sites-available/000-default.conf
93                     #ls -ltr /var/log
94                     #ls -ltr /var/log/apache2
95                     sudo cat /var/log/privoxy/*
96                     sudo cat /var/log/apache2/error.log
97                     sudo cat /var/log/apache2/other_vhosts_access.log
98                     sudo cat /var/log/php*.log