aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/test_php.yml
blob: 391442d8a25e24ac1a65fd40b72735517fec9b92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: PHP Tests

on:
  workflow_call:
    inputs:
      safe-checkout:
        required: true
        description: "The SHA key for the commit we want to run over"
        type: string

permissions:
  contents: read

jobs:
  linux:
    strategy:
      fail-fast: false   # Don't cancel all jobs if one fails.
      matrix:
        include:
          - name: 8.0 Optimized
            version: "8.0.5"
            version-short: "8.0"
            command: composer test \&\& composer test_c
          - name: 8.0 Debug
            version: 8.0.5-dbg
            version-short: "8.0"
            command: composer test \&\& composer test_c
          - name: 8.0 Memory Leak
            version: 8.0.5-dbg
            version-short: "8.0"
            # Run specialized memory leak & multirequest tests.
            command: composer test_c \&\& tests/multirequest.sh \&\& tests/memory_leak_test.sh
          - name: 8.0 Valgrind
            version: 8.0.5-dbg
            version-short: "8.0"
            command: composer test_valgrind

    name: Linux ${{ matrix.name}}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout pending changes
        uses: protocolbuffers/protobuf-ci/checkout@v2
        with:
          ref: ${{ inputs.safe-checkout }}
      - name: Setup composer
        uses: protocolbuffers/protobuf-ci/composer-setup@v2
        with:
          cache-prefix: php-${{ matrix.version-short }}
          directory: php
      - name: Run tests
        uses: protocolbuffers/protobuf-ci/docker@v2
        with:
          image: us-docker.pkg.dev/protobuf-build/containers/test/linux/php:${{ matrix.version }}-66964dc8b07b6d1fc73a5cc14e59e84c1c534cea
          credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
          extra-flags: -e COMPOSER_HOME=/workspace/composer-cache
          command: ${{ matrix.command }}

  linux-32bit:
    strategy:
      fail-fast: false   # Don't cancel all jobs if one fails.
      matrix:
        version: ['8.0']
        suffix: [ '', '-zts']
        test: ['test', 'test_c']
        exclude:
          - suffix: '-zts'
            test: 'test'
        include:
          - suffix: '-zts'
            suffix_name: ' Thread Safe'
          - test: 'test_c'
            test_name: ' Extension'

    name: Linux 32-bit ${{ matrix.version}}${{ matrix.suffix_name }}${{ matrix.test_name }}
    runs-on: ubuntu-latest
    env:
      image: us-docker.pkg.dev/protobuf-build/containers/test/linux/32bit@sha256:8275360dc5d676f3470872d79087901c0e4153453976bea908a92c82e8d209ea
    steps:
      - name: Checkout pending changes
        uses: protocolbuffers/protobuf-ci/checkout@v2
        with:
          ref: ${{ inputs.safe-checkout }}

      - name: Cross compile protoc for i386
        id: cross-compile
        uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v2
        with:
          image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:6.3.0-91a0ac83e968068672bc6001a4d474cfd9a50f1d
          credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
          architecture: linux-i386

      - name: Setup composer
        uses: protocolbuffers/protobuf-ci/composer-setup@v2
        with:
          cache-prefix: php-${{ matrix.version }}
          directory: php

      - name: Run tests
        uses: protocolbuffers/protobuf-ci/docker@v2
        with:
          image: ${{ env.image }}
          platform: linux/386
          credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
          extra-flags: -e COMPOSER_HOME=/workspace/composer-cache -e PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }}
          command: >-
            /bin/bash -cex '
            PATH="/usr/local/php-${{ matrix.version }}${{matrix.suffix}}/bin:$PATH";
            cd php && php -v && php -m;
            composer update --ignore-platform-reqs;
            composer ${{ matrix.test }}'

  linux-aarch64:
    name: Linux aarch64
    runs-on: ubuntu-latest
    steps:
      - name: Checkout pending changes
        uses: protocolbuffers/protobuf-ci/checkout@v2
        with:
          ref: ${{ inputs.safe-checkout }}

      - name: Cross compile protoc for aarch64
        id: cross-compile
        uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v2
        with:
          image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:6.3.0-91a0ac83e968068672bc6001a4d474cfd9a50f1d
          credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
          architecture: linux-aarch64

      - name: Setup composer
        uses: protocolbuffers/protobuf-ci/composer-setup@v2
        with:
          cache-prefix: php-8.0
          directory: php

      - name: Run tests
        uses: protocolbuffers/protobuf-ci/docker@v2
        with:
          image: us-docker.pkg.dev/protobuf-build/containers/test/linux/php-aarch64@sha256:77ff9fdec867bbfb290ee0b10d8b7a3e5e434155daa5ec93de7341c7592b858d
          platform: linux/arm64
          credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
          extra-flags: -e COMPOSER_HOME=/workspace/composer-cache -e PROTOC=/workspace/${{ steps.cross-compile.outputs.protoc }}
          command: >-
            -c '
            cd php;
            composer update --ignore-platform-reqs;
            composer test;
            composer test_c'

  macos:
    strategy:
      fail-fast: false   # Don't cancel all jobs if one fails.
      matrix:
        version: ['8.2']

    name: MacOS PHP ${{ matrix.version }}
    runs-on: macos-12
    steps:
      - name: Checkout pending changes
        uses: protocolbuffers/protobuf-ci/checkout@v2
        with:
          ref: ${{ inputs.safe-checkout }}

      - name: Uninstall problematic libgd
        run: brew uninstall --ignore-dependencies gd

      - name: Install dependencies
        run: brew install coreutils gd

      - name: Pin PHP version
        uses: shivammathur/setup-php@7fdd3ece872ec7ec4c098ae5ab7637d5e0a96067 # 2.26.0
        with:
          php-version: ${{ matrix.version }}

      - name: Check PHP version
        run: php --version | grep ${{ matrix.version }} || (echo "Invalid PHP version - $(php --version)" && exit 1)

      - name: Setup composer
        uses: protocolbuffers/protobuf-ci/composer-setup@v2
        with:
          cache-prefix: php-${{ matrix.version }}
          directory: php

      - name: Run tests
        uses: protocolbuffers/protobuf-ci/bash@v2
        with:
          credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
          command: |
            pushd php
            php -v
            php -m
            composer update
            composer test_c
            popd

      - name: Run conformance tests
        uses: protocolbuffers/protobuf-ci/bazel@v2
        with:
          credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
          bazel-cache: php_macos/${{ matrix.version }}
          bazel: test //php:conformance_test_c --action_env=PATH --test_env=PATH