Skip to content

Commit 40a15b2

Browse files
authored
Initial import of OpenTelemetry PHP distro with native & php parts (#7)
* Native part builds and passes tests * PHP-side bootstrapper and helper classes * Fixed module name and ini config namespace * Package generator * Scripts for building native & PHP dependencies * Semconv generator * Generated composer lock files * Build workflows * Enable qemu for arm64 build
1 parent a74d4ce commit 40a15b2

File tree

479 files changed

+220055
-0
lines changed

Some content is hidden

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

479 files changed

+220055
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
3+
name: build-arch-matrix-generator
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
build_arch:
9+
required: true
10+
type: string
11+
default: 'x86_64'
12+
outputs:
13+
matrix-combinations:
14+
description: "Matrix of architectures to build for"
15+
value: ${{ jobs.setup-build-matrix.outputs.matrix-combinations }}
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
setup-build-matrix:
22+
name: setup-build-matrix
23+
runs-on: ubuntu-latest
24+
env:
25+
SELECTED_ARCH: ${{ inputs.build_arch }}
26+
outputs:
27+
matrix-combinations: ${{ steps.setup-matrix-combinations.outputs.matrix-combinations }}
28+
steps:
29+
- name: Create build matrix
30+
id: setup-matrix-combinations
31+
run: |
32+
MATRIX=''
33+
if [ "${SELECTED_ARCH}" == "x86_64" ] || [ "${SELECTED_ARCH}" == "all" ]; then
34+
echo "${SELECTED_ARCH} selected. Adding x86_64"
35+
MATRIX+='{"arch": "linux-x86-64", "goarch": "amd64", "packages": "deb rpm"}, {"arch": "linuxmusl-x86-64", "goarch": "amd64", "packages": "apk"},'
36+
fi
37+
if [ "${SELECTED_ARCH}" == "arm64" ] || [ "${SELECTED_ARCH}" == "all" ]; then
38+
echo "${SELECTED_ARCH} selected. Adding arm64"
39+
MATRIX+='{"arch": "linux-arm64", "goarch": "arm64", "packages": "deb rpm"},{"arch": "linuxmusl-arm64", "goarch": "arm64", "packages": "apk"},'
40+
fi
41+
echo "matrix-combinations={\"include\":[$MATRIX]}"
42+
43+
echo "matrix-combinations={\"include\":[$MATRIX]}" >> $GITHUB_OUTPUT

.github/workflows/build-native.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
3+
# Runs the build based on the provided files in test.yml
4+
name: build-native
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
build_arch:
10+
required: false
11+
type: string
12+
default: 'x86_64'
13+
workflow_dispatch:
14+
inputs:
15+
build_arch:
16+
type: choice
17+
description: Build architecture
18+
default: 'x86_64'
19+
options:
20+
- all
21+
- x86_64
22+
- arm64
23+
24+
permissions:
25+
contents: read
26+
27+
jobs:
28+
setup-build-matrix:
29+
uses: ./.github/workflows/build-arch-matrix-generator.yml
30+
with:
31+
build_arch: ${{ inputs.build_arch }}
32+
33+
build-native:
34+
name: build-agent-library
35+
runs-on: 'ubuntu-latest'
36+
needs: setup-build-matrix
37+
timeout-minutes: 300
38+
strategy:
39+
fail-fast: false
40+
matrix: ${{ fromJson(needs.setup-build-matrix.outputs.matrix-combinations) }}
41+
env:
42+
BUILD_ARCHITECTURE: ${{ matrix.arch }}
43+
steps:
44+
- uses: actions/checkout@v6
45+
- if: ${{ matrix.goarch == 'arm64' }}
46+
uses: docker/setup-qemu-action@v3
47+
with:
48+
platforms: arm64
49+
- name: Build
50+
run: |
51+
uname -a
52+
echo "Detected CPUs: $(nproc)"
53+
echo "User: $(id -u):$(id -g)"
54+
echo "PWD: ${PWD}"
55+
echo "Arch: ${BUILD_ARCHITECTURE}"
56+
./tools/build/build_native.sh --build_architecture ${BUILD_ARCHITECTURE}
57+
- uses: actions/upload-artifact@v5
58+
with:
59+
name: build-native-${{ matrix.arch }}
60+
path: |
61+
prod/native/_build/${{ matrix.arch }}-release/extension/code/opentelemetry_php_distro_*.so
62+
prod/native/_build/${{ matrix.arch }}-release/extension/code/opentelemetry_php_distro_*.debug
63+
prod/native/_build/${{ matrix.arch }}-release/loader/code/opentelemetry_php_distro_loader.so
64+
prod/native/_build/${{ matrix.arch }}-release/loader/code/opentelemetry_php_distro_loader.debug
65+
prod/native/_build/${{ matrix.arch }}-release/phpbridge_extension/code/phpbridge_*.so
66+
prod/native/_build/${{ matrix.arch }}-release/phpbridge_extension/code/phpbridge_*.debug
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
3+
# Runs the build based on the provided files in test.yml
4+
name: build-packages
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
build_arch:
10+
required: false
11+
type: string
12+
default: 'x86_64'
13+
workflow_dispatch:
14+
inputs:
15+
build_arch:
16+
type: choice
17+
description: Build architecture
18+
default: 'x86_64'
19+
options:
20+
- all
21+
- x86_64
22+
- arm64
23+
24+
permissions:
25+
contents: read
26+
27+
jobs:
28+
setup-build-matrix:
29+
uses: ./.github/workflows/build-arch-matrix-generator.yml
30+
with:
31+
build_arch: ${{ inputs.build_arch }}
32+
33+
build-packages:
34+
name: build-packages
35+
runs-on: 'ubuntu-latest'
36+
needs: setup-build-matrix
37+
timeout-minutes: 300
38+
strategy:
39+
fail-fast: false
40+
matrix: ${{ fromJson(needs.setup-build-matrix.outputs.matrix-combinations) }}
41+
env:
42+
BUILD_ARCHITECTURE: ${{ matrix.arch }}
43+
steps:
44+
- uses: actions/checkout@v6
45+
- if: ${{ matrix.goarch == 'arm64' }}
46+
uses: docker/setup-qemu-action@v3
47+
with:
48+
platforms: arm64
49+
- uses: actions/download-artifact@v6
50+
with:
51+
name: build-native-${{ matrix.arch }}
52+
path: prod/native/_build/${{ matrix.arch }}-release/
53+
- uses: actions/download-artifact@v6
54+
with:
55+
name: php-dependencies
56+
- name: Build packages
57+
run: |
58+
source "./tools/read_properties.sh"
59+
read_properties project.properties PROJECT_PROPERTIES
60+
61+
./tools/build/build_packages.sh --package_version ${PROJECT_PROPERTIES_VERSION} --build_architecture ${{ matrix.arch }} --package_goarchitecture ${{ matrix.goarch }} --package_types '${{ matrix.packages }}' --package_sha '${{ github.sha }}'
62+
- uses: actions/upload-artifact@v5
63+
with:
64+
name: packages-${{ matrix.arch }}
65+
path: |
66+
build/packages/*
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
3+
name: build-php-deps
4+
5+
on:
6+
workflow_call: ~
7+
workflow_dispatch: ~
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build-php-deps:
14+
name: build-php-dependencies
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 300
17+
strategy:
18+
fail-fast: false
19+
env:
20+
COMPOSER_ALLOW_SUPERUSER: 1
21+
steps:
22+
- uses: actions/checkout@v6
23+
- name: Build PHP dependencies
24+
run: |
25+
source ./tools/read_properties.sh
26+
read_properties project.properties PROJECT_PROPERTIES
27+
PHP_VERSIONS=${PROJECT_PROPERTIES_SUPPORTED_PHP_VERSIONS//[()]/}
28+
./tools/build/build_php_deps.sh --php_versions "${PHP_VERSIONS}"
29+
- uses: actions/upload-artifact@v5
30+
with:
31+
name: php-dependencies
32+
path: |
33+
prod/php/vendor_*
34+
prod/php/OpenTelemetry/Distro/PhpPartVersion.php
35+
prod/php/OpenTelemetry/Distro/Log/LogFeature.php
36+
NOTICE

.github/workflows/build.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
build_arch:
7+
required: true
8+
type: string
9+
default: 'all'
10+
pull_request: ~
11+
push:
12+
branches:
13+
- main
14+
workflow_dispatch: ~
15+
16+
permissions:
17+
contents: read
18+
19+
## Concurrency only allowed in the main branch.
20+
## So old builds running for old commits within the same Pull Request are cancelled
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
24+
25+
jobs:
26+
build-native:
27+
uses: ./.github/workflows/build-native.yml
28+
with:
29+
build_arch: all
30+
31+
tests-phpt:
32+
needs:
33+
- build-native
34+
uses: ./.github/workflows/test-phpt.yml
35+
with:
36+
build_arch: all
37+
38+
build-php-deps:
39+
uses: ./.github/workflows/build-php-deps.yml
40+
41+
build-packages:
42+
needs:
43+
- build-native
44+
- build-php-deps
45+
uses: ./.github/workflows/build-packages.yml
46+
with:
47+
build_arch: all
48+
49+
# The very last job to report whether the Workflow passed.
50+
# This will act as the Branch Protection gatekeeper
51+
ci:
52+
needs:
53+
- tests-phpt
54+
- build-packages
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: report
58+
run: echo "CI workflow passed"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
3+
# Generates list of supported PHP versions by reading supported_php_versions property in ./opentelemetry-php-distro
4+
name: generate-php-versions
5+
6+
on:
7+
workflow_call:
8+
outputs:
9+
php-versions:
10+
description: "Generated list of supported PHP versions"
11+
value: ${{ jobs.generate-php-versions.outputs.php-versions }}
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
generate-php-versions:
18+
name: generate-php-versions
19+
timeout-minutes: 5
20+
runs-on: ubuntu-latest
21+
outputs:
22+
php-versions: ${{ steps.generate.outputs.php-versions }}
23+
steps:
24+
- uses: actions/checkout@v6
25+
- id: generate
26+
run: |
27+
source ./tools/read_properties.sh
28+
read_properties opentelemetry-php-distro PROJECT_PROPERTIES
29+
PHP_VERSIONS=${PROJECT_PROPERTIES_SUPPORTED_PHP_VERSIONS//[()]/}
30+
echo "PHP_VERSIONS: ${PHP_VERSIONS}"
31+
PHP_VERSIONS_JSON=$(echo -n ${PHP_VERSIONS} | jq --raw-input --slurp --compact-output 'split(" ") | map(select(length > 0)) | map({ "php-version": . } )')
32+
echo "php-versions={\"include\":${PHP_VERSIONS_JSON}}"
33+
echo "php-versions={\"include\":${PHP_VERSIONS_JSON}}" >> $GITHUB_OUTPUT

.github/workflows/test-phpt.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
3+
name: test-phpt
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
build_arch:
9+
required: false
10+
type: string
11+
default: 'x86_64'
12+
workflow_dispatch:
13+
inputs:
14+
build_arch:
15+
type: choice
16+
description: Build architecture
17+
default: 'x86_64'
18+
options:
19+
- all
20+
- x86_64
21+
- arm64
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
setup-build-matrix:
28+
uses: ./.github/workflows/build-arch-matrix-generator.yml
29+
with:
30+
build_arch: ${{ inputs.build_arch }}
31+
32+
test-phpt:
33+
name: test-phpt
34+
runs-on: 'ubuntu-latest'
35+
needs: setup-build-matrix
36+
timeout-minutes: 300
37+
strategy:
38+
fail-fast: false
39+
matrix: ${{ fromJson(needs.setup-build-matrix.outputs.matrix-combinations) }}
40+
env:
41+
BUILD_ARCHITECTURE: ${{ matrix.arch }}
42+
steps:
43+
- uses: actions/checkout@v6
44+
- uses: actions/download-artifact@v6
45+
with:
46+
name: build-native-${{ matrix.arch }}
47+
path: prod/native/_build/${{ matrix.arch }}-release/
48+
- if: ${{ matrix.goarch == 'arm64' }}
49+
uses: docker/setup-qemu-action@v3
50+
with:
51+
platforms: arm64
52+
- name: Run phpt tests
53+
run: |
54+
uname -a
55+
echo "Arch: ${BUILD_ARCHITECTURE}"
56+
source ./tools/read_properties.sh
57+
read_properties project.properties PROJECT_PROPERTIES
58+
PHP_VERSIONS=${PROJECT_PROPERTIES_SUPPORTED_PHP_VERSIONS//[()]/}
59+
./tools/build/test_phpt.sh --build_architecture ${BUILD_ARCHITECTURE} --results_path ${PWD}/build/test_phpt_results --php_versions "${PHP_VERSIONS}"
60+
- uses: actions/upload-artifact@v5
61+
if: failure()
62+
with:
63+
name: test-phpt-failures-${{ matrix.arch }}
64+
path: |
65+
build/test_phpt_results/*

0 commit comments

Comments
 (0)