-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from scoutapp/research-for-compiling-with-curl
Documentation and info for libcurl requirements
- Loading branch information
Showing
12 changed files
with
202 additions
and
22 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
FROM ubuntu:22.04 | ||
RUN apt-get update && apt-get -y upgrade \ | ||
&& apt-get -y install software-properties-common \ | ||
&& add-apt-repository ppa:ondrej/php \ | ||
&& apt-get update \ | ||
&& DEBIAN_FRONTEND=noninteractive apt-get -y install php8.0 php8.0-xml php8.0-dev | ||
|
||
ARG WITH_CURL_EXT=no | ||
RUN if [ "$WITH_CURL_EXT" = "yes" ]; then apt-get -y install php8.0-curl; fi | ||
|
||
ARG WITH_LIBCURL=no | ||
RUN if [ "$WITH_LIBCURL" = "yes" ]; then apt-get -y install libcurl4-openssl-dev; fi | ||
|
||
ADD *.c *.h config.m4 /scoutapm/ | ||
|
||
RUN cd /scoutapm/ \ | ||
&& ls -l \ | ||
&& phpize \ | ||
&& ./configure --enable-scoutapm \ | ||
&& cat config.h \ | ||
&& make \ | ||
&& make install \ | ||
&& echo "zend_extension=scoutapm" > /etc/php/8.0/mods-available/scoutapm.ini \ | ||
&& phpenmod scoutapm | ||
|
||
ADD .github/test-curl-compilation/analyse-curl.php /scoutapm/analyse-curl.php | ||
|
||
ENTRYPOINT ["/usr/bin/php"] | ||
CMD ["/scoutapm/analyse-curl.php"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
ob_start(); | ||
phpinfo(INFO_MODULES); | ||
$phpinfo = array_column(array_map( | ||
static function ($s) { | ||
return explode(' => ', str_replace('scoutapm curl ', '', $s)); | ||
}, | ||
array_values(array_filter( | ||
explode("\n", ob_get_contents()), | ||
static function ($s) { | ||
return str_contains($s, 'scoutapm curl'); | ||
} | ||
)) | ||
), 1, 0); | ||
ob_end_clean(); | ||
|
||
echo sprintf("HAVE_CURL: %s\n", $phpinfo['HAVE_CURL']); | ||
echo sprintf("HAVE_SCOUT_CURL: %s\n", $phpinfo['HAVE_SCOUT_CURL']); | ||
echo sprintf("curl instrumented: %s\n", $phpinfo['enabled']); | ||
echo sprintf("curl_exec function exists: %s\n", function_exists('curl_exec') ? 'Yes' : 'No'); | ||
echo sprintf("curl_exec is in instrumented list: %s\n", in_array('curl_exec', scoutapm_list_instrumented_functions()) ? 'Yes' : 'No'); | ||
|
||
scoutapm_enable_instrumentation(true); | ||
|
||
if (function_exists('curl_exec')) { | ||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, "file://" . __FILE__); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
curl_exec($ch); | ||
} | ||
|
||
$calls = scoutapm_get_calls(); | ||
|
||
if (! array_key_exists(0, $calls)) { | ||
echo "curl_exec call recorded: No\n"; | ||
exit; | ||
} | ||
|
||
echo sprintf("%s call recorded: Yes\n", $calls[0]['function']); |
6 changes: 6 additions & 0 deletions
6
.github/test-curl-compilation/expected-curlext-no-libcurl-no.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
HAVE_CURL: No | ||
HAVE_SCOUT_CURL: No | ||
curl instrumented: No | ||
curl_exec function exists: No | ||
curl_exec is in instrumented list: No | ||
curl_exec call recorded: No |
6 changes: 6 additions & 0 deletions
6
.github/test-curl-compilation/expected-curlext-no-libcurl-yes.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
HAVE_CURL: No | ||
HAVE_SCOUT_CURL: Yes | ||
curl instrumented: No | ||
curl_exec function exists: No | ||
curl_exec is in instrumented list: No | ||
curl_exec call recorded: No |
6 changes: 6 additions & 0 deletions
6
.github/test-curl-compilation/expected-curlext-yes-libcurl-no.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
HAVE_CURL: No | ||
HAVE_SCOUT_CURL: No | ||
curl instrumented: No | ||
curl_exec function exists: Yes | ||
curl_exec is in instrumented list: No | ||
curl_exec call recorded: No |
6 changes: 6 additions & 0 deletions
6
.github/test-curl-compilation/expected-curlext-yes-libcurl-yes.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
HAVE_CURL: No | ||
HAVE_SCOUT_CURL: Yes | ||
curl instrumented: Yes | ||
curl_exec function exists: Yes | ||
curl_exec is in instrumented list: Yes | ||
curl_exec call recorded: Yes |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,31 @@ on: | |
pull_request: | ||
|
||
jobs: | ||
curl-compilation-test: | ||
name: "Curl Compile" | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
with_curl_ext: ["yes", "no"] | ||
with_libcurl: ["yes", "no"] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Build the tester tool | ||
run: | | ||
docker build \ | ||
--build-arg WITH_CURL_EXT=${{ matrix.with_curl_ext }} \ | ||
--build-arg WITH_LIBCURL=${{ matrix.with_libcurl }} \ | ||
--file .github/test-curl-compilation/Dockerfile \ | ||
--tag scoutapm_ext_test \ | ||
. | ||
- name: Run the tool | ||
run: | | ||
docker run scoutapm_ext_test > results.txt | ||
cat results.txt | ||
- name: Check the output | ||
run: | | ||
diff .github/test-curl-compilation/expected-curlext-${{ matrix.with_curl_ext }}-libcurl-${{ matrix.with_libcurl }}.txt results.txt | ||
windows-test: | ||
name: "Win PHPT" | ||
defaults: | ||
|
@@ -26,7 +51,7 @@ jobs: | |
- { os: windows-2022, php: "7.1" } | ||
runs-on: ${{matrix.os}} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v3 | ||
- name: Setup PHP SDK | ||
id: setup-php | ||
uses: cmb69/[email protected] | ||
|
@@ -123,7 +148,7 @@ jobs: | |
- "--with-curl" | ||
- "" | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v3 | ||
|
||
- name: "Set ZTS mode, PHP 8+" | ||
if: ${{ matrix.zts-mode == 'zts' && startsWith(matrix.php-version, '8.') }} | ||
|
@@ -184,7 +209,7 @@ jobs: | |
php-version: | ||
- "8.0" | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v3 | ||
- name: Setup PHP with PECL extension | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
|
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
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
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
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
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