Skip to content

Use checkout action v4 #4

Use checkout action v4

Use checkout action v4 #4

Workflow file for this run

# Copyright 2023 Rob Spoor
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Build
on:
workflow_dispatch:
push:
# only run for branches, not tags
branches-ignore: php8
pull_request:
jobs:
phpstan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up PHP 7.4
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: xdebug
tools: phpstan
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: PHPStan
run: phpstan analyse
test:
runs-on: ubuntu-latest
strategy:
matrix:
# PHP Unit 4.x is needed for PHP 5.4 but is not supported on PHP 8.x
php: [5.4, 5.6, 7.0, 7.4]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{matrix.php}}
coverage: xdebug
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: PHP Unit
run: |
echo '{}' | jq '.http.upload.skip |= ${{ secrets.SKIP_HTTP_UPLOAD }}' > tests/config.json
vendor/bin/phpunit tests
test-php8:
runs-on: ubuntu-latest
strategy:
matrix:
php: [8.0, 8.1, 8.2]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Rebase PHP8 branch
env:
USER_EMAIL: ${{ github.event.pusher.email }}
USER_NAME: ${{ github.event.pusher.name }}
REBASE_TARGET: ${{ github.head_ref || github.ref_name }}
run: |
git config user.email "$USER_EMAIL"
git config user.name "$USER_NAME"
git pull
git checkout php8
git rebase "$REBASE_TARGET" php8
git status
echo 'diff origin/php8:'
git diff origin/php8
echo 'diff current:'
git diff "$REBASE_TARGET"
- uses: shivammathur/setup-php@v2
with:
php-version: ${{matrix.php}}
coverage: xdebug
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php8-
- name: Install dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: PHP Unit
run: |
echo '{}' | jq '.http.upload.skip |= ${{ secrets.SKIP_HTTP_UPLOAD }}' > tests/config.json
vendor/bin/phpunit tests
rebase-php8:
runs-on: ubuntu-latest
needs: test-php8
if: github.ref_name == 'master'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: php8
fetch-depth: 0
- name: Rebase PHP8 branch
env:
USER_EMAIL: ${{ github.event.pusher.email }}
USER_NAME: ${{ github.event.pusher.name }}
run: |
git config user.email "$USER_EMAIL"
git config user.name "$USER_NAME"
git pull
git rebase origin/master php8
git status
echo 'diff origin/php8:'
git diff origin/php8
echo 'diff master:'
git diff origin/master
git push --force-with-lease