Skip to content

Commit

Permalink
[PHP] support windows/macOS (#657)
Browse files Browse the repository at this point in the history
* test setup-php
* Windows (#67)
* test windows
* test
* add pinpoint_php_files.txt
* add pinpoint_php_files.txt
* remove tar
* update move
* use Move-Item
* enhance for linux
* test case for win32
* fix header out of order
* fix tick++
* support x86
* release test
* remove "and" problem in windows
* fix  LNK2001
* test package
* update license Apache 2.0
* support macOs (#68)
* support macOs
- build problems
* support pecl install
* add dl_cd_pinpoint
* update doc
* update package.xml
* add windows
* fix package
* update doc
  • Loading branch information
eeliu authored Aug 1, 2024
1 parent 49b9bab commit d0de218
Show file tree
Hide file tree
Showing 71 changed files with 5,045 additions and 133 deletions.
168 changes: 149 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: CI

on: [pull_request, workflow_dispatch, push]
on:
pull_request:
workflow_dispatch:
push:
tags:
- "v*.*.*"

env:
MODULE_PAK: pinpoint_php@${{ github.head_ref || github.ref_name }}
MODULE_PAK: pinpoint_php-${{ github.head_ref || github.ref_name }}

jobs:
cpp:
Expand Down Expand Up @@ -69,10 +74,12 @@ jobs:
--log-file=valgrind-out.txt \
./bin/TestCommon
- name: Archive docs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: valgrind-out
path: common/build/valgrind-out.txt
retention-days: 5
if-no-files-found: error

PHP:
runs-on: ubuntu-latest
Expand All @@ -97,24 +104,142 @@ jobs:
# if: always()
run: ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" down php-compatible

PHP-MacOS:
runs-on: macos-latest
needs: cpp
strategy:
matrix:
php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"]
ts: ["ts","nts"]
env:
SKIP_MACOS_ACTION: true
steps:
- uses: actions/checkout@v2
with:
submodules: "true"
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
env:
phpts: ${{ matrix.ts }}
- name: build pinpoint_php
run: phpize && ./configure && make
- name: make test
run: make test TESTS="--show-diff tests_macos"

PHP-Win-2019:
runs-on: windows-2019
needs: cpp-windows
strategy:
matrix:
php-versions: [ "7.4", "7.3", "7.2","7.1","8.0", "8.1", "8.2", "8.3"]
arch: [ "x86" ,"x64"]
ts: [ "ts", "nts" ]
env:
SKIP_WINDOWS_ACTION: true
steps:
- uses: actions/checkout@v2
- id: setup-php-sdk
uses: php/setup-php-sdk@v0.8
with:
version: ${{ matrix.php-versions }}
arch: ${{ matrix.arch }}
ts: ${{ matrix.ts }}
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
toolset: ${{steps.setup-php-sdk.outputs.toolset}}

- name: build pinpoint_php on windows
run: |
php -m
php -v
mkdir output
phpize
./configure.bat --enable-pinpoint_php --enable-debug-pack --enable-object-out-dir=output --with-prefix=${{steps.setup-php-sdk.outputs.prefix}}
nmake
- name: test pinpoint_php on windows
run: |
# from https://github.com/php/setup-php-sdk/issues/7
nmake test TESTS="--show-diff tests_win32"
echo "pinpoint_php_win32_pack_name=${{ env.MODULE_PAK }}-${{ matrix.php-versions }}-${{ matrix.ts }}-${{steps.setup-php-sdk.outputs.vs}}-${{ matrix.arch }}" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: package
run: |
mkdir _package_
if (Test-Path -Path output/Release/ -PathType Container) {
cp output/Release/php_pinpoint_php.dll _package_
cp output/Release/php_pinpoint_php.pdb _package_
cp output/Release/php_pinpoint_php.lib _package_
}
if (Test-Path -Path output/Release_TS/ -PathType Container) {
cp output/Release_TS/php_pinpoint_php.dll _package_
cp output/Release_TS/php_pinpoint_php.pdb _package_
cp output/Release_TS/php_pinpoint_php.lib _package_
}
cp NOTICE _package_
cp README.md _package_
cp CHANGES-PHP.md _package_
cp LICENSE _package_
Compress-Archive -Path _package_/* ${{ env.pinpoint_php_win32_pack_name }}.zip
- uses: actions/upload-artifact@v4
with:
name: ${{ env.pinpoint_php_win32_pack_name }}
path: ${{ env.pinpoint_php_win32_pack_name }}.zip
retention-days: 5
if-no-files-found: error

PHP-Release-Win32-Package:
needs: [ PHP-Win-2019, pack_php_module]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: pinpoint-artifact
pattern: pinpoint_php*
merge-multiple: true
- run: ls -R pinpoint-artifact

- name: Release php_package
id: rel_php_pak
uses: softprops/action-gh-release@v2
with:
files: pinpoint-artifact/*

pack_php_module:
runs-on: ubuntu-latest
needs: PHP
steps:
- uses: actions/checkout@v2
- name: Package pinpoint_php
id: pack
run: |
tar -czf ${{ env.MODULE_PAK }} common/ src/PHP config.m4 tests LICENSE
md5=($(md5sum ${{ env.MODULE_PAK }} ))
PACK_NAME=${{ env.MODULE_PAK }}-${md5}-$(date '+%Y-%m-%d').tar.gz
mv ${{ env.MODULE_PAK }} $PACK_NAME
echo "PACK=$PACK_NAME" >> $GITHUB_OUTPUT
- name: Setup PHP without composer
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'

- name: pecl package
run: pecl package

# - name: Package pinpoint_php
# id: pack
# run: |
# tar -czf ${{ env.MODULE_PAK }} common/ config.m4 tests LICENSE pinpoint_php.cpp php_pinpoint_php.h
# md5=($(md5sum ${{ env.MODULE_PAK }} ))
# pinpoint_php_win32_pack_name=${{ env.MODULE_PAK }}-${md5}-$(date '+%Y-%m-%d').tar.gz
# mv ${{ env.MODULE_PAK }} $pinpoint_php_win32_pack_name
# echo "PACK=$pinpoint_php_win32_pack_name" >> $GITHUB_OUTPUT

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ env.MODULE_PAK }}
path: ${{ steps.pack.outputs.PACK }}
name: pinpoint_php.tgz
path: pinpoint_php*.tgz
retention-days: 5
if-no-files-found: error

Python:
strategy:
Expand All @@ -133,8 +258,8 @@ jobs:
# ref https://github.com/pypa/setuptools/issues/3198
pip install -e .
python -m unittest discover -s src/PY/test
python-plugins:
# timeout-minutes: 20
needs: Python
runs-on: ubuntu-latest
steps:
Expand All @@ -153,27 +278,32 @@ jobs:
- name: Stop containers
# if: always()
run: ./docker-compose-linux-x86_64 -f "testapps/compose.yaml" down python-plugins

Collector-agent:
strategy:
matrix:
go-version: [1.18.x]
os: [ubuntu-latest]
os: [ubuntu-latest,windows-latest,macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v2
with:
submodules: "true"

- name: Setup protoc
uses: arduino/setup-protoc@v2.1.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- run: |
- name: run unittest
run: |
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
export PATH="$PATH:$(go env GOPATH)/bin"
cd collector-agent && make && go test ./... -v
# export PATH="$PATH:$(go env GOPATH)/bin"
cd collector-agent && go mod tidy && go test ./... -v
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Package pinpoint_php
id: pack
run: |
tar -czf ${{ env.MODULE_PAK }} common/ src/PHP config.m4 tests LICENSE
tar -czf ${{ env.MODULE_PAK }} common/ pinpoint_php.cpp php_pinpoint_php.h config.m4 tests LICENSE
md5=($(md5sum ${{ env.MODULE_PAK }} ))
PACK_NAME=${{ env.MODULE_PAK }}-${md5}-$(date '+%Y-%m-%d').tar.gz
mv ${{ env.MODULE_PAK }} $PACK_NAME
Expand Down
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ test.php
.libs/
.libs/
aclocal.m4
src/PHP/pinpoint_php.dep
pinpoint_php.dep
collector-agent/collector-agent
.cache
compile_commands.json
Expand All @@ -78,4 +78,10 @@ wheelhouse/
.vs
*.dep
downloads
testapps/java_call_app/target
testapps/java_call_app/target
x64
x86
output
config.nice.bat
configure.bat
configure.js
5 changes: 5 additions & 0 deletions src/PHP/CHANGES.md → CHANGES-PHP.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.5.3 2024-07-31
- build on win32
- build on macos
- support SendSpanTimeOutMs=-1

## 0.5.2 2024-05-30
- add pinpoint_get_caller_arg

Expand Down
22 changes: 13 additions & 9 deletions DOC/PHP/Readme-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@

### 依赖组件

Dependency|Version| More
---|----|----
PHP| php `7+`|
GCC| GCC `4.7+`| C++11
*inux|| `windows is on the way`
pinpoint| `2.0+`|
composer| | class can be automatic pinpoint-cut
collector-agent| [installed ?](../collector-agent/readme.md)
| Dependency | Version | More |
| ------------------- | ------------------------------------------- | ----------------------------------- |
| PHP | php `7+` |
| *inux/windows/macOs | | windows is released |
| pinpoint | `2.0+` |
| composer | | class can be automatic pinpoint-cut |
| collector-agent | [installed ?](../collector-agent/readme.md) |

### 安装步骤

1. 安装 `ext-pinpoint_php` 模块

curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/v0.6.0/install_pinpoint_php.sh | sh
`pecl install pinpoint_php`
or
`curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/latest/install_pinpoint_php.sh | sh`

> On windows: download .dll from https://pecl.php.net/package/pinpoint_php or https://github.com/pinpoint-apm/pinpoint-c-agent/releases/latest

2. 检查下你的配置文件 pinpoint_php.ini

Expand Down
22 changes: 13 additions & 9 deletions DOC/PHP/Readme-KR.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@

### 요구

디펜던시 | 버전 | 부가
---|----|----
PHP| php `7+`|
GCC| GCC `4.7+`| C++11
*inux|| `windows is on the way`
pinpoint| `2.0+`|
composer| | class can be automatic pinpoint-cut
collector-agent| [installed ?](../collector-agent/readme.md)
| 디펜던시 | 버전 | 부가 |
| ------------------- | ------------------------------------------- | ----------------------------------- |
| PHP | php `7+` |
| *inux/windows/macOs | | windows is released |
| pinpoint | `2.0+` |
| composer | | class can be automatic pinpoint-cut |
| collector-agent | [installed ?](../collector-agent/readme.md) |

### 설치 스텝

1. `ext-pinpoint_php` 모듈 설치
curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/v0.6.0/install_pinpoint_php.sh | sh

`pecl install pinpoint_php`
or
`curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/latest/install_pinpoint_php.sh | sh`

> On windows: download .dll from https://pecl.php.net/package/pinpoint_php or https://github.com/pinpoint-apm/pinpoint-c-agent/releases/latest
2. pinpoint_php.ini 설정 파일 확인
```ini
Expand Down
21 changes: 12 additions & 9 deletions DOC/PHP/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@

### Requirement

Dependency|Version| More
---|----|----
PHP| php `7+`|
GCC| GCC `4.7+`| C++11
*inux|| `windows is on the way`
pinpoint| `2.0+`|
composer| | class can be automatic pinpoint-cut
collector-agent| [installed ?](../collector-agent/readme.md)
| Dependency | Version | More |
| ------------------- | ------------------------------------------- | ----------------------------------- |
| PHP | php `7+` |
| *inux/windows/macOs | | windows is released |
| pinpoint | `2.0+` |
| composer | | class can be automatic pinpoint-cut |
| collector-agent | [installed ?](../collector-agent/readme.md) |

### Installation

#### Steps
1. Install `ext-pinpoint_php`

curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/v0.6.0/install_pinpoint_php.sh | sh
`pecl install pinpoint_php`
or
`curl -sL https://github.com/pinpoint-apm/pinpoint-c-agent/releases/download/latest/install_pinpoint_php.sh | sh`

> On windows: download .dll from https://pecl.php.net/package/pinpoint_php or https://github.com/pinpoint-apm/pinpoint-c-agent/releases/latest
2. Check your pinpoint_php.ini is right

Expand Down
6 changes: 6 additions & 0 deletions common/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v0.5.3 2024-07-30
- support unittest in macos

## v0.5.2 2024-07-26
- fix `tick++`

## v0.5.1 2024-05-07
- fix logging bug
- add EXP_V2 protocol 2024-04-30
Expand Down
2 changes: 1 addition & 1 deletion common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.13)
project(pinpoint VERSION 0.5.1 DESCRIPTION "pinpoint common library")
project(pinpoint VERSION 0.5.3 DESCRIPTION "pinpoint common library")

set(CMAKE_CXX_STANDARD 11)

Expand Down
Loading

0 comments on commit d0de218

Please sign in to comment.