Skip to content

Cache PHP for nightly versions #315

Cache PHP for nightly versions

Cache PHP for nightly versions #315

Workflow file for this run

name: Cache PHP for nightly versions
on:
push:
workflow_dispatch:
schedule:
- cron: '0 4 1-31/2 * *'
jobs:
cache:
container: ubuntu:${{ matrix.container }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
container: [24.04, 22.04, 20.04]
php-versions: ['8.5']
builds: ['debug', 'release']
ts: [zts, nts]
if: "!contains(github.event.head_commit.message, 'skip-nightly-cache')"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install requirements
run: bash scripts/install-requirements.sh
env:
PHP_VERSION: ${{ matrix.php-versions }}
BUILDS: ${{ matrix.builds }}
NIGHTLY: 'true'
TS: ${{ matrix.ts }}
- name: Get ZSTD_DIR
id: zstd
run: echo "ZSTD_DIR=zstd-$(curl -sL https://github.com/facebook/zstd/releases/latest | grep -Po "tree/v(\d+\.\d+\.\d+)" | cut -d'v' -f 2 | head -n 1)" | tee -a "$GITHUB_OUTPUT"
- name: Add ZSTD
env:
CONTAINER: ${{ matrix.container }}
REPO: ${{ github.repository }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
USER: ${{ github.repository_owner }}
ZSTD_DIR: ${{ steps.zstd.outputs.ZSTD_DIR }}
run: bash scripts/install-zstd.sh
- name: Configure git
run: bash scripts/configure-git.sh
- name: Setup PHP
env:
PHP_VERSION: ${{ matrix.php-versions }}
BUILDS: ${{ matrix.builds }}
NIGHTLY: 'true'
TS: ${{ matrix.ts }}
run: bash scripts/install-php.sh
- name: Build package
env:
GITHUB_WORKSPACE: ${{ github.workspace }}
PHP_VERSION: ${{ matrix.php-versions }}
BUILDS: ${{ matrix.builds }}
TS: ${{ matrix.ts }}
run: bash scripts/package-php.sh
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ubuntu-${{ matrix.container }}-${{ matrix.php-versions }}-${{ matrix.builds }}-${{ matrix.ts }}
path: builds
tests:
runs-on: ${{ matrix.os }}
needs: cache
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-22.04, ubuntu-20.04]
php-versions: ['8.5']
builds: ['debug', 'release']
ts: [nts, zts]
if: "!contains(github.event.head_commit.message, 'skip-tests')"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.php-versions }}-${{ matrix.builds }}-${{ matrix.ts }}
path: /tmp
- name: Patch script
run: sed -i -e '/releases/d' -e '$s/fix_packages//' -e '1s/$/\n\nset -x/' scripts/install.sh
- name: Setup PHP
run: bash scripts/install.sh ${{ matrix.php-versions }} ${{ matrix.builds }} ${{ matrix.ts }}
- name: Switch versions
run: |
sudo update-alternatives --set php-cgi-bin /usr/lib/cgi-bin/php${{ matrix.php-versions }}
sudo update-alternatives --set php-fpm /usr/sbin/php-fpm${{ matrix.php-versions }}
sudo update-alternatives --set php-fpm.sock /run/php/php${{ matrix.php-versions }}-fpm.sock
for tool in phpize php-config phpdbg php-cgi php phar.phar phar; do
sudo update-alternatives --set "$tool" /usr/bin/"$tool"${{ matrix.php-versions }}
done
- name: Test PHP
run: |
file /usr/bin/php${{ matrix.php-versions }}
php -v
php-config --version
php-fpm -v
php-cgi -v
phpize -v
php -m
sudo service php${{ matrix.php-versions }}-fpm status || exit 1
php -v | grep -q '${{ matrix.php-versions }}' || exit 1
php-config --version | grep -q '${{ matrix.php-versions }}' || exit 1
phpize -v | grep -q "$(php-config --phpapi)" || exit 1
php-fpm -v | grep -q '${{ matrix.php-versions }}' || exit 1
php-cgi -v | grep -q '${{ matrix.php-versions }}' || exit 1
- name: Test broken packages
run: sudo apt-get check
release:
runs-on: ubuntu-latest
needs: [cache, tests]
if: "!contains(github.event.head_commit.message, 'skip-release')"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create builds directory
run: mkdir builds
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: builds
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install cloudsmith-cli
run: pip install --upgrade cloudsmith-cli
- name: Release
run: bash scripts/release.sh
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
GITHUB_MESSAGE: ${{ github.event.head_commit.message }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_WORKSPACE: ${{ github.workspace }}