From c4caddb5f48a31421368a6673681ea9af4bdc386 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Fri, 2 Aug 2024 15:16:26 +0200 Subject: [PATCH] migrate profiling tests to github actions --- .circleci/continue_config.yml | 249 +------------------------------ .github/workflows/prof_tests.yml | 106 +++++++++++++ 2 files changed, 114 insertions(+), 241 deletions(-) create mode 100644 .github/workflows/prof_tests.yml diff --git a/.circleci/continue_config.yml b/.circleci/continue_config.yml index 344da463e5..e3ef804b68 100644 --- a/.circleci/continue_config.yml +++ b/.circleci/continue_config.yml @@ -288,16 +288,16 @@ commands: shell: "<<# parameters.is_windows >>bash.exe<>" command: | git config --global gc.auto 0 - + export CIRCLE_REPOSITORY_URL="${CIRCLE_REPOSITORY_URL/git@github.com:/https://github.com/}" - + APP_DIR="$HOME/datadog" if [ -e "$APP_DIR/.git" ] ; then echo 'Fetching into existing repository' existing_repo='true' cd "$APP_DIR" git remote set-url origin "$CIRCLE_REPOSITORY_URL" || true - + echo 'Fetching from remote repository' retry_count=3 if [ -n "$CIRCLE_TAG" ]; then @@ -316,7 +316,7 @@ commands: cd "$APP_DIR" git clone --no-checkout "$CIRCLE_REPOSITORY_URL" . fi - + if [ -n "$CIRCLE_TAG" ]; then echo 'Checking out tag' git checkout --force "$CIRCLE_TAG" @@ -329,7 +329,7 @@ commands: git checkout --force -B "$CIRCLE_BRANCH" "$CIRCLE_SHA1" git --no-pager log --no-color -n 1 --format='HEAD is now at %h %s' fi - + echo 'Updating submodules' # we don't need appsec submodules on windows <<# parameters.is_windows >>git submodule update --init libdatadog<> @@ -407,7 +407,7 @@ commands: command: | set +x cd << parameters.directory >> - if [[ '<< parameters.job >>' != "${LAST_ARTIFACTS_JOB:-}" ]]; then + if [[ '<< parameters.job >>' != "${LAST_ARTIFACTS_JOB:-}" ]]; then job_id=$(curl -X GET "https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID/job" -H "Accept: application/json" | grep -Eo '\{[^}]*"<< parameters.job >>"[^}]*' | grep -Eo '"job_number":[^,]+' | tail -c +14) export LAST_ARTIFACTS_RESULT=$(curl -X GET "https://circleci.com/api/v2/project/github/DataDog/dd-trace-php/$job_id/artifacts" -H "Accept: application/json") export LAST_ARTIFACTS_JOB='<< parameters.job >>' @@ -3160,7 +3160,7 @@ jobs: - run: name: cargo fetch command: | - SUDO=$(! command -v sudo >/dev/null || echo "sudo") + SUDO=$(! command -v sudo >/dev/null || echo "sudo") # On occasion, we've observed the .package-cache being in the cache. # If it's there, it will cause commands to stall, waiting for the file to be released. if [ -e '/rust/cargo/.package-cache' ] ; then @@ -3170,7 +3170,7 @@ jobs: $SUDO mkdir /.cargo $SUDO chmod 777 /.cargo - + $SUDO cargo fetch -v --target << parameters.triplet >> $SUDO chmod -R 777 '/rust/cargo' @@ -3214,90 +3214,6 @@ jobs: paths: - datadog-profiling - "profiling tests": - working_directory: ~/datadog - parameters: - docker_image: - type: string - triplet: - type: string - resource_class: - type: string - default: large # mostly for more RAM for ramdisk - <<: *BARE_DOCKER_MACHINE - environment: - - CARGO_TARGET_DIR: /mnt/ramdisk/cargo - steps: - - restore_cache: - keys: - - source-v1-{{ .Branch }}-{{ .Revision }} - - git_checkout - - <<: *STEP_ATTACH_WORKSPACE - - setup_docker: - docker_image: << parameters.docker_image >> - ramdisk: true - - restore_cache: - name: Restore Cargo Package Cache - keys: - - cargo-cache-<< parameters.triplet >>-{{ checksum "Cargo.lock" }} - - run: - name: cargo tests - command: | - if [ -d '/opt/rh/devtoolset-7' ] ; then - set +eo pipefail - source scl_source enable devtoolset-7 - set -eo pipefail - fi - set -u - command -v switch-php && switch-php "${PHP_VERSION}" - cd profiling - cargo test --release --all-features - - run: - name: phpt tests NTS - command: | - set -u - command -v switch-php && switch-php "${PHP_VERSION}" - set -e - libdir="/tmp/datadog-profiling" - cd profiling - cargo build --release --all-features - cd tests - # don't anticipate there being more than one - run_tests_php=$(find $(php-config --prefix) -name run-tests.php) - cp -v "${run_tests_php}" . - export TEST_PHP_EXECUTABLE=$(which php) - php run-tests.php -d "extension=/mnt/ramdisk/cargo/release/libdatadog_php_profiling.so" --show-diff -g "FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP" "phpt" - - run: - name: phpt tests ZTS - command: | - set -u - command -v switch-php && switch-php "${PHP_VERSION}-zts" - set -e - libdir="/tmp/datadog-profiling" - cd profiling - touch build.rs #make sure `build.rs` gets executed after `switch-php` call - cargo build --release --all-features - cd tests - # don't anticipate there being more than one - run_tests_php=$(find $(php-config --prefix) -name run-tests.php) - cp -v "${run_tests_php}" . - export TEST_PHP_EXECUTABLE=$(which php) - php run-tests.php -d "extension=/mnt/ramdisk/cargo/release/libdatadog_php_profiling.so" --show-diff -g "FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP" "phpt" - - - run: - name: clippy NTS (for select platforms) - command: | - if [[ "x86_64-unknown-linux-gnu" != "<< parameters.triplet >>" ]] ; then - exit 0 - fi - set -u - command -v switch-php && switch-php "${PHP_VERSION}" - set -e - cd profiling - touch build.rs - sed -i -e "s/crate-type.*$/crate-type = [\"rlib\"]/g" Cargo.toml - cargo clippy --all-targets --all-features -- -D warnings -Aunknown-lints - "compile_loader": working_directory: ~/datadog parameters: @@ -5673,152 +5589,3 @@ workflows: resource_class: - medium - arm.medium - - profiling_tests: - when: << pipeline.parameters.profiling >> - jobs: - - "profiling tests": - name: "Profiler test PHP v7.1 - x86_64-alpine-linux-musl" - docker_image: "datadog/dd-trace-ci:php-compile-extension-alpine-7.1" - triplet: "x86_64-alpine-linux-musl" - - "profiling tests": - name: "Profiler test PHP v7.1 - aarch64-alpine-linux-musl" - docker_image: "datadog/dd-trace-ci:php-compile-extension-alpine-7.1" - triplet: "aarch64-alpine-linux-musl" - resource_class: "arm.medium" - - "profiling tests": - name: "Profiler test PHP v7.2 - x86_64-alpine-linux-musl" - docker_image: "datadog/dd-trace-ci:php-compile-extension-alpine-7.2" - triplet: "x86_64-alpine-linux-musl" - - "profiling tests": - name: "Profiler test PHP v7.2 - aarch64-alpine-linux-musl" - docker_image: "datadog/dd-trace-ci:php-compile-extension-alpine-7.2" - triplet: "aarch64-alpine-linux-musl" - resource_class: "arm.medium" - - "profiling tests": - name: "Profiler test PHP v7.3 - x86_64-alpine-linux-musl" - docker_image: "datadog/dd-trace-ci:php-compile-extension-alpine-7.3" - triplet: "x86_64-alpine-linux-musl" - - "profiling tests": - name: "Profiler test PHP v7.3 - aarch64-alpine-linux-musl" - docker_image: "datadog/dd-trace-ci:php-compile-extension-alpine-7.3" - triplet: "aarch64-alpine-linux-musl" - resource_class: "arm.medium" - - "profiling tests": - name: "Profiler test PHP v7.4 - x86_64-alpine-linux-musl" - docker_image: "datadog/dd-trace-ci:php-compile-extension-alpine-7.4" - triplet: "x86_64-alpine-linux-musl" - - "profiling tests": - name: "Profiler test PHP v7.4 - aarch64-alpine-linux-musl" - docker_image: "datadog/dd-trace-ci:php-compile-extension-alpine-7.4" - triplet: "aarch64-alpine-linux-musl" - resource_class: "arm.medium" - - "profiling tests": - name: "Profiler test PHP v8.0 - x86_64-alpine-linux-musl" - docker_image: "datadog/dd-trace-ci:php-compile-extension-alpine-8.0" - triplet: "x86_64-alpine-linux-musl" - - "profiling tests": - name: "Profiler test PHP v8.0 - aarch64-alpine-linux-musl" - docker_image: "datadog/dd-trace-ci:php-compile-extension-alpine-8.0" - triplet: "aarch64-alpine-linux-musl" - resource_class: "arm.medium" - - "profiling tests": - name: "Profiler test PHP v8.1 - x86_64-alpine-linux-musl" - docker_image: "datadog/dd-trace-ci:php-compile-extension-alpine-8.1" - triplet: "x86_64-alpine-linux-musl" - - "profiling tests": - name: "Profiler test PHP v8.1 - aarch64-alpine-linux-musl" - docker_image: "datadog/dd-trace-ci:php-compile-extension-alpine-8.1" - triplet: "aarch64-alpine-linux-musl" - resource_class: "arm.medium" - - "profiling tests": - name: "Profiler test PHP v8.2 - x86_64-alpine-linux-musl" - docker_image: "datadog/dd-trace-ci:php-compile-extension-alpine-8.2" - triplet: "x86_64-alpine-linux-musl" - - "profiling tests": - name: "Profiler test PHP v8.2 - aarch64-alpine-linux-musl" - docker_image: "datadog/dd-trace-ci:php-compile-extension-alpine-8.2" - triplet: "aarch64-alpine-linux-musl" - resource_class: "arm.medium" - - "profiling tests": - name: "Profiler test PHP v8.3 - x86_64-alpine-linux-musl" - docker_image: "datadog/dd-trace-ci:php-compile-extension-alpine-8.3" - triplet: "x86_64-alpine-linux-musl" - - "profiling tests": - name: "Profiler test PHP v8.3 - aarch64-alpine-linux-musl" - docker_image: "datadog/dd-trace-ci:php-compile-extension-alpine-8.3" - triplet: "aarch64-alpine-linux-musl" - resource_class: "arm.medium" - - - "profiling tests": - name: "Profiler test PHP v7.1 - x86_64-unknown-linux-gnu" - docker_image: "datadog/dd-trace-ci:php-7.1_centos-7" - triplet: "x86_64-unknown-linux-gnu" - - "profiling tests": - name: "Profiler test PHP v7.1 - aarch64-unknown-linux-gnu" - docker_image: "datadog/dd-trace-ci:php-7.1_centos-7" - triplet: "aarch64-unknown-linux-gnu" - resource_class: "arm.medium" - - "profiling tests": - name: "Profiler test PHP v7.2 - x86_64-unknown-linux-gnu" - docker_image: "datadog/dd-trace-ci:php-7.2_centos-7" - triplet: "x86_64-unknown-linux-gnu" - - "profiling tests": - name: "Profiler test PHP v7.2 - aarch64-unknown-linux-gnu" - docker_image: "datadog/dd-trace-ci:php-7.2_centos-7" - triplet: "aarch64-unknown-linux-gnu" - resource_class: "arm.medium" - - "profiling tests": - name: "Profiler test PHP v7.3 - x86_64-unknown-linux-gnu" - docker_image: "datadog/dd-trace-ci:php-7.3_centos-7" - triplet: "x86_64-unknown-linux-gnu" - - "profiling tests": - name: "Profiler test PHP v7.3 - aarch64-unknown-linux-gnu" - docker_image: "datadog/dd-trace-ci:php-7.3_centos-7" - triplet: "aarch64-unknown-linux-gnu" - resource_class: "arm.medium" - - "profiling tests": - name: "Profiler test PHP v7.4 - x86_64-unknown-linux-gnu" - docker_image: "datadog/dd-trace-ci:php-7.4_centos-7" - triplet: "x86_64-unknown-linux-gnu" - - "profiling tests": - name: "Profiler test PHP v7.4 - aarch64-unknown-linux-gnu" - docker_image: "datadog/dd-trace-ci:php-7.4_centos-7" - triplet: "aarch64-unknown-linux-gnu" - resource_class: "arm.medium" - - "profiling tests": - name: "Profiler test PHP v8.0 - x86_64-unknown-linux-gnu" - docker_image: "datadog/dd-trace-ci:php-8.0_centos-7" - triplet: "x86_64-unknown-linux-gnu" - - "profiling tests": - name: "Profiler test PHP v8.0 - aarch64-unknown-linux-gnu" - docker_image: "datadog/dd-trace-ci:php-8.0_centos-7" - triplet: "aarch64-unknown-linux-gnu" - resource_class: "arm.medium" - - "profiling tests": - name: "Profiler test PHP v8.1 - x86_64-unknown-linux-gnu" - docker_image: "datadog/dd-trace-ci:php-8.1_centos-7" - triplet: "x86_64-unknown-linux-gnu" - - "profiling tests": - name: "Profiler test PHP v8.1 - aarch64-unknown-linux-gnu" - docker_image: "datadog/dd-trace-ci:php-8.1_centos-7" - triplet: "aarch64-unknown-linux-gnu" - resource_class: "arm.medium" - - "profiling tests": - name: "Profiler test PHP v8.2 - x86_64-unknown-linux-gnu" - docker_image: "datadog/dd-trace-ci:php-8.2_centos-7" - triplet: "x86_64-unknown-linux-gnu" - - "profiling tests": - name: "Profiler test PHP v8.2 - aarch64-unknown-linux-gnu" - docker_image: "datadog/dd-trace-ci:php-8.2_centos-7" - triplet: "aarch64-unknown-linux-gnu" - resource_class: "arm.medium" - - "profiling tests": - name: "Profiler test PHP v8.3 - x86_64-unknown-linux-gnu" - docker_image: "datadog/dd-trace-ci:php-8.3_centos-7" - triplet: "x86_64-unknown-linux-gnu" - - "profiling tests": - name: "Profiler test PHP v8.3 - aarch64-unknown-linux-gnu" - docker_image: "datadog/dd-trace-ci:php-8.3_centos-7" - triplet: "aarch64-unknown-linux-gnu" - resource_class: "arm.medium" diff --git a/.github/workflows/prof_tests.yml b/.github/workflows/prof_tests.yml new file mode 100644 index 0000000000..43b88d39e7 --- /dev/null +++ b/.github/workflows/prof_tests.yml @@ -0,0 +1,106 @@ +name: Profiling Tests + +on: + push: + branches: + - main + pull_request: + +jobs: + profiling-tests: + strategy: + matrix: + docker_image: + - "datadog/dd-trace-ci:php-compile-extension-alpine-7.1" + - "datadog/dd-trace-ci:php-compile-extension-alpine-7.2" + - "datadog/dd-trace-ci:php-compile-extension-alpine-7.3" + - "datadog/dd-trace-ci:php-compile-extension-alpine-7.4" + - "datadog/dd-trace-ci:php-compile-extension-alpine-8.0" + - "datadog/dd-trace-ci:php-compile-extension-alpine-8.1" + - "datadog/dd-trace-ci:php-compile-extension-alpine-8.2" + - "datadog/dd-trace-ci:php-compile-extension-alpine-8.3" + # - "datadog/dd-trace-ci:php-7.1_centos-7" + # - "datadog/dd-trace-ci:php-7.2_centos-7" + # - "datadog/dd-trace-ci:php-7.3_centos-7" + # - "datadog/dd-trace-ci:php-7.4_centos-7" + # - "datadog/dd-trace-ci:php-8.0_centos-7" + # - "datadog/dd-trace-ci:php-8.1_centos-7" + # - "datadog/dd-trace-ci:php-8.2_centos-7" + # - "datadog/dd-trace-ci:php-8.3_centos-7" + architecture: + - x86_64 + - aarch64 + # triplet: + # - "x86_64-alpine-linux-musl" + # - "aarch64-alpine-linux-musl" + # - "x86_64-unknown-linux-gnu" + # - "aarch64-unknown-linux-gnu" + runs-on: ${{ matrix.architecture == 'aarch64' && 'arm-8core-linux' || 'ubuntu-latest' }} + + container: + image: ${{ matrix.docker_image }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: true + + # - name: Restore Cargo Package Cache + # id: cache + # uses: actions/cache@v2 + # with: + # path: target + # key: cargo-cache-${{ matrix.triplet }}-${{ hashFiles('Cargo.lock') }} + + - name: Run cargo tests + run: | + if [ -d '/opt/rh/devtoolset-7' ] ; then + set +eo pipefail + source scl_source enable devtoolset-7 + set -eo pipefail + fi + set -u + command -v switch-php && switch-php "${PHP_VERSION}" + cd profiling + cargo test --release --all-features + + - name: Run phpt tests NTS + run: | + set -u + command -v switch-php && switch-php "${PHP_VERSION}" + set -e + libdir="/tmp/datadog-profiling" + cd profiling + cargo build --release --all-features + cd tests + run_tests_php=$(find $(php-config --prefix) -name run-tests.php) + cp -v "${run_tests_php}" . + export TEST_PHP_EXECUTABLE=$(which php) + php run-tests.php -d "extension=../../target/release/libdatadog_php_profiling.so" --show-diff -g "FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP" "phpt" + + - name: Run phpt tests ZTS + run: | + set -u + command -v switch-php && switch-php "${PHP_VERSION}-zts" + set -e + libdir="/tmp/datadog-profiling" + cd profiling + touch build.rs + cargo build --release --all-features + cd tests + run_tests_php=$(find $(php-config --prefix) -name run-tests.php) + cp -v "${run_tests_php}" . + export TEST_PHP_EXECUTABLE=$(which php) + php run-tests.php -d "extension=../../target/release/libdatadog_php_profiling.so" --show-diff -g "FAIL,XFAIL,BORK,WARN,LEAK,XLEAK,SKIP" "phpt" + + # - name: Run clippy NTS (for select platforms) + # if: matrix.triplet == 'x86_64-unknown-linux-gnu' + # run: | + # set -u + # command -v switch-php && switch-php "${PHP_VERSION}" + # set -e + # cd profiling + # touch build.rs + # sed -i -e "s/crate-type.*$/crate-type = [\"rlib\"]/g" Cargo.toml + # cargo clippy --all-targets --all-features -- -D warnings -Aunknown-lints