From 237d17b61f8ac970bd077a870f71357f23c65906 Mon Sep 17 00:00:00 2001 From: pducolin Date: Mon, 16 Dec 2024 18:55:09 +0100 Subject: [PATCH 1/4] [gitlab] add manual trigger for bump in datadog-agent --- .gitlab-ci.yml | 38 +++++++++++++++++++++++++++++--------- tasks/ci.py | 8 ++++++++ 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ddc2d5ce1..af5d5155b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -100,14 +100,9 @@ release-runner-image: - if: $CI_COMMIT_BRANCH == "main" when: on_success -bump-version-on-datadog-agent: - stage: post-release - image: ${CI_REGISTRY_IMAGE_TEST}:${CI_COMMIT_SHORT_SHA} - tags: ["arch:amd64"] - needs: ["release-runner-image"] - rules: - - if: $CI_COMMIT_BRANCH == "main" - when: on_success +.bump-version-on-datadog-agent: + variables: + EXTRA_UPDATE_ARGS: "" before_script: - set +x - export GITHUB_APP_USER_ID=153269286 # Can be found on https://api.github.com/users/agent-platform-auto-pr[bot] @@ -126,10 +121,35 @@ bump-version-on-datadog-agent: - pushd datadog-agent - git checkout -b auto-bump/bump-test-infra-$CI_COMMIT_SHORT_SHA - export PREVIOUS_SHA=$(cat .gitlab/common/test_infra_version.yml | grep 'TEST_INFRA_DEFINITIONS_BUILDIMAGES:' | awk -F " " '{print $NF}') - - inv -e buildimages.update-test-infra-definitions --commit-sha $CI_COMMIT_SHA + - inv -e buildimages.update-test-infra-definitions --commit-sha $CI_COMMIT_SHA $EXTRA_UPDATE_ARGS - git add test/new-e2e/go.mod test/new-e2e/go.sum .gitlab/common/test_infra_version.yml - git commit -m "[test-infra-definitions][automated] Bump test-infra-definitions to $CI_COMMIT_SHORT_SHA" - git push -f origin auto-bump/bump-test-infra-$CI_COMMIT_SHORT_SHA - popd - pip install -r requirements.txt - inv ci.create-bump-pr-and-close-stale-ones-on-datadog-agent --branch auto-bump/bump-test-infra-$CI_COMMIT_SHORT_SHA --new-commit-sha $CI_COMMIT_SHA --old-commit-sha $PREVIOUS_SHA + +bump-version-on-datadog-agent-dev: + extends: .bump-version-on-datadog-agent + stage: post-release + image: ${CI_REGISTRY_IMAGE_TEST}:${CI_COMMIT_SHORT_SHA} + tags: ["arch:amd64"] + needs: ["build-runner-image"] + rules: + - if: $CI_COMMIT_BRANCH == "main" + when: never + - when: manual + allow_failure: true + variables: + EXTRA_UPDATE_ARGS: "--is-dev-image" + +bump-version-on-datadog-agent: + extends: .bump-version-on-datadog-agent + stage: post-release + image: ${CI_REGISTRY_IMAGE_TEST}:${CI_COMMIT_SHORT_SHA} + tags: ["arch:amd64"] + needs: ["release-runner-image"] + rules: + - if: $CI_COMMIT_BRANCH == "main" + when: on_success + \ No newline at end of file diff --git a/tasks/ci.py b/tasks/ci.py index d1f33cfb6..200dd8a11 100644 --- a/tasks/ci.py +++ b/tasks/ci.py @@ -9,12 +9,16 @@ @task def create_bump_pr_and_close_stale_ones_on_datadog_agent(ctx, branch: str, new_commit_sha: str, old_commit_sha: str): + is_dev_branch = False if os.getenv("CI") != "true": print("This task should only be run in CI") return if os.getenv("GITHUB_TOKEN") is None: print("GITHUB_TOKEN is not set") return + if os.getenv("CI_COMMIT_BRANCH") != "main": + print("Running on a dev branch") + is_dev_branch = True repo = Github(auth=Auth.Token(os.environ["GITHUB_TOKEN"])).get_repo("DataDog/datadog-agent") pr_body = f""" @@ -36,6 +40,10 @@ def create_bump_pr_and_close_stale_ones_on_datadog_agent(ctx, branch: str, new_c print(f"PR created: {new_pr.html_url}") + if is_dev_branch: + print("Skipping stale PRs check since this is a dev branch") + return + print("Looking for stale auto bump PRs...") issues = repo.get_issues(state="open", labels=["automatic/test-infra-bump"]) From 8632266a2f88c85165dc72534e961e236b6a2f2a Mon Sep 17 00:00:00 2001 From: pducolin Date: Tue, 17 Dec 2024 12:56:08 +0100 Subject: [PATCH 2/4] [gitlab] sync and tidy all go modules in datadog-agent on test-infra bump --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index af5d5155b..57d0b955d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -122,7 +122,8 @@ release-runner-image: - git checkout -b auto-bump/bump-test-infra-$CI_COMMIT_SHORT_SHA - export PREVIOUS_SHA=$(cat .gitlab/common/test_infra_version.yml | grep 'TEST_INFRA_DEFINITIONS_BUILDIMAGES:' | awk -F " " '{print $NF}') - inv -e buildimages.update-test-infra-definitions --commit-sha $CI_COMMIT_SHA $EXTRA_UPDATE_ARGS - - git add test/new-e2e/go.mod test/new-e2e/go.sum .gitlab/common/test_infra_version.yml + - inv -e tidy + - git add -u - git commit -m "[test-infra-definitions][automated] Bump test-infra-definitions to $CI_COMMIT_SHORT_SHA" - git push -f origin auto-bump/bump-test-infra-$CI_COMMIT_SHORT_SHA - popd From 6fe0f0c1c219033cfcc3abade95c0e7462f777f5 Mon Sep 17 00:00:00 2001 From: pducolin Date: Tue, 17 Dec 2024 14:23:45 +0100 Subject: [PATCH 3/4] [gitlab] use one single job definition to trigger test-infra bumps in datadog-agent --- .gitlab-ci.yml | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 57d0b955d..aca5aff67 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -100,7 +100,21 @@ release-runner-image: - if: $CI_COMMIT_BRANCH == "main" when: on_success -.bump-version-on-datadog-agent: +bump-version-on-datadog-agent: + stage: post-release + image: registry.ddbuild.io/ci/datadog-agent-buildimages/deb_x64:v48815877-9bfad02c + tags: ["arch:amd64"] + rules: + - if: $CI_COMMIT_BRANCH == "main" + needs: ["release-runner-image"] + when: on_success + - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/ + when: never + - when: manual + needs: ["build-runner-image"] + allow_failure: true + variables: + EXTRA_UPDATE_ARGS: "--is-dev-image" variables: EXTRA_UPDATE_ARGS: "" before_script: @@ -129,28 +143,3 @@ release-runner-image: - popd - pip install -r requirements.txt - inv ci.create-bump-pr-and-close-stale-ones-on-datadog-agent --branch auto-bump/bump-test-infra-$CI_COMMIT_SHORT_SHA --new-commit-sha $CI_COMMIT_SHA --old-commit-sha $PREVIOUS_SHA - -bump-version-on-datadog-agent-dev: - extends: .bump-version-on-datadog-agent - stage: post-release - image: ${CI_REGISTRY_IMAGE_TEST}:${CI_COMMIT_SHORT_SHA} - tags: ["arch:amd64"] - needs: ["build-runner-image"] - rules: - - if: $CI_COMMIT_BRANCH == "main" - when: never - - when: manual - allow_failure: true - variables: - EXTRA_UPDATE_ARGS: "--is-dev-image" - -bump-version-on-datadog-agent: - extends: .bump-version-on-datadog-agent - stage: post-release - image: ${CI_REGISTRY_IMAGE_TEST}:${CI_COMMIT_SHORT_SHA} - tags: ["arch:amd64"] - needs: ["release-runner-image"] - rules: - - if: $CI_COMMIT_BRANCH == "main" - when: on_success - \ No newline at end of file From c9b482bfed9e80da854eb598310a7c12aa14e9a4 Mon Sep 17 00:00:00 2001 From: pducolin Date: Tue, 17 Dec 2024 14:34:37 +0100 Subject: [PATCH 4/4] [gitlab] use test-infra image to bump on datadog-agent Requires jq --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aca5aff67..726f65d76 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -102,7 +102,7 @@ release-runner-image: bump-version-on-datadog-agent: stage: post-release - image: registry.ddbuild.io/ci/datadog-agent-buildimages/deb_x64:v48815877-9bfad02c + image: ${CI_REGISTRY_IMAGE_TEST}:${CI_COMMIT_SHORT_SHA} tags: ["arch:amd64"] rules: - if: $CI_COMMIT_BRANCH == "main"