Skip to content

Commit eb041bb

Browse files
authored
Merge pull request #53 from arnaud-lb/github-workflow
Add github workflow
2 parents 11e2b71 + e632428 commit eb041bb

File tree

8 files changed

+143
-4
lines changed

8 files changed

+143
-4
lines changed

.github/workflows/test.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: 'Tests'
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
tests:
11+
name: 'Tests'
12+
strategy:
13+
matrix:
14+
include:
15+
- php: '8.0.0'
16+
os: 'ubuntu-20.04'
17+
expect_native: 1
18+
werror: 1
19+
20+
- php: '8.0.0'
21+
os: 'macos-10.15'
22+
23+
- php: '7.4.0'
24+
os: 'ubuntu-20.04'
25+
expect_native: 1
26+
27+
- php: '7.3.0'
28+
os: 'ubuntu-20.04'
29+
expect_native: 1
30+
31+
runs-on: ${{ matrix.os }}
32+
continue-on-error: ${{ !!matrix.experimental }}
33+
env:
34+
PHP_VERSION: ${{ matrix.php }}
35+
MEMORY_CHECK: ${{ matrix.memcheck }}
36+
WERROR: ${{ matrix.werror }}
37+
MEMPROF_EXPECT_NATIVE_TRACKING: ${{ matrix.expect_native }}
38+
steps:
39+
- name: 'Check out repository'
40+
uses: 'actions/checkout@v2'
41+
with:
42+
path: 'ext'
43+
44+
- uses: actions/cache@v2
45+
with:
46+
path: ~/build-cache/php
47+
key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.memcheck }}
48+
49+
- name: 'Build PHP'
50+
run: './ext/.github/workflows/test/build-php.sh'
51+
52+
- name: 'Build extension'
53+
run: './ext/.github/workflows/test/build-extension.sh'
54+
55+
- name: 'Run tests'
56+
run: './ext/.github/workflows/test/tests.sh'
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
export PATH="$HOME/php/bin:$PATH"
6+
hash -r
7+
8+
echo "Building extension with PHP version:"
9+
php --version
10+
11+
if which apt-get >/dev/null 2>&1; then
12+
sudo apt-get -y install libjudy-dev
13+
else
14+
brew install traildb/judy/judy
15+
fi
16+
17+
if [ "$WERROR" = "1" ]; then
18+
PHP_EXT_CFLAGS="-Wall -Werror -Wno-deprecated-declarations"
19+
fi
20+
21+
cd ext
22+
phpize
23+
CFLAGS="$PHP_EXT_CFLAGS" ./configure
24+
make
25+
26+
echo "extension=$(pwd)/modules/memprof.so"|sudo tee "$HOME/php/etc/php/memprof.ini" >/dev/null

.github/workflows/test/build-php.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
if [ "$MEMORY_CHECK" = "1" ]; then
6+
if which apt-get >/dev/null 2>&1; then
7+
sudo apt-get -y install valgrind
8+
else
9+
break install valgrind
10+
fi
11+
fi
12+
13+
PREFIX="$HOME/php"
14+
15+
if ! [ -f "$HOME/build-cache/php/$PREFIX/bin/php" ]; then
16+
echo "PHP build is not cached"
17+
18+
wget https://secure.php.net/distributions/php-${PHP_VERSION}.tar.bz2
19+
tar xjf php-${PHP_VERSION}.tar.bz2
20+
cd php-${PHP_VERSION}
21+
22+
PHP_BUILD_FLAGS="--prefix=$PREFIX --disable-all --enable-cli --enable-cgi --with-config-file-scan-dir=$PREFIX/etc/php --with-zlib --enable-debug"
23+
24+
if [ $MEMORY_CHECK -eq 1 ]; then
25+
PHP_BUILD_FLAGS="$PHP_BUILD_FLAGS --with-valgrind"
26+
fi
27+
28+
./configure $PHP_BUILD_FLAGS $PHP_BUILD_EXTRA_FLAGS
29+
make -j $(nproc)
30+
rm -rf "$HOME/build-cache/php"
31+
mkdir -p ~/build-cache/php
32+
sudo make install INSTALL_ROOT=$HOME/build-cache/php
33+
else
34+
echo "PHP build is cached"
35+
fi
36+
37+
sudo rsync -av "$HOME/build-cache/php$PREFIX/" "$PREFIX/"
38+
sudo mkdir -p "$PREFIX/etc/php"

.github/workflows/test/tests.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
set -xve
4+
5+
export PATH="$HOME/php/bin:$PATH"
6+
hash -r
7+
8+
cd ext
9+
10+
if [ "$MEMORY_CHECK" = "1" ]; then
11+
echo "Enabling memory checking"
12+
showmem=--show-mem
13+
checkmem=-m
14+
fi
15+
16+
PHP=$(which php)
17+
REPORT_EXIT_STATUS=1 TEST_PHP_EXECUTABLE="$PHP" "$PHP" run-tests.php -q $checkmem --show-diff $showmem

memprof.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ static zend_bool should_autodump(int error_type, const char *message) {
748748
static char * generate_filename(const char * format) {
749749
char * filename;
750750
struct timeval tv;
751-
int64_t ts;
751+
uint64_t ts;
752752
const char * output_dir = MEMPROF_G(output_dir);
753753
char slash[] = "\0";
754754

@@ -759,7 +759,7 @@ static char * generate_filename(const char * format) {
759759
slash[0] = DEFAULT_SLASH;
760760
}
761761

762-
spprintf(&filename, 0, "%s%smemprof.%s.%lld", output_dir, slash, format, (long long) ts);
762+
spprintf(&filename, 0, "%s%smemprof.%s.%" PRIu64, output_dir, slash, format, ts);
763763

764764
return filename;
765765
}

tests/007.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Enable native profiling
3+
--SKIPIF--
4+
<?php getenv('MEMPROF_EXPECT_NATIVE_TRACKING') === '1' || die("skip no native tracking");
35
--ENV--
46
MEMPROF_PROFILE=native
57
--FILE--

tests/autodump-disabled.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function f() {
2929

3030
f();
3131
--EXPECTF--
32-
string(%d) "/tmp/%s"
32+
string(%d) "/%s"
3333
bool(true)
3434
array(3) {
3535
["enabled"]=>

tests/autodump.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function f() {
2929

3030
f();
3131
--EXPECTF--
32-
string(%d) "/tmp/%s"
32+
string(%d) "/%s"
3333
bool(true)
3434
array(3) {
3535
["enabled"]=>

0 commit comments

Comments
 (0)