name: CI
on:
push:
branches: [master]
pull_request:
jobs:
lint:
name: rustfmt and clippy
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
coverage: none
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all --check
- run: cargo clippy --workspace --all-targets -- -D warnings
test:
name: ${{ matrix.os }}, PHP ${{ matrix.php }} ${{ matrix.ts }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-latest, windows-latest]
php: ["8.2", "8.5", "8.6"]
ts: [nts]
include:
- { os: ubuntu-24.04, php: "8.6", ts: ts }
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer
env:
phpts: ${{ matrix.ts }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ runner.os == 'Windows' && 'nightly' || 'stable' }}
- uses: Swatinem/rust-cache@v2
with:
key: php-${{ matrix.php }}-${{ matrix.ts }}
- name: Build the extensions
run: cargo build --release --workspace
- name: Install the test suite's dependencies
working-directory: tests
run: composer install --no-interaction --no-progress
- name: Run the test suite
working-directory: tests
run: |
case "$RUNNER_OS" in
Linux) extension=../target/release/libphp_tokio_test_extension.so ;;
macOS) extension=../target/release/libphp_tokio_test_extension.dylib ;;
Windows) extension=../target/release/php_tokio_test_extension.dll ;;
esac
# ShutdownTest starts PHP processes of its own with the extension.
PHP_TOKIO_TEST_EXTENSION="$extension" php -d "extension=$extension" vendor/bin/phpunit
coverage:
name: coverage, ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-latest, windows-latest]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: "8.5"
coverage: none
tools: composer
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ runner.os == 'Windows' && 'nightly' || 'stable' }}
components: llvm-tools-preview
- uses: taiki-e/install-action@cargo-llvm-cov
- uses: Swatinem/rust-cache@v2
with:
key: coverage
- name: Install the test suite's dependencies
working-directory: tests
run: composer install --no-interaction --no-progress
- run: tests/coverage.sh
mutants:
name: mutation testing, ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
mutants: --exclude src/notify/windows.rs
- os: windows-latest
mutants: --file src/notify/windows.rs
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: "8.5"
coverage: none
tools: composer
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ runner.os == 'Windows' && 'nightly' || 'stable' }}
- uses: taiki-e/install-action@cargo-mutants
- uses: Swatinem/rust-cache@v2
with:
key: mutants
- name: Install the test suite's dependencies
working-directory: tests
run: composer install --no-interaction --no-progress
- name: Test the mutants
run: PHP_TOKIO_TESTS="$PWD/tests" cargo mutants --jobs 2 --timeout 300 ${{ matrix.mutants }}
- uses: actions/upload-artifact@v4
if: failure()
with:
name: mutants.out-${{ matrix.os }}
path: mutants.out