|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + tags-ignore: |
| 8 | + - '**' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - master |
| 12 | + |
| 13 | +env: |
| 14 | + LIBIP2LOCATION_VERSION: 8.7.0 |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + name: PECL (PHP ${{ matrix.php-version }} on ${{ matrix.os-version }}) |
| 19 | + runs-on: ubuntu-latest |
| 20 | + container: |
| 21 | + image: php:${{ matrix.php-version }}-cli-${{ matrix.os-version }} |
| 22 | + strategy: |
| 23 | + fail-fast: false |
| 24 | + matrix: |
| 25 | + include: |
| 26 | + - |
| 27 | + php-version: '8.0' |
| 28 | + os-version: alpine3.13 |
| 29 | + prepare-command: apk add --no-cache $PHPIZE_DEPS automake libtool perl |
| 30 | + cleanup-command: apk del $PHPIZE_DEPS automake libtool perl |
| 31 | + - |
| 32 | + php-version: '8.0' |
| 33 | + os-version: buster |
| 34 | + prepare-command: apt-get update && apt-get install -qy automake libtool |
| 35 | + cleanup-command: apt-get remove --purge -qy automake libtool |
| 36 | + fix-apt: true |
| 37 | + - |
| 38 | + php-version: '8.4' |
| 39 | + os-version: alpine3.22 |
| 40 | + prepare-command: apk add --no-cache $PHPIZE_DEPS automake libtool perl |
| 41 | + cleanup-command: apk del $PHPIZE_DEPS automake libtool perl |
| 42 | + - |
| 43 | + php-version: '8.4' |
| 44 | + os-version: trixie |
| 45 | + prepare-command: apt-get update && apt-get install -qy automake libtool |
| 46 | + cleanup-command: apt-get remove --purge -qy automake libtool |
| 47 | + steps: |
| 48 | + - |
| 49 | + name: Fix apt |
| 50 | + if: matrix.fix-apt |
| 51 | + env: |
| 52 | + DEB_ARCHIVE: http://archive.debian.org/debian-archive |
| 53 | + DEB_ARCHIVE_SECURITY: http://archive.debian.org/debian-archive/debian-security |
| 54 | + run: | |
| 55 | + echo '# Original /etc/apt/sources.list' |
| 56 | + cat /etc/apt/sources.list | grep -v '^#' |
| 57 | + . /etc/os-release |
| 58 | + sed -ri "s;^(\s*deb\s+http://(httpredir|deb).debian.org/debian\s+$VERSION_CODENAME-updates\b.*);#\1;" /etc/apt/sources.list |
| 59 | + sed -ri "s;^(\s*deb\s+)http://(httpredir|deb).debian.org;\1$DEB_ARCHIVE;" /etc/apt/sources.list |
| 60 | + sed -ri "s;^(\s*deb\s+)http://security.debian.org/debian-security;\1$DEB_ARCHIVE_SECURITY;" /etc/apt/sources.list |
| 61 | + sed -ri "s;^(\s*deb\s+)http://security.debian.org;\1$DEB_ARCHIVE_SECURITY;" /etc/apt/sources.list |
| 62 | + echo '# Patched /etc/apt/sources.list' |
| 63 | + cat /etc/apt/sources.list | grep -v '^#' |
| 64 | + - |
| 65 | + name: Prepare environment |
| 66 | + if: matrix.prepare-command |
| 67 | + run: ${{ matrix.prepare-command }} |
| 68 | + - |
| 69 | + name: Install libIP2Location |
| 70 | + working-directory: /tmp |
| 71 | + run: | |
| 72 | + curl -sSLf "https://codeload.github.com/chrislim2888/IP2Location-C-Library/tar.gz/$LIBIP2LOCATION_VERSION" | tar xz |
| 73 | + cd IP2Location-C-Library-* |
| 74 | + autoreconf -fiv |
| 75 | + ./configure |
| 76 | + make -j$(nproc) |
| 77 | + (cd data && perl ip-country.pl) |
| 78 | + make check |
| 79 | + make install |
| 80 | + ldconfig || true |
| 81 | + cd .. |
| 82 | + rm -rf IP2Location-C-Library-* |
| 83 | + - |
| 84 | + name: Checkout repository |
| 85 | + uses: actions/checkout@v4 |
| 86 | + - |
| 87 | + name: Create PECL package |
| 88 | + run: | |
| 89 | + pecl package |
| 90 | + mv ip2location-*.tgz /tmp/ip2location.tgz |
| 91 | + - |
| 92 | + name: Install PECL package |
| 93 | + working-directory: /tmp |
| 94 | + run: | |
| 95 | + pecl install ./ip2location.tgz |
| 96 | + - |
| 97 | + name: Cleanup environment |
| 98 | + if: matrix.cleanup-command |
| 99 | + run: ${{ matrix.cleanup-command }} |
| 100 | + - |
| 101 | + name: Enable extension |
| 102 | + run: docker-php-ext-enable ip2location |
| 103 | + - |
| 104 | + name: Inspect extension |
| 105 | + run: php --ri ip2location |
0 commit comments