diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f114833136..1744b602ca 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -73,6 +73,17 @@ jobs: - php: '8.4' skip_tests: true + # The default libxml library on Ubuntu images is a little out of date. + # To safeguard support for the latest libxml we need to update the library on the fly. + # This only needs to be tested with one PHP version for each libxml minor to verify support. + # Testing against multiple PHP versions would not yield a difference in results. + - php: '8.0' + os: 'ubuntu-latest' + libxml_minor: '2.11' + - php: '8.3' + os: 'ubuntu-latest' + libxml_minor: '2.13' + # Extra builds running only the unit tests with different PHP ini settings. - php: '5.5' os: 'ubuntu-latest' @@ -82,7 +93,7 @@ jobs: custom_ini: true # yamllint disable-line rule:line-length - name: "PHP: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }})" + name: "PHP: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }}${{ matrix.libxml_minor && format( ' with libxml {0}', matrix.libxml_minor ) || '' }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }})" continue-on-error: ${{ matrix.php == '8.5' }} @@ -93,6 +104,70 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: "libxml2: find the latest relevant tag" + if: ${{ matrix.libxml_minor }} + id: libxml_version + uses: oprypin/find-latest-tag@v1 + with: + repository: GNOME/libxml2 + releases-only: false # The libxml2 repository doesn't use GitHub's "release" feature. + prefix: 'v${{ matrix.libxml_minor }}.' # Limit the result to the minor we're interested in. + sort-tags: true # Find the "greatest" version for that minor based on semver. + + # To put it simply: we need to remove the 'v' prefix from the version number. + - name: "libxml2: parse the version to a patch version" + if: ${{ matrix.libxml_minor }} + id: libxml_patch_version + shell: bash + env: + TAG: ${{ steps.libxml_version.outputs.tag }} + run: echo "PATCH=$( echo "$TAG" | cut -b 2- )" >> "$GITHUB_OUTPUT" + + - name: "libxml2: restore cache" + if: ${{ matrix.libxml_minor }} + id: libxml_cache_restore + uses: actions/cache/restore@v4 + with: + path: "libxml2-${{ steps.libxml_patch_version.outputs.PATCH }}" + key: "${{ matrix.os }}-libxml-${{ matrix.libxml_minor }}-${{ steps.libxml_patch_version.outputs.PATCH }}" + + # Updating the lists can fail intermittently, typically after Microsoft has released a new package. + # This should not be blocking for this job, so ignore any errors from this step. + # Ref: https://github.com/dotnet/core/issues/4167 + - name: "libxml2: Update the available packages list" + if: ${{ matrix.libxml_minor && steps.libxml_cache_restore.outputs.cache-hit != 'true' }} + continue-on-error: true + run: sudo apt-get update + + - name: "libxml2: Download and build package (linux only)" + if: ${{ matrix.libxml_minor && steps.libxml_cache_restore.outputs.cache-hit != 'true' }} + env: + PATCH: ${{ steps.libxml_patch_version.outputs.PATCH }} + run: | + sudo apt-get install -y wget build-essential + wget "https://download.gnome.org/sources/libxml2/${{ matrix.libxml_minor }}/libxml2-$PATCH.tar.xz" + tar -xf "libxml2-$PATCH.tar.xz" + cd "libxml2-$PATCH" + ./configure --prefix=/usr/local + make + + - name: "libxml2: save cache" + if: ${{ matrix.libxml_minor && steps.libxml_cache_restore.outputs.cache-hit != 'true' }} + id: libxml_cache_save + uses: actions/cache/save@v4 + with: + path: "libxml2-${{ steps.libxml_patch_version.outputs.PATCH }}" + key: ${{ steps.libxml_cache_restore.outputs.cache-primary-key }} + + - name: "libxml2: Install package (linux only)" + if: ${{ matrix.libxml_minor }} + env: + PATCH: ${{ steps.libxml_patch_version.outputs.PATCH }} + run: | + cd "libxml2-$PATCH" + sudo make install + sudo ldconfig + - name: Setup ini config id: set_ini shell: bash @@ -115,6 +190,9 @@ jobs: coverage: none tools: cs2pr + - name: "DEBUG: show libxml loaded version (php)" + run: php -r 'echo "libxml loaded version = ", LIBXML_LOADED_VERSION, PHP_EOL;' + # This action also handles the caching of the dependencies. - name: Set up node if: ${{ matrix.custom_ini == false }}