diff --git a/scripts/bump_ddtrace.py b/scripts/bump_ddtrace.py deleted file mode 100755 index a13ff8c826b..00000000000 --- a/scripts/bump_ddtrace.py +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/env python3 -import os -import platform -import re -import subprocess -import sys - -import requests - - -PROJECT = os.getenv("BUMP_PROJECT", "") -GH_USERNAME = os.getenv("BUMP_GH_UNAME", "") -OS_USERNAME = os.getenv("BUMP_OS_UNAME", "") - - -PROJECT_MAIN_BRANCH_NAME = "main" -PARTIAL_BRANCH_NAME = "bump-ddtrace-to-" -PACKAGE_NAME = "ddtrace" - -linux = platform.system() == "Linux" -HOME_PREFIX = "/home" if linux else "/Users" -OPEN_CMD = "xdg-open" if linux else "open" - - -def run_command(command, check=True, cwd=None): - """Utility function to run shell commands.""" - print(f"Running: {command}") - result = subprocess.run(command, shell=True, check=check, text=True, capture_output=True, cwd=cwd) - print(result.stdout) - if result.stderr: - print(result.stderr, file=sys.stderr) - return result - - -def get_current_git_branch(project_path): - """Get the name of the current git branch.""" - result = run_command("git rev-parse --abbrev-ref HEAD", check=False, cwd=project_path) - return result.stdout.strip() - - -def create_git_branch(branch_name, project_path): - """Step 0: Create a new git branch if not already on it.""" - current_branch = get_current_git_branch(project_path) - if current_branch != branch_name: - run_command(f"git checkout -b '{branch_name}'", cwd=project_path) - - -def get_latest_dependency_version(package_name): - """Step 1: Get the latest version of a package from PyPI.""" - url = f"https://pypi.org/pypi/{package_name}/json" - response = requests.get(url) - if response.status_code == 200: - return response.json().get("info", {}).get("version") - return None - - -def modify_requirements_file(requirements_path, new_version): - """Step 2: Modify the requirements.in file.""" - print(f"Updating {PACKAGE_NAME} to version {new_version} in {requirements_path}") - with open(requirements_path, "r") as file: - lines = file.readlines() - - with open(requirements_path, "w") as file: - for line in lines: - if re.match(rf"{PACKAGE_NAME}==[0-9]+(\.[0-9]+)*", line): - file.write(f"{PACKAGE_NAME}=={new_version}\n") - else: - file.write(line) - - -def run_bazel_commands(project_path, only_vendor=False): - """Step 3: Run necessary Bazel commands.""" - commands = ["bzl run //:requirements.update", "bzl run //:requirements_vendor"] - if only_vendor: - commands = commands[1:] - for cmd in commands: - run_command(cmd, cwd=project_path) - - -def commit_and_push_changes(branch_name, project_path, latest_version): - """Step 4: Commit the changes and push to remote.""" - run_command("git add requirements*", cwd=project_path) - input("Are you ready to commit and push the changes? Press Enter to continue...") - run_command(f"git commit -m 'Bump {PACKAGE_NAME} version to {latest_version}'", cwd=project_path) - run_command(f"git push --set-upstream origin {branch_name}", cwd=project_path) - - -def create_bump_pr(branch_name, project_path, requirements_path, latest_version, project): - try: - create_git_branch(branch_name, project_path) - modify_requirements_file("/".join((project_path, requirements_path)), latest_version) - run_bazel_commands(project_path) - commit_and_push_changes(branch_name, project_path, latest_version) - run_command(f"{OPEN_CMD} https://github.com/DataDog/{project}/pull/new/{branch_name}") - except Exception: - run_command("git reset --hard HEAD", cwd=project_path) - run_command(f"git checkout {PROJECT_MAIN_BRANCH_NAME}", cwd=project_path) - run_command(f"git branch -D {branch_name}", cwd=project_path) - - -def update_pr(branch_name, project_path): - # update main branch - run_command(f"git checkout {PROJECT_MAIN_BRANCH_NAME}", cwd=project_path) - run_command("git pull", cwd=project_path) - # checkout branch - run_command(f"git checkout {branch_name}", cwd=project_path) - # save git sha - git_sha = run_command("git rev-parse HEAD", cwd=project_path).stdout.strip() - cherry_pick_success = False - try: - # reset branch to main_branch - run_command(f"git reset --hard {PROJECT_MAIN_BRANCH_NAME}", cwd=project_path) - # cherry-pick commit, this will fail if there are conflicts, that's OK - result = run_command(f"git cherry-pick {git_sha}", check=False, cwd=project_path) - if "conflict" in result.stdout.lower() or "conflict" in result.stderr.lower(): - # reset requirement_* files to main state - run_command(f"git checkout {PROJECT_MAIN_BRANCH_NAME} -- requirements_*", cwd=project_path) - # run bazel commands - run_bazel_commands(project_path, only_vendor=True) - # add new changes - run_command("git add requirements_*", cwd=project_path) - # cherry-pick continue with changes, no editor - run_command("git -c core.editor=true cherry-pick --continue", check=False, cwd=project_path) - cherry_pick_success = True - else: - cherry_pick_success = True - - except Exception: - # if there are conflicts, abort the cherry-pick and reset the branch - run_command("git cherry-pick --abort", check=False, cwd=project_path) - run_command(f"git reset --hard {git_sha}", cwd=project_path) - - if cherry_pick_success: - # force push changes - run_command("git push --force", cwd=project_path) - - -def main(package_version=None): - if not all((GH_USERNAME, OS_USERNAME, PROJECT)): - print("Fill the required constants at the top of the file (project and usernames)") - sys.exit(1) - - requirements_path = "requirements.in" - project_path = f"{HOME_PREFIX}/{OS_USERNAME}/go/src/github.com/DataDog/{PROJECT}" - - latest_version = package_version or get_latest_dependency_version(PACKAGE_NAME) - branch_name = "/".join((GH_USERNAME, PARTIAL_BRANCH_NAME + latest_version)) - - # To decide whether if create or update the PR, check if the branch name exists in origin - result = run_command(f"git ls-remote --heads origin {branch_name}", check=False, cwd=project_path) - branch_exists = result.stdout - - if not branch_exists: - create_bump_pr(branch_name, project_path, requirements_path, latest_version, PROJECT) - else: - update_pr(branch_name, project_path) - - -if __name__ == "__main__": - # Usage: ./bump_ddtrace.py 0.1.2 - # Get package version from command line arguments - package_version = None - if len(sys.argv) > 1: - package_version = sys.argv[1] - main(package_version) diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh deleted file mode 100755 index d96809c0cf4..00000000000 --- a/scripts/cppcheck.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -set -e - -cppcheck --inline-suppr --error-exitcode=1 --std=c++17 --language=c++ --force \ - $(git ls-files '*.c' '*.cpp' '*.h' '*.hpp' '*.cc' '*.hh' | grep -E -v '^(ddtrace/(vendor|internal)|ddtrace/appsec/_iast/_taint_tracking/_vendor)/') diff --git a/scripts/get-test-agent-results.sh b/scripts/get-test-agent-results.sh deleted file mode 100644 index 5080078b34b..00000000000 --- a/scripts/get-test-agent-results.sh +++ /dev/null @@ -1,29 +0,0 @@ -set +e # Disable exiting from testagent response failure -SUMMARY_RESPONSE=$(curl -s -w "\n%{http_code}" -o summary_response.txt http://localhost:9126/test/trace_check/summary) -set -e -SUMMARY_RESPONSE_CODE=$(echo "$SUMMARY_RESPONSE" | awk 'END {print $NF}') - -if [[ SUMMARY_RESPONSE_CODE -eq 200 ]]; then - echo "APM Test Agent is running. (HTTP 200)" -else - echo "APM Test Agent is not running and was not used for testing. No checks failed." - exit 0 -fi - -RESPONSE=$(curl -s -w "\n%{http_code}" -o response.txt http://localhost:9126/test/trace_check/failures) -RESPONSE_CODE=$(echo "$RESPONSE" | awk 'END {print $NF}') - -if [[ $RESPONSE_CODE -eq 200 ]]; then - echo "All APM Test Agent Check Traces returned successful! (HTTP 200)" - echo "APM Test Agent Check Traces Summary Results:" - cat summary_response.txt | jq '.' -elif [[ $RESPONSE_CODE -eq 404 ]]; then - echo "Real APM Agent running in place of TestAgent, no checks to validate!" -else - echo "APM Test Agent Check Traces failed with response code: $RESPONSE_CODE" - echo "Failures:" - cat response.txt - echo "APM Test Agent Check Traces Summary Results:" - cat summary_response.txt | jq '.' - exit 1 -fi \ No newline at end of file diff --git a/scripts/run-test-suite b/scripts/run-test-suite deleted file mode 100755 index 5a57199a352..00000000000 --- a/scripts/run-test-suite +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env bash - -set -o pipefail - -CHECKPOINT_FILENAME="latest-success-commit" -RIOT_PATTERN=${1} -DDTRACE_FLAG=$([ -v _CI_DD_API_KEY ] && echo '--ddtrace') -GIT_MESSAGE_LOWERCASE=$(git log -1 --pretty=%B | tr "[:upper:]" "[:lower:]") -if [[ $GIT_MESSAGE_LOWERCASE == *"itr:noskip"* ]]; then - COLLECT_COVERAGE=true -else - if [[ -v CIRCLE_PULL_REQUEST ]]; then - COLLECT_COVERAGE=false - else - echo "Getting coverage for non-PR branch" - COLLECT_COVERAGE=true - fi -fi -COVERAGE_FLAG=$([[ "${2:-false}" == false && $COLLECT_COVERAGE == false ]] && echo '--no-cov') -DDTEST_CMD=$([[ ${3} == "1" ]] && echo "./scripts/ddtest") - -RIOT_HASHES=( $(riot list --hash-only $RIOT_PATTERN | sort) ) -echo "Found ${#RIOT_HASHES[@]} riot hashes: ${RIOT_HASHES[@]}" -if [[ ${#RIOT_HASHES[@]} -eq 0 ]]; then - echo "No riot hashes found for pattern: $RIOT_PATTERN" - if [[ -v CIRCLECI ]]; then - circleci step halt - fi - exit 1 -fi - -if [[ -v CIRCLECI ]]; then - # circleci tests splits expects one test per line - RIOT_HASHES=( $( printf '%s\n' "${RIOT_HASHES[@]}" | circleci tests split) ) - if [[ ${#RIOT_HASHES[@]} -eq 0 ]]; then - echo "No riot hashes found after split, halting." - circleci step halt - exit 0 - fi - echo "${#RIOT_HASHES[@]} hashes split for CircleCI: ${RIOT_HASHES[@]}" -fi - - - -set -e - -if ! [[ -v CIRCLECI && $CIRCLE_BRANCH =~ main ]]; then - if [[ -f "$CHECKPOINT_FILENAME" ]]; then - latest_success_commit=$(cat $CHECKPOINT_FILENAME) - if ! hatch run scripts:needs_testrun $CIRCLE_JOB --sha $latest_success_commit; then - echo "The $CIRCLE_JOB job succeeded at commit $latest_success_commit." - echo "None of the changes on this branch since that commit affect the $CIRCLE_JOB job." - echo "Skipping this job." - circleci step halt - fi - fi -fi - -for hash in ${RIOT_HASHES[@]}; do - echo "Running riot hash: $hash" - ($DDTEST_CMD riot -P -v run --exitfirst --pass-env -s $hash $COVERAGE_FLAG $DDTRACE_FLAG) - exit_code=$? - if [ $exit_code -ne 0 ] ; then - if [[ -v CIRCLECI ]]; then - circleci step halt - fi - exit $exit_code - fi -done - -rm -f $CHECKPOINT_FILENAME -echo $CIRCLE_SHA1 > $CHECKPOINT_FILENAME -echo "All tests passed. Saved $CIRCLE_SHA1 as the latest successful commit for job $CIRCLE_JOB" - -./scripts/check-diff \ - ".riot/requirements/" \ - "Changes detected after running riot. Consider deleting changed files, \ - running scripts/compile-and-prune-test-requirements and committing the result." - -./scripts/check-diff \ - "ddtrace/contrib/integration_registry/registry.yaml" \ - "Registry YAML file (ddtrace/contrib/integration_registry/registry.yaml) was modified. Please run: \ - \`python scripts/integration_registry/update_and_format_registry.py\` and commit the changes." diff --git a/scripts/run-test-suite-hatch b/scripts/run-test-suite-hatch deleted file mode 100755 index 38754de9ac9..00000000000 --- a/scripts/run-test-suite-hatch +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env bash - -CHECKPOINT_FILENAME="latest-success-commit" -HATCH_ENV=${1} -DDTRACE_FLAG=$([ -v _CI_DD_API_KEY ] && echo '--ddtrace') -DDTEST_CMD=$([[ ${2} == "1" ]] && echo "./scripts/ddtest") - -HATCH_ENVS=( $(hatch env show --json | jq --arg hatch_env "${HATCH_ENV}" -r 'keys[] | select(. | contains($hatch_env + ".py"))' | sort ) ) -echo "Found ${#HATCH_ENVS[@]} hatch envs: ${HATCH_ENVS[@]}" -if [[ ${#HATCH_ENVS[@]} -eq 0 ]]; then - echo "No hatch envs found for $HATCH_ENV" - if [[ -v CIRCLECI ]]; then - circleci step halt - fi - exit 1 -fi - -if [[ -v CIRCLECI ]]; then - # circleci tests splits expects one test per line - HATCH_ENVS=( $( printf '%s\n' "${HATCH_ENVS[@]}" | circleci tests split) ) - if [[ ${#HATCH_ENVS[@]} -eq 0 ]]; then - echo "No hatch env after split, halting." - circleci step halt - exit 0 - fi - echo "${#HATCH_ENVS[@]} hatch env split for CircleCI: ${HATCH_ENVS[@]}" -fi - - - -set -e - -if ! [[ -v CIRCLECI && $CIRCLE_BRANCH =~ main ]]; then - if [[ -f "$CHECKPOINT_FILENAME" ]]; then - latest_success_commit=$(cat $CHECKPOINT_FILENAME) - if ! hatch run scripts:needs_testrun $CIRCLE_JOB --sha $latest_success_commit; then - echo "The $CIRCLE_JOB job succeeded at commit $latest_success_commit." - echo "None of the changes on this branch since that commit affect the $CIRCLE_JOB job." - echo "Skipping this job." - circleci step halt - exit 0 - fi - fi -fi - -for hatch_env in ${HATCH_ENVS[@]}; do - echo "Running hatch env: $hatch_env" - if ! $DDTEST_CMD hatch run "'${hatch_env}:test'"; then - if [[ -v CIRCLECI ]]; then - circleci step halt - fi - exit 1 - fi -done - -rm -f $CHECKPOINT_FILENAME -echo $CIRCLE_SHA1 > $CHECKPOINT_FILENAME -echo "All tests passed. Saved $CIRCLE_SHA1 as the latest successful commit for job $CIRCLE_JOB" diff --git a/scripts/stubgen.sh b/scripts/stubgen.sh deleted file mode 100755 index 5471288156f..00000000000 --- a/scripts/stubgen.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -e -for file in ddtrace/profiling/exporter/pprof.pyx -do - stubgen "$file" - mv out/__main__.pyi $(dirname "$file")/$(basename "$file" .pyx).pyi -done -rmdir out diff --git a/scripts/unreleased-changes b/scripts/unreleased-changes deleted file mode 100755 index d0b64ea0448..00000000000 --- a/scripts/unreleased-changes +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env python -""" -Shell script to help find unreleased changes on release branches. - -Loops through each release branch from current branch to 1.0 and prints out -the changes that have not been released yet in json format as: - -{"branch": "1.1","changes": ["..."]} -{"branch": "1.0","changes": ["..."]} -""" -import json -import packaging.version -import subprocess -import sys - - -def get_release_branches() -> list[str]: - # get list of all git release tags - tags = subprocess.check_output(["git", "tag", "--list", "v*"]).splitlines() - # get list of all release branches - branches = sorted( - {".".join(tag.decode("utf-8")[1:].split(".")[:2]) for tag in tags}, - key=lambda x: packaging.version.Version(x), - reverse=True, - ) - - return [branch for branch in branches if float(branch) >= 1.0] - - -def get_unreleased_changes(branch: str) -> list[str]: - # get list of reno changes for the branch - results = subprocess.check_output( - ["reno", "--quiet", "list", "--branch", branch, "--stop-at-branch-base"], stderr=subprocess.PIPE - ).decode("utf-8") - - changes = [] - - unreleased_version = None - # The output from reno list will be: - # - # v1.2.3-13 - # releasenotes/unreleased-change - # v1.2.3 - # releasenotes/released-change ... - # v1.2.2 - # releasenotes/released-change ... - # - # We want to collect all the lines between the first version with a `vx.y.z-#` until - # the next version - for line in results.splitlines(): - if line.startswith("v") and "-" in line: - unreleased_version = line.strip() - elif line.startswith("\t") and unreleased_version: - changes.append(line.strip()) - elif unreleased_version and line.startswith("v"): - break - - return changes - - -def main(): - # Make sure we have the latest tags - subprocess.check_output(["git", "fetch", "--tags", "--force"], stderr=subprocess.PIPE) - - branches = get_release_branches() - for branch in branches: - changes = get_unreleased_changes(branch) - if changes: - json.dump({"branch": branch, "changes": changes}, sys.stdout, indent=None, separators=(",", ":")) - sys.stdout.write("\n") - sys.stdout.flush() - - -if __name__ == "__main__": - main() diff --git a/scripts/validate-version b/scripts/validate-version deleted file mode 100755 index ef65d22cd61..00000000000 --- a/scripts/validate-version +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python -import os -import sys -import textwrap - -import setuptools_scm - - -def main(root, expected_version): - # type: (str, str) -> None - version = setuptools_scm.get_version(root) - if version != expected_version: - sys.stderr.write("Version {!r} does not match expected {!r}\r\n".format(version, expected_version)) - sys.exit(1) - - sys.stdout.write("Version {!r} is correct\r\n".format(version)) - - -if __name__ == "__main__": - if len(sys.argv) != 2: - sys.stderr.write( - textwrap.dedent( - """ - Usage: {0} EXPECTED-VERSION - Examples: - {0} \"0.48.0\" - {0} \"0.48.0rc3\" - {0} \"0.48.0rc3.dev64+g8c11ad89.d20210419\" - """.format( - sys.argv[0] - ) - ) - ) - sys.exit(1) - - root = os.path.abspath(os.path.join(__file__, "../../")) - main(root, sys.argv[1]) diff --git a/tests/profiling/suitespec.yml b/tests/profiling/suitespec.yml index 8c49696c48a..a002e86cac5 100644 --- a/tests/profiling/suitespec.yml +++ b/tests/profiling/suitespec.yml @@ -6,7 +6,6 @@ components: - riotfile.py - .riot/requirements/* - scripts/ddtest - - scripts/run-test-suite - hatch.toml - tests/conftest.py - tests/utils.py diff --git a/tests/suitespec.yml b/tests/suitespec.yml index 45ff7bfd95b..fe0ece52ca8 100644 --- a/tests/suitespec.yml +++ b/tests/suitespec.yml @@ -6,7 +6,6 @@ components: - riotfile.py - .riot/requirements/* - scripts/ddtest - - scripts/run-test-suite - hatch.toml - tests/conftest.py - tests/utils.py