|
| 1 | +# This workflow runs tests on all databases supported by CI4. |
1 | 2 | name: PHPUnit
|
2 | 3 |
|
3 | 4 | on:
|
|
17 | 18 | - 'composer.*'
|
18 | 19 | - 'phpunit*'
|
19 | 20 | - '.github/workflows/phpunit.yml'
|
| 21 | + workflow_call: |
| 22 | + |
| 23 | +concurrency: |
| 24 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 25 | + cancel-in-progress: true |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: read |
20 | 29 |
|
21 | 30 | jobs:
|
22 |
| - phpunit: |
23 |
| - uses: codeigniter4/.github/.github/workflows/phpunit.yml@main |
| 31 | + main: |
| 32 | + name: PHP ${{ matrix.php-versions }} - ${{ matrix.db-platforms }} - ${{ matrix.dependencies }} |
| 33 | + runs-on: ubuntu-latest |
| 34 | + if: "!contains(github.event.head_commit.message, '[ci skip]')" |
| 35 | + strategy: |
| 36 | + matrix: |
| 37 | + php-versions: ['7.4', '8.0', '8.1', '8.2'] |
| 38 | + db-platforms: ['MySQLi', 'SQLite3'] |
| 39 | + mysql-versions: ['5.7'] |
| 40 | + dependencies: ['highest'] |
| 41 | + include: |
| 42 | + # MySQL 8.0 |
| 43 | + - php-versions: '7.4' |
| 44 | + db-platforms: MySQLi |
| 45 | + mysql-versions: '8.0' |
| 46 | + dependencies: 'highest' |
| 47 | + # Postgre |
| 48 | + - php-versions: '7.4' |
| 49 | + db-platforms: Postgre |
| 50 | + mysql-versions: '5.7' |
| 51 | + dependencies: 'highest' |
| 52 | + # SQLSRV |
| 53 | + - php-versions: '7.4' |
| 54 | + db-platforms: SQLSRV |
| 55 | + mysql-versions: '5.7' |
| 56 | + dependencies: 'highest' |
| 57 | + # OCI8 |
| 58 | + - php-versions: '7.4' |
| 59 | + db-platforms: OCI8 |
| 60 | + mysql-versions: '5.7' |
| 61 | + dependencies: 'highest' |
| 62 | + |
| 63 | + services: |
| 64 | + mysql: |
| 65 | + image: mysql:${{ matrix.mysql-versions }} |
| 66 | + env: |
| 67 | + MYSQL_ALLOW_EMPTY_PASSWORD: yes |
| 68 | + MYSQL_DATABASE: test |
| 69 | + ports: |
| 70 | + - 3306:3306 |
| 71 | + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 72 | + |
| 73 | + postgres: |
| 74 | + image: postgres |
| 75 | + env: |
| 76 | + POSTGRES_USER: postgres |
| 77 | + POSTGRES_PASSWORD: postgres |
| 78 | + POSTGRES_DB: test |
| 79 | + ports: |
| 80 | + - 5432:5432 |
| 81 | + options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3 |
| 82 | + |
| 83 | + mssql: |
| 84 | + image: mcr.microsoft.com/mssql/server:2019-CU10-ubuntu-20.04 |
| 85 | + env: |
| 86 | + SA_PASSWORD: 1Secure*Password1 |
| 87 | + ACCEPT_EULA: Y |
| 88 | + MSSQL_PID: Developer |
| 89 | + ports: |
| 90 | + - 1433:1433 |
| 91 | + options: --health-cmd="/opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U sa -P 1Secure*Password1 -Q 'SELECT @@VERSION'" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 92 | + |
| 93 | + oracle: |
| 94 | + image: quillbuilduser/oracle-18-xe |
| 95 | + env: |
| 96 | + ORACLE_ALLOW_REMOTE: true |
| 97 | + ports: |
| 98 | + - 1521:1521 |
| 99 | + options: --health-cmd="/opt/oracle/product/18c/dbhomeXE/bin/sqlplus -s sys/Oracle18@oracledbxe/XE as sysdba <<< 'SELECT 1 FROM DUAL'" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 100 | + |
| 101 | + steps: |
| 102 | + - name: Create database for MSSQL Server |
| 103 | + if: matrix.db-platforms == 'SQLSRV' |
| 104 | + run: sqlcmd -S 127.0.0.1 -U sa -P 1Secure*Password1 -Q "CREATE DATABASE test" |
| 105 | + |
| 106 | + - name: Install Oracle InstantClient |
| 107 | + if: matrix.db-platforms == 'OCI8' |
| 108 | + run: | |
| 109 | + sudo apt-get install wget libaio1 alien |
| 110 | + sudo wget https://download.oracle.com/otn_software/linux/instantclient/185000/oracle-instantclient18.5-basic-18.5.0.0.0-3.x86_64.rpm |
| 111 | + sudo wget https://download.oracle.com/otn_software/linux/instantclient/185000/oracle-instantclient18.5-devel-18.5.0.0.0-3.x86_64.rpm |
| 112 | + sudo wget https://download.oracle.com/otn_software/linux/instantclient/185000/oracle-instantclient18.5-sqlplus-18.5.0.0.0-3.x86_64.rpm |
| 113 | + sudo alien oracle-instantclient18.5-basic-18.5.0.0.0-3.x86_64.rpm |
| 114 | + sudo alien oracle-instantclient18.5-devel-18.5.0.0.0-3.x86_64.rpm |
| 115 | + sudo alien oracle-instantclient18.5-sqlplus-18.5.0.0.0-3.x86_64.rpm |
| 116 | + sudo dpkg -i oracle-instantclient18.5-basic_18.5.0.0.0-4_amd64.deb oracle-instantclient18.5-devel_18.5.0.0.0-4_amd64.deb oracle-instantclient18.5-sqlplus_18.5.0.0.0-4_amd64.deb |
| 117 | + echo "LD_LIBRARY_PATH=/lib/oracle/18.5/client64/lib/" >> $GITHUB_ENV |
| 118 | + echo "NLS_LANG=AMERICAN_AMERICA.UTF8" >> $GITHUB_ENV |
| 119 | + echo "C_INCLUDE_PATH=/usr/include/oracle/18.5/client64" >> $GITHUB_ENV |
| 120 | + echo 'NLS_DATE_FORMAT=YYYY-MM-DD HH24:MI:SS' >> $GITHUB_ENV |
| 121 | + echo 'NLS_TIMESTAMP_FORMAT=YYYY-MM-DD HH24:MI:SS' >> $GITHUB_ENV |
| 122 | + echo 'NLS_TIMESTAMP_TZ_FORMAT=YYYY-MM-DD HH24:MI:SS' >> $GITHUB_ENV |
| 123 | +
|
| 124 | + - name: Create database for Oracle Database |
| 125 | + if: matrix.db-platforms == 'OCI8' |
| 126 | + run: echo -e "ALTER SESSION SET CONTAINER = XEPDB1;\nCREATE BIGFILE TABLESPACE \"TEST\" DATAFILE '/opt/oracle/product/18c/dbhomeXE/dbs/TEST' SIZE 10M AUTOEXTEND ON MAXSIZE UNLIMITED SEGMENT SPACE MANAGEMENT AUTO EXTENT MANAGEMENT LOCAL AUTOALLOCATE;\nCREATE USER \"ORACLE\" IDENTIFIED BY \"ORACLE\" DEFAULT TABLESPACE \"TEST\" TEMPORARY TABLESPACE TEMP QUOTA UNLIMITED ON \"TEST\";\nGRANT CONNECT,RESOURCE TO \"ORACLE\";\nexit;" | /lib/oracle/18.5/client64/bin/sqlplus -s sys/Oracle18@localhost:1521/XE as sysdba |
| 127 | + |
| 128 | + - name: Checkout |
| 129 | + uses: actions/checkout@v4 |
| 130 | + |
| 131 | + - name: Set up PHP |
| 132 | + uses: shivammathur/setup-php@v2 |
| 133 | + with: |
| 134 | + php-version: ${{ matrix.php-versions }} |
| 135 | + tools: composer, phive, phpunit |
| 136 | + extensions: intl, json, mbstring, gd, xdebug, xml, sqlite3, sqlsrv, oci8, pgsql |
| 137 | + coverage: xdebug |
| 138 | + env: |
| 139 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 140 | + |
| 141 | + - name: Get composer cache directory |
| 142 | + run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_ENV |
| 143 | + |
| 144 | + - name: Cache composer dependencies |
| 145 | + uses: actions/cache@v3 |
| 146 | + with: |
| 147 | + path: ${{ env.COMPOSER_CACHE_FILES_DIR }} |
| 148 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} |
| 149 | + restore-keys: ${{ runner.os }}-composer- |
| 150 | + |
| 151 | + - name: Install dependencies |
| 152 | + run: | |
| 153 | + if [ -f composer.lock ]; then |
| 154 | + composer install ${{ env.COMPOSER_UPDATE_FLAGS }} --no-progress --no-interaction --prefer-dist --optimize-autoloader |
| 155 | + else |
| 156 | + composer update ${{ env.COMPOSER_UPDATE_FLAGS }} --no-progress --no-interaction --prefer-dist --optimize-autoloader |
| 157 | + fi |
| 158 | + env: |
| 159 | + COMPOSER_UPDATE_FLAGS: ${{ matrix.dependencies == 'lowest' && '--prefer-lowest' || '' }} |
| 160 | + |
| 161 | + - name: Test with PHPUnit |
| 162 | + run: vendor/bin/phpunit --verbose --coverage-text --testsuite main |
| 163 | + env: |
| 164 | + DB: ${{ matrix.db-platforms }} |
| 165 | + TERM: xterm-256color |
| 166 | + TACHYCARDIA_MONITOR_GA: enabled |
| 167 | + |
| 168 | + - if: matrix.php-versions == '8.1' |
| 169 | + name: Run Coveralls |
| 170 | + continue-on-error: true |
| 171 | + run: | |
| 172 | + sudo phive --no-progress install --global --trust-gpg-keys E82B2FB314E9906E php-coveralls |
| 173 | + php-coveralls --verbose --coverage_clover=build/phpunit/clover.xml --json_path build/phpunit/coveralls-upload.json |
| 174 | + env: |
| 175 | + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 176 | + COVERALLS_PARALLEL: true |
| 177 | + COVERALLS_FLAG_NAME: PHP ${{ matrix.php-versions }} - ${{ matrix.db-platforms }} |
| 178 | + |
| 179 | + coveralls: |
| 180 | + needs: [main] |
| 181 | + name: Coveralls Finished |
| 182 | + runs-on: ubuntu-latest |
| 183 | + steps: |
| 184 | + - name: Upload Coveralls results |
| 185 | + uses: coverallsapp/github-action@master |
| 186 | + continue-on-error: true |
| 187 | + with: |
| 188 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 189 | + parallel-finished: true |
0 commit comments