From ac3040854f5325204dc7a861fe37266e46aec746 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Thu, 14 Sep 2023 08:30:30 +0200 Subject: [PATCH] Run GitHub Action steps directly within docker containers --- .github/workflows/ci-ext.sh | 44 -------------------------- .github/workflows/ci-ext.yml | 60 +++++++++++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 49 deletions(-) delete mode 100755 .github/workflows/ci-ext.sh diff --git a/.github/workflows/ci-ext.sh b/.github/workflows/ci-ext.sh deleted file mode 100755 index 9b92478..0000000 --- a/.github/workflows/ci-ext.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh - -set -o nounset -set -o errexit - -. /etc/os-release - -case "${ID:-}" in - alpine) - apk update - case "$VERSION_ID" in - 3.11.* | 3.12.* | 3.13.* | 3.14.* | 3.15.* | 3.16.* | 3.17.*) - apk update && apk add $PHPIZE_DEPS lapack lapack-dev openblas-dev - if [ ! -e /usr/lib/liblapacke.so ]; then - # Fix for Alpine 3.15, 3.16 and 3.17 - ln -s /usr/lib/liblapacke.so.3 /usr/lib/liblapacke.so - fi - ;; - *) - apk add $PHPIZE_DEPS liblapack lapack-dev openblas-dev - ;; - esac - ;; - debian) - apt-get update - apt-get install -qy gfortran liblapack-dev libopenblas-dev liblapacke-dev - ;; - *) - echo 'Unsupported distribution' >&2 - exit 1 -esac - -cd /tmp -pecl package /app/package.xml -MAKE="make -j$(nproc)" pecl install tensor-*.tgz -docker-php-ext-enable tensor -php --ri tensor - -# Let's check that PHP doesn't output any warning -TENSOR_PHP_OUTPUT="$(php -r ';' 2>&1)" -if [ -n "$TENSOR_PHP_OUTPUT" ]; then - printf 'PHP displayed these warnings at startup:\n%s\n' "$TENSOR_PHP_OUTPUT" >&2 - exit 1 -fi diff --git a/.github/workflows/ci-ext.yml b/.github/workflows/ci-ext.yml index 4c73dbb..17b1787 100644 --- a/.github/workflows/ci-ext.yml +++ b/.github/workflows/ci-ext.yml @@ -32,12 +32,62 @@ jobs: name: Image ${{ matrix.image }} runs-on: ubuntu-latest + container: ${{ matrix.image }} steps: - - name: Pull docker image - run: docker pull ${{ matrix.image }} - - name: Checkout uses: actions/checkout@v3 - - name: Compile - run: docker run --rm -v "$GITHUB_WORKSPACE:/app" ${{ matrix.image }} /app/.github/workflows/ci-ext.sh + - name: Install system dependencies (Alpine) + if: contains(matrix.image, 'alpine') + run: | + apk update + . /etc/os-release + case "$VERSION_ID" in + 3.11.* | 3.12.* | 3.13.* | 3.14.* | 3.15.* | 3.16.* | 3.17.*) + apk update && apk add $PHPIZE_DEPS lapack lapack-dev openblas-dev + if [ ! -e /usr/lib/liblapacke.so ]; then + # Fix for Alpine 3.15, 3.16 and 3.17 + ln -s /usr/lib/liblapacke.so.3 /usr/lib/liblapacke.so + fi + ;; + *) + apk add $PHPIZE_DEPS liblapack lapack-dev openblas-dev + ;; + esac + + - name: Install system dependencies (Debian) + if: ${{ !contains(matrix.image, 'alpine') }} + run: | + apt-get update -q + apt-get install -qy gfortran liblapack-dev libopenblas-dev liblapacke-dev + + - name: Create working directory + run: | + rm -rf /tmp/tensor-package + mkdir /tmp/tensor-package + + - name: Create PECL package + run: | + cd /tmp/tensor-package + pecl package "$GITHUB_WORKSPACE/package.xml" + + - name: Compile PECL package + run: | + cd /tmp/tensor-package + MAKE="make -j$(nproc)" pecl install tensor-*.tgz + + - name: Enable PHP extension + run: docker-php-ext-enable tensor + + - name: Check for PHP startup warnings + run: | + php -d display_errors=stderr -d display_startup_errors=1 -d error_reporting=-1 -r ';' 2>/tmp/php-startup-warnings + if [ -s /tmp/php-startup-warnings ]; then + echo 'The PHP extension was successfully installed, but PHP raised these warnings:' >&2 + cat /tmp/php-startup-warnings >&2 + exit 1 + fi + echo "PHP didn't raise any warnings at startup." + + - name: Inspect PHP extension + run: php --ri tensor