|
| 1 | +name: Build and Test |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - master |
| 9 | +jobs: |
| 10 | + # XXX: macOS |
| 11 | + ubuntu: |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + version: ['7.3', '7.4', '8.0'] |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v2 |
| 19 | + - name: Cache DB2 library |
| 20 | + id: cache-clidriver |
| 21 | + uses: actions/cache@v2 |
| 22 | + with: |
| 23 | + path: clidriver |
| 24 | + key: ${{ runner.os }}-clidriver |
| 25 | + - name: Install DB2 library |
| 26 | + if: steps.cache-clidriver.outputs.cache-hit != 'true' |
| 27 | + run: | |
| 28 | + wget https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz |
| 29 | + tar xvzf linuxx64_odbc_cli.tar.gz |
| 30 | + - name: Setup PHP |
| 31 | + uses: shivammathur/setup-php@v2 |
| 32 | + with: |
| 33 | + php-version: ${{matrix.version}} |
| 34 | + - name: phpize |
| 35 | + run: phpize |
| 36 | + - name: configure |
| 37 | + run: ./configure --with-IBM_DB2=$PWD/clidriver |
| 38 | + - name: make |
| 39 | + run: make V=1 |
| 40 | + - name: Cache container |
| 41 | + id: cache-docker |
| 42 | + uses: actions/cache@v2 |
| 43 | + with: |
| 44 | + path: image-cache |
| 45 | + key: ${{ runner.os }}-image-cache |
| 46 | + - name: Download container |
| 47 | + if: steps.cache-docker.outputs.cache-hit != 'true' |
| 48 | + run: | |
| 49 | + docker pull ibmcom/db2 |
| 50 | + mkdir image-cache |
| 51 | + docker save -o image-cache/db2.tar ibmcom/db2 |
| 52 | + - name: Restore container from cache |
| 53 | + if: steps.cache-docker.outputs.cache-hit == 'true' |
| 54 | + run: docker load -i image-cache/db2.tar |
| 55 | + - name: Set up Db2 LUW in Docker |
| 56 | + # XXX: Should we be caching the Docker image? Are we creating the necessary things? |
| 57 | + # Adapted from the Travis setup with the changes used for the current |
| 58 | + # version of the Db2 container. |
| 59 | + run: | |
| 60 | + set -x |
| 61 | + cat <<EOF > db2cli.ini |
| 62 | + [SAMPLE] |
| 63 | + Hostname=localhost |
| 64 | + Protocol=TCPIP |
| 65 | + Port=60000 |
| 66 | + Database=sample |
| 67 | + EOF |
| 68 | + mkdir database |
| 69 | + docker run --name db2 --privileged=true -p 60000:50000 -e DB2INST1_PASSWORD=password -e LICENSE=accept -e DBNAME=sample -v database:/database -itd ibmcom/db2 |
| 70 | + docker ps -as |
| 71 | + while true |
| 72 | + do |
| 73 | + if (docker logs db2 | grep 'Setup has completed') |
| 74 | + then |
| 75 | + break |
| 76 | + fi |
| 77 | + sleep 20 |
| 78 | + done |
| 79 | + - name: Tests |
| 80 | + # make test is insufficient to load PDO |
| 81 | + # Most of these are either cribbed from the old Travis configuration, |
| 82 | + # or required for the tests to use the DSN. |
| 83 | + # Note that connection.inc defaults should be mostly sufficient. |
| 84 | + run: | |
| 85 | + export TEST_PHP_ARGS="-n -d extension=modules/ibm_db2.so" |
| 86 | + export IBM_DB2_TEST_SKIP_CONNECT_FAILURE=0 |
| 87 | + export DB2CLIINIPATH=$PWD |
| 88 | + export REPORT_EXIT_STATUS=1 |
| 89 | + php run-tests.php -P --show-diff tests |
| 90 | + windows: |
| 91 | + defaults: |
| 92 | + run: |
| 93 | + shell: cmd |
| 94 | + strategy: |
| 95 | + matrix: |
| 96 | + version: ["7.4", "8.0", "8.1"] |
| 97 | + arch: [x64] |
| 98 | + ts: [ts] |
| 99 | + runs-on: windows-latest |
| 100 | + steps: |
| 101 | + - name: Checkout |
| 102 | + uses: actions/checkout@v2 |
| 103 | + - name: Cache DB2 library |
| 104 | + id: cache-clidriver |
| 105 | + uses: actions/cache@v2 |
| 106 | + with: |
| 107 | + path: clidriver |
| 108 | + key: ${{ runner.os }}-clidriver |
| 109 | + - name: Install DB2 library |
| 110 | + if: steps.cache-clidriver.outputs.cache-hit != 'true' |
| 111 | + shell: pwsh |
| 112 | + run: | |
| 113 | + Invoke-WebRequest -Uri 'https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/ntx64_odbc_cli.zip' -OutFile 'ntx64_odbc_cli.zip' |
| 114 | + Expand-Archive 'ntx64_odbc_cli.zip' -DestinationPath '.\' |
| 115 | + - name: Setup PHP |
| 116 | + id: setup-php |
| 117 | + |
| 118 | + with: |
| 119 | + version: ${{matrix.version}} |
| 120 | + arch: ${{matrix.arch}} |
| 121 | + ts: ${{matrix.ts}} |
| 122 | + - name: Enable Developer Command Prompt |
| 123 | + uses: ilammy/msvc-dev-cmd@v1 |
| 124 | + with: |
| 125 | + arch: ${{matrix.arch}} |
| 126 | + toolset: ${{steps.setup-php.outputs.toolset}} |
| 127 | + - name: phpize |
| 128 | + run: phpize |
| 129 | + - name: configure |
| 130 | + run: configure --with-ibm_db2=%cd%\clidriver --with-prefix=${{steps.setup-php.outputs.prefix}} |
| 131 | + - name: make |
| 132 | + run: nmake |
| 133 | + # XXX: Can we run Docker containers in a Windows runner? That'll be required for tests |
| 134 | + #- name: test |
| 135 | + # run: nmake test TESTS=tests |
0 commit comments