From 078ca1eac0e95bd3e2b999b7726656e5312df915 Mon Sep 17 00:00:00 2001 From: NautiyalVikas1 <157499123+NautiyalVikas1@users.noreply.github.com> Date: Fri, 4 Apr 2025 10:43:13 +0100 Subject: [PATCH 1/3] APM-6129-AnsibleUpdate --- poetry.lock | 86 +++++++++++++++++++++++++----------- pyproject.toml | 2 +- scripts/trigger_pipelines.py | 2 + 3 files changed, 64 insertions(+), 26 deletions(-) diff --git a/poetry.lock b/poetry.lock index 32f022d67..3448a028b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2,32 +2,36 @@ [[package]] name = "ansible" -version = "2.10.7" +version = "8.7.0" description = "Radically simple IT automation" optional = false -python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*" +python-versions = ">=3.9" files = [ - {file = "ansible-2.10.7.tar.gz", hash = "sha256:9ff024500116d53c460cb09ea92e3c9404119f100d1d1ff0de69a9dafca561d5"}, + {file = "ansible-8.7.0-py3-none-any.whl", hash = "sha256:fa7d3bc2dfdb0ab031df645814ff86b15cb5ec041bfbee4041f795abfa5646ca"}, + {file = "ansible-8.7.0.tar.gz", hash = "sha256:3a5ca5152e4547d590e40b542d76b18dbbe2b36da4edd00a13a7c51a374ff737"}, ] [package.dependencies] -ansible-base = ">=2.10.5,<2.11" +ansible-core = ">=2.15.7,<2.16.0" [[package]] -name = "ansible-base" -version = "2.10.17" +name = "ansible-core" +version = "2.15.13" description = "Radically simple IT automation" optional = false -python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*" +python-versions = ">=3.9" files = [ - {file = "ansible-base-2.10.17.tar.gz", hash = "sha256:ef925882ca8d4c3c2ccd091cde199e0c869024ccad0d07a337dcf207bff32f34"}, + {file = "ansible_core-2.15.13-py3-none-any.whl", hash = "sha256:e7f50bbb61beae792f5ecb86eff82149d3948d078361d70aedb01d76bc483c30"}, + {file = "ansible_core-2.15.13.tar.gz", hash = "sha256:f542e702ee31fb049732143aeee6b36311ca48b7d13960a0685afffa0d742d7f"}, ] [package.dependencies] cryptography = "*" -jinja2 = "*" +importlib-resources = {version = ">=5.0,<5.1", markers = "python_version < \"3.10\""} +jinja2 = ">=3.0.0" packaging = "*" -PyYAML = "*" +PyYAML = ">=5.1" +resolvelib = ">=0.5.3,<1.1.0" [[package]] name = "ansible-lint" @@ -77,17 +81,17 @@ tests-mypy = ["mypy (>=1.11.1)", "pytest-mypy-plugins"] [[package]] name = "awscli" -version = "1.38.25" +version = "1.38.27" description = "Universal Command Line Environment for AWS." optional = false python-versions = ">=3.8" files = [ - {file = "awscli-1.38.25-py3-none-any.whl", hash = "sha256:d512d9fc659fe9ebea5ba1a0433687c1055eaea04109f6775fb511343e96a3dd"}, - {file = "awscli-1.38.25.tar.gz", hash = "sha256:4e63d47d1445ad021dcc8d8c972759acfc4f79efdce8c1f5c158a94ebba8132b"}, + {file = "awscli-1.38.27-py3-none-any.whl", hash = "sha256:defb0e07c99b6aa3c90fa703710f892282e869a1843179c009593f47302fff3a"}, + {file = "awscli-1.38.27.tar.gz", hash = "sha256:7213499a0ab2fac625e22f7b17f6754e6c9fdb908935aa9b7908d1a4497e16f8"}, ] [package.dependencies] -botocore = "1.37.25" +botocore = "1.37.27" colorama = ">=0.2.5,<0.4.7" docutils = ">=0.10,<0.17" PyYAML = ">=3.10,<6.1" @@ -142,17 +146,17 @@ uvloop = ["uvloop (>=0.15.2)"] [[package]] name = "boto3" -version = "1.37.25" +version = "1.37.27" description = "The AWS SDK for Python" optional = false python-versions = ">=3.8" files = [ - {file = "boto3-1.37.25-py3-none-any.whl", hash = "sha256:00a025c621198508dc20c45224baaa7bd2a695323d999cce08b0d4deab5ada6f"}, - {file = "boto3-1.37.25.tar.gz", hash = "sha256:23e9cbad028ef3723567f4556411ee8d0f732594316b4c78c174a03ba3ca3159"}, + {file = "boto3-1.37.27-py3-none-any.whl", hash = "sha256:439c2cd18c79386b1b9d5fdc4a4e7e418e57ac50431bdf9421c60f09807f40fb"}, + {file = "boto3-1.37.27.tar.gz", hash = "sha256:ccdeee590902e6f4fb30cec6d3a88668545817fccfd3e5cb9cbc166c4a0000d4"}, ] [package.dependencies] -botocore = ">=1.37.25,<1.38.0" +botocore = ">=1.37.27,<1.38.0" jmespath = ">=0.7.1,<2.0.0" s3transfer = ">=0.11.0,<0.12.0" @@ -161,13 +165,13 @@ crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] [[package]] name = "botocore" -version = "1.37.25" +version = "1.37.27" description = "Low-level, data-driven core of boto 3." optional = false python-versions = ">=3.8" files = [ - {file = "botocore-1.37.25-py3-none-any.whl", hash = "sha256:e35f10df0c3bcf42f4680439148462073fe6445d8938679f0576eb189fb034d7"}, - {file = "botocore-1.37.25.tar.gz", hash = "sha256:6f8cefd769df170809816d66bde2e12c43f557ca6cf18c807922003319b52991"}, + {file = "botocore-1.37.27-py3-none-any.whl", hash = "sha256:a86d1ffbe344bfb183d9acc24de3428118fc166cb89d0f1ce1d412857edfacd7"}, + {file = "botocore-1.37.27.tar.gz", hash = "sha256:143fd7cdb0d73f43aa1f14799124de7b857da7d7ab996af5c89a49e3032a9e66"}, ] [package.dependencies] @@ -657,6 +661,21 @@ files = [ [package.extras] all = ["flake8 (>=7.1.1)", "mypy (>=1.11.2)", "pytest (>=8.3.2)", "ruff (>=0.6.2)"] +[[package]] +name = "importlib-resources" +version = "5.0.7" +description = "Read resources from Python packages" +optional = false +python-versions = ">=3.6" +files = [ + {file = "importlib_resources-5.0.7-py3-none-any.whl", hash = "sha256:2238159eb743bd85304a16e0536048b3e991c531d1cd51c4a834d1ccf2829057"}, + {file = "importlib_resources-5.0.7.tar.gz", hash = "sha256:4df460394562b4581bb4e4087ad9447bd433148fba44241754ec3152499f1d1b"}, +] + +[package.extras] +docs = ["jaraco.packaging (>=8.2)", "rst.linker (>=1.9)", "sphinx"] +testing = ["pytest (>=3.5,!=3.7.3)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=1.2.3)", "pytest-cov", "pytest-enabler", "pytest-flake8", "pytest-mypy"] + [[package]] name = "jinja2" version = "3.1.6" @@ -1339,6 +1358,23 @@ urllib3 = ">=1.21.1,<3" socks = ["PySocks (>=1.5.6,!=1.5.7)"] use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] +[[package]] +name = "resolvelib" +version = "1.0.1" +description = "Resolve abstract dependencies into concrete ones" +optional = false +python-versions = "*" +files = [ + {file = "resolvelib-1.0.1-py2.py3-none-any.whl", hash = "sha256:d2da45d1a8dfee81bdd591647783e340ef3bcb104b54c383f70d422ef5cc7dbf"}, + {file = "resolvelib-1.0.1.tar.gz", hash = "sha256:04ce76cbd63fded2078ce224785da6ecd42b9564b1390793f64ddecbe997b309"}, +] + +[package.extras] +examples = ["html5lib", "packaging", "pygraphviz", "requests"] +lint = ["black", "flake8", "isort", "mypy", "types-requests"] +release = ["build", "towncrier", "twine"] +test = ["commentjson", "packaging", "pytest"] + [[package]] name = "rich" version = "14.0.0" @@ -1583,13 +1619,13 @@ files = [ [[package]] name = "typing-extensions" -version = "4.13.0" +version = "4.13.1" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.13.0-py3-none-any.whl", hash = "sha256:c8dd92cc0d6425a97c18fbb9d1954e5ff92c1ca881a309c45f06ebc0b79058e5"}, - {file = "typing_extensions-4.13.0.tar.gz", hash = "sha256:0a4ac55a5820789d87e297727d229866c9650f6521b64206413c4fbada24d95b"}, + {file = "typing_extensions-4.13.1-py3-none-any.whl", hash = "sha256:4b6cf02909eb5495cfbc3f6e8fd49217e6cc7944e145cdda8caa3734777f9e69"}, + {file = "typing_extensions-4.13.1.tar.gz", hash = "sha256:98795af00fb9640edec5b8e31fc647597b4691f099ad75f469a2616be1a76dff"}, ] [[package]] @@ -1639,4 +1675,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "61df3acd79fda99a237fd91727d71706ccbc46d5cc6decb0177863ad7723cb8f" +content-hash = "2fd21cab99260db6abd39d8fb9def0252e21aa651a605cb4fe8b0adf96d39297" diff --git a/pyproject.toml b/pyproject.toml index abe188888..6a3b7bd4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ flake8 = "^3.7.9" mypy = "^0.770" pytest = "^5.4.2" pytest-cov = "^2.8.1" -ansible = "^2.10.7" +ansible = "^8.5.0" pyyaml = "^5.4.1" jmespath = "^0.10.0" awscli = "^1.18.80" diff --git a/scripts/trigger_pipelines.py b/scripts/trigger_pipelines.py index b53f2ecb0..5ab7029b0 100644 --- a/scripts/trigger_pipelines.py +++ b/scripts/trigger_pipelines.py @@ -14,6 +14,8 @@ def __init__(self): self.client_id = os.environ["AZ_CLIENT_ID"] self.client_secret = os.environ["AZ_CLIENT_SECRET"] self.client_tenant = os.environ["AZ_CLIENT_TENANT"] + if not all([self.client_id, self.client_secret, self.client_tenant]): + raise ValueError("Client ID, Secret, or Tenant is not set in the environment variables.") self.access_token = self._get_access_token() self.notify_commit_sha = os.environ["NOTIFY_COMMIT_SHA"] self.utils_pr_number = os.environ["UTILS_PR_NUMBER"] From ff1a48308c32917b4fa31c343d0891d7aa5f00f1 Mon Sep 17 00:00:00 2001 From: NautiyalVikas1 <157499123+NautiyalVikas1@users.noreply.github.com> Date: Fri, 4 Apr 2025 10:52:40 +0100 Subject: [PATCH 2/3] APM-6129-AnsibleUpdate --- scripts/test_pull_request_deployments.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/scripts/test_pull_request_deployments.py b/scripts/test_pull_request_deployments.py index 39d560744..91afe75f9 100644 --- a/scripts/test_pull_request_deployments.py +++ b/scripts/test_pull_request_deployments.py @@ -23,13 +23,8 @@ def trigger_pipelines(pipeline_ids: dict, service: str): ) if build_status != "succeeded": sys.exit(1) + print(f"Build pipeline for {service} failed with status: {build_status}") return - # azure_dev_ops.run_pipeline( - # service=service, - # pipeline_type="pr", - # pipeline_id=pipeline_ids["pr"], - # pipeline_branch=pipeline_ids["branch"] - # ) def main(): From 38430290af81a21276952869ef887c77ba3fdfb3 Mon Sep 17 00:00:00 2001 From: NautiyalVikas1 <157499123+NautiyalVikas1@users.noreply.github.com> Date: Fri, 4 Apr 2025 11:09:42 +0100 Subject: [PATCH 3/3] APM-6129-AnsibleUpdate --- azure/utils-pr-pipeline.yml | 2 +- scripts/test_pull_request_deployments.py | 100 +++++++++++------------ 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/azure/utils-pr-pipeline.yml b/azure/utils-pr-pipeline.yml index c5263e85c..0c12d52af 100644 --- a/azure/utils-pr-pipeline.yml +++ b/azure/utils-pr-pipeline.yml @@ -30,7 +30,7 @@ jobs: clean: all steps: - task: UsePythonVersion@0 - displayName: 'Use Python 3.8' + displayName: 'Use Python 3.9' inputs: versionSpec: 3.9 diff --git a/scripts/test_pull_request_deployments.py b/scripts/test_pull_request_deployments.py index 91afe75f9..ee5ae5e4e 100644 --- a/scripts/test_pull_request_deployments.py +++ b/scripts/test_pull_request_deployments.py @@ -1,50 +1,50 @@ -import os -import sys -from multiprocessing import Process -from trigger_pipelines import AzureDevOps - - -PULL_REQUEST_PIPELINES = { - "canary-api": { - "build": 222, - "pr": 223, - "branch": "refs/heads/main" - } -} - - -def trigger_pipelines(pipeline_ids: dict, service: str): - azure_dev_ops = AzureDevOps() - build_status = azure_dev_ops.run_pipeline( - service=service, - pipeline_type="build", - pipeline_id=pipeline_ids["build"], - pipeline_branch=pipeline_ids["branch"] - ) - if build_status != "succeeded": - sys.exit(1) - print(f"Build pipeline for {service} failed with status: {build_status}") - return - - -def main(): - jobs = [] - for service, pipeline_ids in PULL_REQUEST_PIPELINES.items(): - process = Process( - target=trigger_pipelines, - args=(pipeline_ids, service,) - ) - process.start() - jobs.append(process) - for process in jobs: - process.join() - # check return code of jobs and fail if there is a problem - for process in jobs: - if process.exitcode != 0: - print("A job failed") - sys.exit(1) - sys.exit(0) - - -if __name__ == "__main__": - main() +# import os +# import sys +# from multiprocessing import Process +# from trigger_pipelines import AzureDevOps + + +# PULL_REQUEST_PIPELINES = { +# "canary-api": { +# "build": 222, +# "pr": 223, +# "branch": "refs/heads/main" +# } +# } + + +# def trigger_pipelines(pipeline_ids: dict, service: str): +# azure_dev_ops = AzureDevOps() +# build_status = azure_dev_ops.run_pipeline( +# service=service, +# pipeline_type="build", +# pipeline_id=pipeline_ids["build"], +# pipeline_branch=pipeline_ids["branch"] +# ) +# if build_status != "succeeded": +# sys.exit(1) +# print(f"Build pipeline for {service} failed with status: {build_status}") +# return + + +# def main(): +# jobs = [] +# for service, pipeline_ids in PULL_REQUEST_PIPELINES.items(): +# process = Process( +# target=trigger_pipelines, +# args=(pipeline_ids, service,) +# ) +# process.start() +# jobs.append(process) +# for process in jobs: +# process.join() +# # check return code of jobs and fail if there is a problem +# for process in jobs: +# if process.exitcode != 0: +# print("A job failed") +# sys.exit(1) +# sys.exit(0) + + +# if __name__ == "__main__": +# main()