Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to GitHub Actions from Travis #75

Draft
wants to merge 65 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
72ac62c
Drop .travis.yml integration
glensc Aug 7, 2021
8bbbe86
Add CI job to run tests
glensc May 31, 2022
356fd4b
Debug on push
glensc May 31, 2022
a2b4bcc
Install extensions
glensc May 31, 2022
bc839bf
fixup! Debug on push
glensc May 31, 2022
a375c24
Fix SC2223
glensc May 31, 2022
ce62ce4
fixup! Install extensions
glensc May 31, 2022
0b14ba5
Revert "Fix SC2223"
glensc May 31, 2022
5905847
fixup! Fix SC2223
glensc May 31, 2022
4a99aba
fixup! fixup! Fix SC2223
glensc May 31, 2022
a7e5d39
Test xhprof from shivammathur
glensc May 31, 2022
94b2e31
Add has_extension helper
glensc May 31, 2022
79703da
Skip xhprof install if present
glensc May 31, 2022
b206401
Install mongodb via shivammathur
glensc May 31, 2022
e9bae35
Use has_extension check for mongodb
glensc May 31, 2022
7e32862
Try tideways_xhprof extension
glensc May 31, 2022
93830ec
Show php config paths
glensc May 31, 2022
94f3e94
Use path specific to GHA
glensc May 31, 2022
75a838c
Run phpunit
glensc May 31, 2022
79452d8
Fix test name
glensc May 31, 2022
03840e6
Install phpunit
glensc May 31, 2022
53efaec
Add "test" script to composer
glensc May 31, 2022
647958f
fixup! Add "test" script to composer
glensc May 31, 2022
603828a
Restore composer test
glensc May 31, 2022
b47256f
Skip deprecated --no-suggest
glensc May 31, 2022
1608d26
No composer.lock, so hash based on composer.json
glensc May 31, 2022
206a3dc
Rename to mongodb
glensc May 31, 2022
ef818d7
Add mongodb service
glensc May 31, 2022
4e3ca43
Pass tests to enable cache
glensc May 31, 2022
647fbcb
Revert "Pass tests to enable cache"
glensc May 31, 2022
fc3768b
Include phpunit version to cache-key
glensc May 31, 2022
291b68a
Unpack tideways_xhprof to vendor for cache
glensc May 31, 2022
01a5379
Fix expected frame count
glensc May 31, 2022
ed658bc
Optimize for cache
glensc Jun 1, 2022
7814a50
Update to 5.0.4
glensc Jun 1, 2022
2ca796e
fixup! Update to 5.0.4
glensc Jun 1, 2022
2c3ccf1
fixup! Update to 5.0.4
glensc Jun 1, 2022
c321ffb
Allow php 8.x
glensc Jun 1, 2022
3c8bdf0
Enable more 7.x versions
glensc Jun 1, 2022
21b1f2f
Fix cache key
glensc Jun 1, 2022
635a700
Use shared CACHE_KEY for cache key
glensc Jun 1, 2022
5fdae61
Add PHP_VERSION environ
glensc Jun 1, 2022
ffb9fee
Debug env
glensc Jun 1, 2022
bcb826f
Cleanup TRAVIS_PHP_VERSION
glensc Jun 1, 2022
472b8ad
Remove env debug
glensc Jun 1, 2022
c425976
Change syntax
glensc Jun 1, 2022
f1ce96d
Switch to bash
glensc Jun 1, 2022
9eb3a3b
fixup! Switch to bash
glensc Jun 1, 2022
4dfc2ac
Debug PHP_VERSION
glensc Jun 1, 2022
d8d4085
Remove sudo
glensc Jun 1, 2022
e65ba7d
Use has_extension
glensc Jun 1, 2022
cc3252e
Use sudo for specific command only
glensc Jun 1, 2022
6d186e2
Use new cache key
glensc Jun 1, 2022
ff63c08
Use PHP_VERSION for cache key
glensc Jun 1, 2022
dfa2410
Disable fail-fast
glensc Jun 1, 2022
0a17cd4
Test array key existence rather count
glensc Jun 1, 2022
bd41855
Install extensions with composer
glensc Jun 1, 2022
8e655dd
Bump cache key
glensc Jun 1, 2022
bc4d77d
Remove env for tests
glensc Jun 1, 2022
adf0e14
Fix test name
glensc Jun 1, 2022
3db0d9c
Remove PHP_VERSION debug
glensc Jun 1, 2022
50ee687
Revert "Install extensions with composer"
glensc Jun 1, 2022
9bd3911
Install twice
glensc Jun 1, 2022
c2172e6
Bump cache
glensc Jun 1, 2022
a14368a
Try php 8.0
glensc Jun 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/tests-mongodb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: "Tests: MongoDB"

on:
- pull_request
- push

jobs:
mongodb:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
php:
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "8.0"
env:
PHPUNIT_VERSION: "7.5"
PHP_VERSION: "${{ matrix.php }}"

services:
mongodb:
image: percona/percona-server-mongodb:3.6
ports:
- 27017:27017

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: xdebug, xhprof, mongodb, tideways_xhprof

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
env:
CACHE_KEY: "${{ runner.os }}-php-${{ env.PHP_VERSION }}-phpunit-${{ env.PHPUNIT_VERSION }}-v4"
with:
path: vendor
key: ${{ env.CACHE_KEY }}-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ env.CACHE_KEY }}-

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: |
composer install --prefer-dist --no-progress
composer require --dev phpunit/phpunit:^$PHPUNIT_VERSION
./install-extensions.sh

- name: Install extensions
run: ./install-extensions.sh

- name: Run PHPUnit tests
run: composer test

# vim:ft=yaml:et:ts=2:sw=2
97 changes: 0 additions & 97 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"config": {
"sort-packages": true
},
"scripts": {
"test": "phpunit"
},
"autoload": {
"psr-4": {
"Xhgui\\Profiler\\": "src/"
Expand Down
49 changes: 32 additions & 17 deletions install-extensions.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
#!/bin/sh
#!/usr/bin/env bash

set -xeu
set -eu
set -x

: ${TRAVIS_PHP_VERSION=7.4}
: ${TIDEWAYS_VERSION=4.1.4}
: ${TIDEWAYS_XHPROF_VERSION=5.0.2}
: ${PHP_VERSION=${TRAVIS_PHP_VERSION}}
: "${TIDEWAYS_VERSION:=4.1.4}"
: "${TIDEWAYS_XHPROF_VERSION:=5.0.4}"
: "${PHP_VERSION:=7.4}"

die() {
echo >&2 "ERROR: $*"
exit 1
}

has_extension() {
local extension="$1"
php -m | awk -vrc=1 -vextension="$extension" '$1 == extension { rc=0 } END { exit rc }'
}

install_xhprof() {
local version="${1:-stable}"

has_extension "xhprof" && return 0
pecl install xhprof-$version
}

Expand All @@ -23,7 +29,7 @@ install_mongo() {
}

install_mongodb() {
php -m | grep -q mongodb || pecl install -f mongodb
has_extension "mongodb" || pecl install -f mongodb
composer require --dev alcaeus/mongo-php-adapter
}

Expand All @@ -33,31 +39,40 @@ install_tideways_xhprof() {
local url="https://github.com/tideways/php-xhprof-extension/releases/download/v$version/tideways-xhprof-$version-$arch.tar.gz"
local extension="tideways_xhprof"
local tar="$extension.tgz"
local config library
local workdir="vendor/tideways_xhprof"
local library
local config
local zts

curl -fL -o "$tar" "$url"
tar -xvf "$tar"

zts=$(php --version | grep -q ZTS && echo -zts || :)
library="$PWD/tideways_xhprof-$version/tideways_xhprof-$PHP_VERSION$zts.so"
config="$HOME/.phpenv/versions/$PHP_VERSION/etc/conf.d/tideways_xhprof.ini"
library="$PWD/$workdir/tideways_xhprof-$version/tideways_xhprof-$PHP_VERSION$zts.so"

if [ ! -f "$library" ]; then
curl -fL -o "$tar" "$url"
mkdir -p "$workdir"
tar -xvf "$tar" -C "$workdir"
fi

test -f "$library" || die "Extension not available: $library"
echo "extension=$library" > "$config"
php -m | grep -F "$extension"
config="/etc/php/$PHP_VERSION/cli/conf.d/10-tideways_xhprof.ini"
echo "extension=$library" | sudo tee "$config"
has_extension "$extension"
}

# Show php config paths
php --ini

case "$(uname -s):$PHP_VERSION" in
*:5.*)
install_xhprof 0.9.4
install_mongo
;;
Linux:7.*)
Linux:7.*|Linux:8.*)
install_xhprof
install_mongodb
install_tideways_xhprof
;;
*:7.*)
*:7.*|*:8.*)
install_xhprof
install_mongodb
;;
Expand Down
8 changes: 4 additions & 4 deletions tests/TidewaysXHProfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function setUp()
public function testDefaults()
{
$data = $this->runProfiler();
$this->assertCount(3, $data);
$this->assertArrayHasKey('main()', $data);
}

public function testCpuFlags()
Expand All @@ -27,7 +27,7 @@ public function testCpuFlags()
ProfilingFlags::CPU,
);
$data = $this->runProfiler($flags);
$this->assertCount(3, $data);
$this->assertArrayHasKey('main()', $data);
$main = $data['main()'];
$this->assertArrayHasKey('cpu', $main);
}
Expand All @@ -39,7 +39,7 @@ public function testCpuMemoryFlags()
ProfilingFlags::MEMORY,
);
$data = $this->runProfiler($flags);
$this->assertCount(3, $data);
$this->assertArrayHasKey('main()', $data);

$main = $data['main()'];
$this->assertArrayHasKey('cpu', $main);
Expand All @@ -52,6 +52,6 @@ public function testNoFlags()
ProfilingFlags::NO_BUILTINS,
);
$data = $this->runProfiler($flags);
$this->assertCount(2, $data);
$this->assertArrayHasKey('main()', $data);
}
}