Skip to content

Commit efdc636

Browse files
committed
feat(py): flask plugins #538 (#539)
- remove cmake - rename pinpintPy - add testcase for plugins - support macos - add gz for build faster close #538
1 parent 488d371 commit efdc636

File tree

95 files changed

+1447
-1365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1447
-1365
lines changed

.devcontainer/Dockerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ USER root
33
## install developmental env
44
ENV TZ=Asia/Shanghai
55
ENV LC_CTYPE=en_US.UTF-8
6-
ENV LC_ALL=en_US.UTF-8
6+
# ENV LC_ALL=en_US.UTF-8
77
# referr from https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user
88
ARG USERNAME=pinpoint
99
ARG USER_UID=1000
@@ -28,10 +28,11 @@ RUN groupadd --gid $USER_GID $USERNAME \
2828

2929

3030
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
31-
RUN apt update && apt install -y gcc g++ gdb pkg-config libxml2-dev libsqlite3-dev libcurl4-openssl-dev zlib1g-dev make cmake wget autoconf git clangd python3-pip clang-format protobuf-compiler vim
32-
## enable php-7.4
31+
RUN apt update && apt install -y apt-utils gcc g++ gdb pkg-config libxml2-dev libsqlite3-dev libcurl4-openssl-dev zlib1g-dev make cmake wget autoconf git clangd iputils-ping python3 python3.8-venv python3-pip clang-format protobuf-compiler vim
32+
# enable php-7.4
3333
ENV PHP_VESION=php-7.4.33
34-
RUN cd ~ && wget https://www.php.net/distributions/${PHP_VESION}.tar.gz && tar xvf ${PHP_VESION}.tar.gz && cd ${PHP_VESION} && ./configure --prefix=/opt/${PHP_VESION} --enable-fpm --enable-opcache --enable-debug && make -j && make install
34+
COPY ${PHP_VESION}.tar.gz /repo/${PHP_VESION}.tar.gz
35+
RUN cd /repo && tar xvf ${PHP_VESION}.tar.gz && cd ${PHP_VESION} && ./configure --prefix=/opt/${PHP_VESION} --enable-fpm --enable-opcache --enable-debug && make -j && make install
3536
ENV PATH="$PATH:/opt/php/bin/:/opt/php/sbin/"
3637
COPY php.ini /opt/$PHP_VESION/lib
3738

@@ -61,9 +62,9 @@ COPY php.ini /opt/$PHP_VESION/lib
6162

6263

6364
# install golang 1.18
64-
65-
RUN wget https://go.dev/dl/go1.18.10.linux-amd64.tar.gz && rm -rf /usr/local/go && tar -C /usr/local -xzf go1.18.10.linux-amd64.tar.gz
65+
COPY go1.18.10.linux-amd64.tar.gz /repo/go1.18.10.linux-amd64.tar.gz
66+
RUN rm -rf /usr/local/go && cd /repo/ && tar -C /usr/local -xzf go1.18.10.linux-amd64.tar.gz
6667
ENV PATH=$PATH:/usr/local/go/bin
6768
ENV GO_PATH=~/go
6869
ENV PATH=$PATH:/$GO_PATH/bin
69-
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
70+
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

.devcontainer/devcontainer.json

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
{
22
"name": "PINPOINT php Dev",
3-
"dockerFile": "Dockerfile",
4-
"runArgs": [
5-
"--user=pinpoint",
6-
"--cap-add=SYS_PTRACE",
7-
"--cap-add=NET_RAW",
8-
"--cap-add=NET_ADMIN",
9-
"--security-opt=seccomp=unconfined",
10-
"--volume=${env:HOME}:${env:HOME}",
11-
"--volume=/var/run/docker.sock:/var/run/docker.sock",
12-
// "--volume=envoy-build:/build",
13-
"--network=host",
14-
// Uncomment next line if you have devcontainer.env
15-
// "--env-file=.devcontainer/devcontainer.env"
3+
"service": "pinpoint",
4+
"dockerComposeFile": [
5+
"docker-compose.yaml"
166
],
17-
"containerEnv": {
18-
"ENVOY_SRCDIR": "${containerWorkspaceFolder}",
19-
},
7+
"workspaceFolder": "/workspace",
208
"settings": {
219
"terminal.integrated.shell.linux": "/bin/bash",
2210
"bazel.buildifierFixOnFormat": true,
@@ -33,22 +21,24 @@
3321
},
3422
"remoteUser": "pinpoint",
3523
"containerUser": "pinpoint",
36-
"postCreateCommand": ".devcontainer/setup.sh",
24+
// "postCreateCommand": ".devcontainer/setup.sh",
3725
"extensions": [
38-
"zxh404.vscode-proto3",
39-
"llvm-vs-code-extensions.vscode-clangd",
40-
"vadimcn.vscode-lldb",
41-
"webfreak.debug",
42-
"ms-python.python",
43-
"xaver.clang-format",
44-
"zxh404.vscode-proto3",
45-
"Gruntfuggly.todo-tree",
46-
"msyrus.go-doc",
47-
"golang.go",
48-
"bierner.github-markdown-preview",
49-
"bierner.markdown-emoji",
50-
"ms-vscode.cmake-tools",
51-
"matepek.vscode-catch2-test-adapter",
52-
"adam-bender.commit-message-editor"
53-
]
26+
"zxh404.vscode-proto3",
27+
"llvm-vs-code-extensions.vscode-clangd",
28+
"vadimcn.vscode-lldb",
29+
"webfreak.debug",
30+
"ms-python.python",
31+
"xaver.clang-format",
32+
"zxh404.vscode-proto3",
33+
"Gruntfuggly.todo-tree",
34+
"msyrus.go-doc",
35+
"golang.go",
36+
"bierner.github-markdown-preview",
37+
"bierner.markdown-emoji",
38+
"ms-vscode.cmake-tools",
39+
"matepek.vscode-catch2-test-adapter",
40+
"adam-bender.commit-message-editor",
41+
"formulahendry.vscode-mysql",
42+
"ms-python.autopep8"
43+
]
5444
}

.devcontainer/docker-compose.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
version: '3.9'
2+
3+
services:
4+
dev-mysql:
5+
image: mysql:5.7
6+
restart: always
7+
container_name: dev-mysql
8+
hostname: dev-mysql
9+
environment:
10+
MYSQL_ROOT_PASSWORD: 'password'
11+
ports:
12+
- '3306:3306'
13+
expose:
14+
- '3306'
15+
volumes:
16+
- ..:/workspace:cached
17+
redis:
18+
image: redis:alpine
19+
command: redis-server --port 6379
20+
container_name: redis_boot
21+
hostname: redis_boot
22+
labels:
23+
- "name=redis"
24+
- "mode=standalone"
25+
ports:
26+
- 6379:6379
27+
28+
pinpoint:
29+
container_name: pinpoint
30+
command: sleep infinity
31+
hostname: pinpoint
32+
build:
33+
context: ./
34+
dockerfile: Dockerfile
35+
# args:
36+
volumes:
37+
- ..:/workspace:cached
38+
- /var/run/docker.sock:/var/run/docker.sock
39+
# - ${env:HOME}:/workspace
40+
security_opt:
41+
- seccomp=unconfined
42+
cap_add:
43+
- SYS_PTRACE
44+
- NET_RAW
45+
- NET_ADMIN
46+
user: pinpoint
47+
48+
49+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:5e05400e4c79ef5394424c0eff5b9141cb782da25f64f79d54c98af0a37f8d49
3+
size 141977100

.devcontainer/php-7.4.33.tar.gz

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:5a2337996f07c8a097e03d46263b5c98d2c8e355227756351421003bea8f463e
3+
size 16869345

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.devcontainer/*.gz filter=lfs diff=lfs merge=lfs -text
2+
.devcontainer/go1.18.10.linux-amd64.tar.gz filter=lfs diff=lfs merge=lfs -text
3+
.devcontainer/php-7.4.33.tar.gz filter=lfs diff=lfs merge=lfs -text

.github/workflows/build-wheels.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@ name: build-wheels
33
on:
44
workflow_dispatch:
55
inputs:
6+
release-testpypi:
7+
description: Do you want to release to test-pypi
8+
required: true
9+
default: "true"
610
release:
7-
description: Do you want to release to pipy
11+
description: Do you want to release to pypi
812
required: true
913
default: "false"
1014

1115
jobs:
1216
build_wheels_pypitest:
17+
if: ${{ github.event.inputs.release-testpypi }} == "true"
1318
name: Build wheels on ${{ matrix.os }}
1419
runs-on: ${{ matrix.os }}
1520
strategy:
@@ -58,7 +63,6 @@ jobs:
5863
publish-pypitest:
5964
needs: build_wheels_pypitest
6065
runs-on: ubuntu-latest
61-
if: ${{ github.event.inputs.release }} == "true"
6266
steps:
6367
- uses: actions/download-artifact@v3
6468
with:
@@ -78,6 +82,7 @@ jobs:
7882
repository_url: https://test.pypi.org/legacy/
7983

8084
build_wheels:
85+
if: ${{ github.event.inputs.release }} == "true"
8186
name: Build wheels on ${{ matrix.os }}
8287
runs-on: ${{ matrix.os }}
8388
strategy:
@@ -121,7 +126,6 @@ jobs:
121126
publish:
122127
needs: build_wheels
123128
runs-on: ubuntu-latest
124-
if: ${{ github.event.inputs.release }} == "true"
125129
steps:
126130
- uses: actions/download-artifact@v3
127131
with:

.github/workflows/main.yml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,6 @@ jobs:
7777
php-versions: ["7.0"]
7878
steps:
7979
- uses: actions/checkout@v2
80-
# - name: set mysql
81-
# run: |
82-
# sudo service mysql start
83-
# sudo mysql --host='127.0.0.1' --user='root' --password='root' < '/home/runner/work/pinpoint-c-agent/pinpoint-c-agent/testapps/PHP/tests/script.sql'
84-
# - name: set redis
85-
# run: |
86-
# sudo apt-get install redis-server
8780
- uses: shivammathur/setup-php@v2
8881
with:
8982
php-version: ${{ matrix.php-versions }}
@@ -117,13 +110,13 @@ jobs:
117110
- uses: actions/setup-python@v2
118111
with:
119112
python-version: ${{ matrix.python-version }}
120-
- run: |
121-
pip install -r requirements.txt
122-
python setup.py install || echo "failed, but ignore"
123-
# nosetests does not support python3 anymore
124-
# nosetests src/PY/test --ignore-files="TestCoroutines.*"
125-
python -m unittest discover -s src/PY/test -p 'Test*.py'
126-
113+
- name: run unittest
114+
run: |
115+
# ref https://github.com/pypa/setuptools/issues/3198
116+
pip install -e .
117+
python -m unittest discover -s src/PY/test
118+
pip install -r plugins/PY/requirements.txt
119+
python -m unittest discover -s plugins/PY/pinpointPy
127120
Collector-agent:
128121
strategy:
129122
matrix:
@@ -145,8 +138,4 @@ jobs:
145138

146139
- run: |
147140
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
148-
# cd collector-agent
149-
# go mod download
150-
# go build
151-
# go test ./... -v
152141
cd collector-agent && make && go test ./... -v

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ aclocal.m4
6969
src/PHP/pinpoint_php.dep
7070
testapps/PHP/composer.phar
7171
collector-agent/collector-agent
72-
common/include/common.h
7372
.cache
7473
compile_commands.json
7574
wheelhouse/

0 commit comments

Comments
 (0)