Skip to content

Commit

Permalink
Implemented script to insert and verify license in source header. Mov…
Browse files Browse the repository at this point in the history
…ed workflows implementation to scripts (#33)

* Implemented scripts to insert or replace and verify license headers in source code files
* Added and updated license headers in native part
* Added source code license check into workflows, reorganized workflows into tools/build scripts
  • Loading branch information
intuibase authored Jun 4, 2024
1 parent c0b2b7f commit 5c9c1ad
Show file tree
Hide file tree
Showing 102 changed files with 1,922 additions and 175 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ jobs:
run: |
uname -a
echo "Detected CPUs: $(nproc)"
echo "User: $(id -u):$(id -g)}"
echo "User: $(id -u):$(id -g)"
echo "PWD: ${PWD}"
echo "Arch: ${BUILD_ARCHITECTURE}"
docker run --rm -t -u : -v ${PWD}:/source -w /source/prod/native elasticobservability/apm-agent-php-dev:native-build-gcc-12.2.0-${BUILD_ARCHITECTURE}-0.0.2 sh -c "cmake --preset ${BUILD_ARCHITECTURE}-release && cmake --build --preset ${BUILD_ARCHITECTURE}-release && ctest --preset ${BUILD_ARCHITECTURE}-release --verbose"
./tools/build/build_native.sh --build_architecture ${BUILD_ARCHITECTURE}
- uses: actions/upload-artifact@v4
with:
name: build-native-${{ matrix.arch }}
Expand Down
29 changes: 1 addition & 28 deletions .github/workflows/build-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,7 @@ jobs:
name: php-dependencies
- name: Build packages
run: |
mkdir -p "${PWD}/build/packages"
packages=( ${{ matrix.packages }} )
for pkg in "${packages[@]}"
do
docker run --rm \
-e ELASTIC_OTEL_PHP_VERSION=1.0.0 \
-e ELASTIC_OTEL_PHP_PLATFORM="${{ matrix.arch }}" \
-e ELASTIC_OTEL_PHP_ARCH="${{ matrix.goarch }}" \
-e ELASTIC_OTEL_PHP_GIT_SHA=$( git rev-parse HEAD || echo "unknown") \
-v ${PWD}:/source \
-w /source/packaging goreleaser/nfpm package -f nfpm.yaml -t "/source/build/packages" -p ${pkg} | tee /tmp/nfpm_output.txt
PKG_FILENAME=$(grep "created package: " /tmp/nfpm_output.txt | sed 's/^.*: \/source\/build\/packages\///')
# create sha512 file
pushd "${PWD}/build/packages"
md5sum "${PKG_FILENAME}" >"${PKG_FILENAME}".sha512
popd
done
echo "Creating debug symbols artifacts"
DBGSYM="${PWD}/build/packages/elastic-otel-php-debugsymbols-${{ matrix.arch }}.tar.gz"
pushd prod/native/_build/${{ matrix.arch }}-release
tar --transform 's/.*\///g' -zcvf ${DBGSYM} extension/code/*.debug loader/code/*.debug
popd
pushd "${PWD}/build/packages"
md5sum ${DBGSYM} >${DBGSYM}.sha512
popd
./tools/build/build_packages.sh --package_version 1.0.0 --build_architecture ${{ matrix.arch }} --package_goarchitecture ${{ matrix.goarch }} --package_types '${{ matrix.packages }}' --package_sha '${{ github.sha }}'
- uses: actions/upload-artifact@v4
with:
name: packages-${{ matrix.arch }}
Expand Down
22 changes: 1 addition & 21 deletions .github/workflows/build-php-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build PHP dependencies
run: |
uname -a
PHP_VERSIONS=( 80 81 82 83 )
for PHP_VERSION in "${PHP_VERSIONS[@]}"
do
mkdir -p "prod/php/vendor_${PHP_VERSION}"
echo "This project depends on folliwng packages for PHP ${PHP_VERSION:0:1}.${PHP_VERSION:1:1}" >>NOTICE
docker run --rm \
-v ${PWD}:/sources \
-v ${PWD}/prod/php/vendor_${PHP_VERSION}:/sources/vendor \
-w /sources \
php:${PHP_VERSION:0:1}.${PHP_VERSION:1:1}-cli sh -c "apt-get update && apt-get install -y unzip && curl -sS https://getcomposer.org/installer | php -- --filename=composer --install-dir=/usr/local/bin && composer --ignore-platform-req=ext-opentelemetry --ignore-platform-req=ext-otel_instrumentation --no-dev install && php /sources/packaging/notice_generator.php >>/sources/NOTICE"
rm composer.lock
done
run: ./tools/build/build_php_deps.sh --php_versions '80 81 82 83'
- uses: actions/upload-artifact@v4
with:
name: php-dependencies
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
build-php-deps:
uses: ./.github/workflows/build-php-deps.yml

test-sources-license:
uses: ./.github/workflows/test-sources-license.yml

build-packages:
needs:
- build-native
Expand All @@ -52,7 +55,6 @@ jobs:
needs:
- build-native
uses: ./.github/workflows/test-phpt.yml


# The very last job to report whether the Workflow passed.
# This will act as the Branch Protection gatekeeper
Expand Down
27 changes: 2 additions & 25 deletions .github/workflows/test-phpt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,11 @@ jobs:
run: |
uname -a
echo "Arch: ${BUILD_ARCHITECTURE}"
pushd prod/native/extension/phpt
mkdir ${PWD}/results
PHP_VERSIONS=( 80 81 82 83 )
for PHP_VERSION in "${PHP_VERSIONS[@]}"
do
./run.sh -b ${BUILD_ARCHITECTURE} -p ${PHP_VERSION} -f ${PWD}/results/phpt-${PHP_VERSION}.tar.gz || TEST_ERROR=1
done
popd
pushd prod/native/phpbridge_extension/phpt
for PHP_VERSION in "${PHP_VERSIONS[@]}"
do
./run.sh -b ${BUILD_ARCHITECTURE} -p ${PHP_VERSION} -f ${PWD}/results/phpt-bridge-${PHP_VERSION}.tar.gz || TEST_ERROR=1
done
popd
if [ $TEST_ERROR -eq 1 ]; then
echo "Some tests failed"
exit 1
fi
./tools/build/test_phpt.sh --build_architecture ${BUILD_ARCHITECTURE} --php_versions '80 81 82 83'
- uses: actions/upload-artifact@v4
if: failure()
with:
name: test-phpt-failures-${{ matrix.arch }}
path: |
prod/native/extension/phpt/results/*
prod/native/phpbridge_extension/phpt/results/*
19 changes: 19 additions & 0 deletions .github/workflows/test-sources-license.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---

name: test-sources-license

on:
workflow_call: ~
workflow_dispatch: ~

jobs:
test-sources-license:
name: test-sources-license
runs-on: ubuntu-latest
timeout-minutes: 300
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Verification whether the source files contain a header with the license
run: ./tools/build/test_sources_license.sh
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ phpunit.xml
html_docs

# Packaging artifacts and generated unit test reports
build/
build/*

# Backup files when using sed
.bck
Expand Down
6 changes: 3 additions & 3 deletions prod/native/extension/code/ForkHandler.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
Expand Down
8 changes: 4 additions & 4 deletions prod/native/extension/code/ForkHandler.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
Expand All @@ -19,4 +19,4 @@

#pragma once

void registerCallbacksToLogFork();
void registerCallbacksToLogFork();
21 changes: 20 additions & 1 deletion prod/native/extension/code/Hooking.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/


#include "Hooking.h"

Expand Down Expand Up @@ -139,4 +158,4 @@ void Hooking::replaceHooks() {

}

}
}
19 changes: 19 additions & 0 deletions prod/native/extension/code/Hooking.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#pragma once

#include <main/php_version.h>
Expand Down
21 changes: 20 additions & 1 deletion prod/native/extension/code/InternalFunctionInstrumentation.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#include "ModuleGlobals.h"
#include "InternalFunctionInstrumentation.h"
#include "AutoZval.h"
Expand Down Expand Up @@ -291,4 +310,4 @@ zend_observer_fcall_handlers elasticRegisterObserver(zend_execute_data *execute_



}
}
20 changes: 19 additions & 1 deletion prod/native/extension/code/InternalFunctionInstrumentation.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#pragma once

#include "AutoZval.h"
Expand All @@ -17,4 +36,3 @@ zend_observer_fcall_handlers elasticRegisterObserver(zend_execute_data *execute_


}

8 changes: 4 additions & 4 deletions prod/native/extension/code/ModuleEntry.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
Expand Down Expand Up @@ -163,4 +163,4 @@ zend_module_entry elastic_apm_module_entry = {
# ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
# endif
extern "C" ZEND_GET_MODULE(elastic_apm)
extern "C" ZEND_GET_MODULE(elastic_apm)
21 changes: 20 additions & 1 deletion prod/native/extension/code/ModuleFunctions.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/


#include "ModuleFunctions.h"
#include "ConfigurationStorage.h"
Expand Down Expand Up @@ -188,4 +207,4 @@ const zend_function_entry elastic_apm_functions[] = {

PHP_FE_END
};
// clang-format on
// clang-format on
21 changes: 20 additions & 1 deletion prod/native/extension/code/ModuleFunctions.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#pragma once

#include <Zend/zend_API.h>

extern const zend_function_entry elastic_apm_functions[];
extern const zend_function_entry elastic_apm_functions[];
Loading

0 comments on commit 5c9c1ad

Please sign in to comment.