Test #439
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
workflow_dispatch: | |
push: | |
jobs: | |
build-php: | |
if: "!contains(github.event.head_commit.message, 'skip-build-php')" | |
name: Build PHP ${{ matrix.php-versions }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
php-versions: [5.3, 5.4, 5.5] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Cache Docker layers | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-docker-php-${{ matrix.php-versions }}-${{ github.run_id }}-${{ github.run_number }} | |
restore-keys: ${{ runner.os }}-docker-php-${{ matrix.php-versions }} | |
- name: Build | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
tags: php-${{ matrix.php-versions }} | |
build-args: PHP_VERSION=${{ matrix.php-versions }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new | |
outputs: type=docker,dest=/tmp/php-${{ matrix.php-versions }}.tar | |
# https://github.com/docker/build-push-action/issues/252 | |
- name: Move build cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
- name: Copy build | |
env: | |
PHP_VERSION: ${{ matrix.php-versions }} | |
run: | | |
docker load --input /tmp/php-$PHP_VERSION.tar | |
docker run --name=php-$PHP_VERSION php-$PHP_VERSION sh -c exit | |
sudo chmod 777 /usr/local | |
docker cp php-$PHP_VERSION:/usr/local/php /usr/local/php | |
- name: Package and ship artifact to releases | |
run: bash scripts/build.sh ship | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_WORKSPACE: ${{ github.workspace }} | |
PHP_VERSION: ${{ matrix.php-versions }} | |
REPO: ${{ github.repository }} | |
USER: ${{ github.repository_owner }} | |
- name: Upload artifact to workflow | |
uses: actions/upload-artifact@v2 | |
with: | |
name: php${{ matrix.php-versions }} | |
path: ${{ github.workspace }}/php-${{ matrix.php-versions }}-build.tar.zst | |
test: | |
needs: build-php | |
if: ${{ always() }} | |
name: Test PHP-${{ matrix.php-versions }} on ${{ matrix.operating-system }} | |
runs-on: ${{ matrix.operating-system }} | |
strategy: | |
fail-fast: false | |
matrix: | |
operating-system: [ubuntu-24.04, ubuntu-22.04, ubuntu-20.04] | |
php-versions: ['5.3', '5.4', '5.5'] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Stage PHP | |
run: | | |
bash scripts/version-files.sh ${{ matrix.php-versions }} | |
bash scripts/stage.sh ${{ matrix.php-versions }} | |
gh release download -p 'php-${{ matrix.php-versions }}-build.tar.zst' -D php-${{ matrix.php-versions }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install PHP | |
run: | | |
cd php-${{ matrix.php-versions }} || exit | |
sudo chmod a+x *.sh | |
./install-php.sh | |
./post-install.sh | |
- name: Test libs | |
run: sudo apt-get -f install | |
- name: Test versions and extensions | |
run: | | |
php$ver -v | head -n 1 | |
php-config$ver --version | |
phpize$ver -v | |
php$ver -m | |
php-cgi -v | |
php-fpm -v | |
pecl -V | |
curl -V | |
sudo service php$ver-fpm status | |
php$ver -r "echo file_get_contents('https://repo.packagist.org/packages.json');" | |
env: | |
ver: ${{ matrix.php-versions }} | |
- name: Test SAPI | |
run: | | |
sudo rm -rf /var/www/html/index.html | |
echo "<?php echo current(explode('-', php_sapi_name())).':'.strtolower(current(explode('/', \$_SERVER['SERVER_SOFTWARE']))).\"\n\";" | sudo tee /var/www/html/index.php >/dev/null | |
for sapi in apache2handler:apache fpm:apache cgi:apache fpm:nginx; do | |
echo "::group::Test $sapi" | |
sudo switch_sapi $sapi >/dev/null | |
curl -s http://localhost | |
[ "$(curl -s http://localhost)" != "$sapi" ] && exit 1 | |
echo "::endgroup::" | |
done | |
package: | |
name: Update dist | |
if: "!contains(github.event.head_commit.message, 'skip-release')" | |
needs: [build-php, test] | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
php-versions: ['5.3', '5.4', '5.5'] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Add ZSTD | |
env: | |
REPO: ${{ github.repository }} | |
TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
USER: ${{ github.repository_owner }} | |
run: bash scripts/install-zstd.sh | |
- name: Package | |
run: | | |
mkdir builds | |
bash scripts/version-files.sh "$PHP_VERSION" | |
bash scripts/stage.sh "$PHP_VERSION" | |
gh release download -p php-"$PHP_VERSION"-build.tar.zst -D php-"$PHP_VERSION" | |
sudo XZ_OPT=-e9 tar cfJ php-"$PHP_VERSION".tar.xz php-"$PHP_VERSION" | |
sudo tar cf - php-"$PHP_VERSION" | zstd -22 -T0 --ultra > php-"$PHP_VERSION".tar.zst | |
mv php-"$PHP_VERSION".tar.* ./builds/ | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PHP_VERSION: ${{ matrix.php-versions }} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: builds | |
path: builds | |
release: | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, 'skip-release')" | |
needs: [build-php, test, package] | |
steps: | |
- uses: actions/checkout@v3 | |
- run: mkdir builds | |
- uses: actions/download-artifact@v2 | |
with: | |
name: builds | |
path: builds | |
- name: Release | |
run: | | |
set -x | |
assets=() | |
for asset in ./builds/*; do | |
assets+=("$asset") | |
done | |
assets+=("./scripts/install.sh") | |
gh release download -p "release.log" || true | |
echo "$(date "+%Y-%m-%d %H:%M:%S") Update ${assets[@]}" | sudo tee -a release.log >/dev/null 2>&1 | |
assets+=("./release.log") | |
exists=$(gh release list | grep -Po 'builds' | head -n 1) | |
if [ "x$exists" != "xbuilds" ]; then | |
gh release create "builds" "${assets[@]}" -n "builds" -t "builds" | |
else | |
gh release upload "builds" "${assets[@]}" --clobber | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |