diff --git a/.gitlab/generate-package.php b/.gitlab/generate-package.php index 221626eb45..767e2e2a20 100644 --- a/.gitlab/generate-package.php +++ b/.gitlab/generate-package.php @@ -1235,6 +1235,7 @@ # Install Python dependencies pip install -U pip virtualenv + - /tmp/vault kv get --format=json "kv/k8s/gitlab-runner/dd-trace-php/datadoghq-api-key" 2>/dev/null | python3 -c "import sys,json;print(json.load(sys.stdin)['data']['data']['key'])" > /tmp/.dd-api-key 2>/dev/null || true - git clone https://github.com/DataDog/system-tests.git - mv packages/{datadog-setup.php,dd-library-php-*x86_64-linux-gnu.tar.gz} system-tests/binaries - cd system-tests @@ -1244,10 +1245,13 @@ when: always paths: - .cache/ + after_script: + - DATADOG_API_KEY=$(cat /tmp/.dd-api-key 2>/dev/null) || true + - mkdir -p artifacts && for f in system-tests/logs*/reportJunit.xml; do dir=$(basename $(dirname "$f")); cp "$f" "artifacts/reportJunit_${dir}.xml" 2>/dev/null || true; done + - DATADOG_API_KEY=${DATADOG_API_KEY:-} DD_SERVICE=system-tests DD_JUNIT_XPATH_TAGS="test.codeowners=/testcase/properties/property[@name='test.codeowners']" .gitlab/silent-upload-junit-to-datadog.sh artifacts: paths: - - "system-tests/logs_parametric/" - - "system-tests/logs/" + - "system-tests/logs*/" when: "always" "System Tests: [default]": @@ -1268,6 +1272,22 @@ script: - ./run.sh $TESTSUITE +"System Tests: [tracer-release]": + extends: .system_tests + timeout: 4h + rules: + - if: $CI_COMMIT_REF_NAME == "master" + when: on_success + - if: $CI_PIPELINE_SOURCE == "schedule" + when: on_success + - when: manual + allow_failure: true + script: + - DD_API_KEY=$(cat /tmp/.dd-api-key 2>/dev/null) || { echo "Failed to fetch DD_API_KEY"; exit 1; } + - export DD_API_KEY + - SCENARIOS=$(PYTHONPATH=. venv/bin/python utils/scripts/compute-workflow-parameters.py php -g tracer_release -f json | python3 -c "import sys,json;d=json.load(sys.stdin);s=set();[s.update(v['scenarios']) for v in d.values() if isinstance(v,dict) and 'scenarios' in v];print(' '.join(sorted(s)))") + - FAILED=""; for S in $SCENARIOS; do echo "=== Running $S ==="; ./run.sh $S || FAILED="$FAILED $S"; done; if [ -n "$FAILED" ]; then echo "Failed scenarios:$FAILED"; exit 1; fi + "System Tests: [parametric]": extends: .system_tests variables: diff --git a/.gitlab/upload-junit-to-datadog.sh b/.gitlab/upload-junit-to-datadog.sh index a7ce07fd82..46fb0dc380 100755 --- a/.gitlab/upload-junit-to-datadog.sh +++ b/.gitlab/upload-junit-to-datadog.sh @@ -4,7 +4,7 @@ set -eo pipefail export DATADOG_SITE="datadoghq.com" export DD_ENV="ci" -export DD_SERVICE="dd-trace-php-tests" +export DD_SERVICE="${DD_SERVICE:-dd-trace-php-tests}" export VAULT_SECRET_PATH="kv/k8s/gitlab-runner/dd-trace-php/datadoghq-api-key" export VAULT_VERSION="1.20.0" @@ -103,7 +103,7 @@ if ! command -v vault &> /dev/null; then fi echo "Extracting Vault..." - if ! unzip -q "${vault_zip}" -d /tmp; then + if ! unzip -o -q "${vault_zip}" -d /tmp; then echo "Warning: Failed to extract Vault. Skipping JUnit upload." >&2 exit 0 fi @@ -142,9 +142,10 @@ export DATADOG_API_KEY # Determine which datadog-ci method to use datadog_ci_cmd="" -# Prefer npm/npx if available -if command -v npx &> /dev/null || command -v npm &> /dev/null; then - echo "Using npx to run datadog-ci" +# Prefer npm/npx if available and node version is recent enough (>=16) +node_version="$(node --version 2>/dev/null | sed 's/^v//' | cut -d. -f1)" +if [ -n "$node_version" ] && [ "$node_version" -ge 16 ] 2>/dev/null && { command -v npx &> /dev/null || command -v npm &> /dev/null; }; then + echo "Using npx to run datadog-ci (node v${node_version})" datadog_ci_cmd="npx --yes @datadog/datadog-ci" else # Fall back to standalone binary if npm/npx not available @@ -212,10 +213,16 @@ if [[ -n "${TAGS}" ]]; then tags_args="--tags ${TAGS}" fi +# Build xpath-tag arguments if DD_JUNIT_XPATH_TAGS is set +xpath_tags_args="" +if [[ -n "${DD_JUNIT_XPATH_TAGS:-}" ]]; then + xpath_tags_args="--xpath-tag ${DD_JUNIT_XPATH_TAGS}" +fi + echo "Current directory: $(pwd)" -echo "Running command: ${datadog_ci_cmd} junit upload --service \"${DD_SERVICE}\" --max-concurrency 20 --verbose --tags git.repository_url:https://github.com/DataDog/dd-trace-php ${tags_args} ${files_array[*]}" +echo "Running command: ${datadog_ci_cmd} junit upload --service \"${DD_SERVICE}\" --max-concurrency 20 --verbose --tags git.repository_url:https://github.com/DataDog/dd-trace-php ${tags_args} ${xpath_tags_args} ${files_array[*]}" -if ! ${datadog_ci_cmd} junit upload --service "${DD_SERVICE}" --max-concurrency 20 --verbose --tags "git.repository_url:https://github.com/DataDog/dd-trace-php" ${tags_args} "${files_array[@]}"; then +if ! ${datadog_ci_cmd} junit upload --service "${DD_SERVICE}" --max-concurrency 20 --verbose --tags "git.repository_url:https://github.com/DataDog/dd-trace-php" ${tags_args} ${xpath_tags_args} "${files_array[@]}"; then echo "Warning: Failed to upload JUnit files" >&2 exit 0 fi