Skip to content

Commit

Permalink
fix tests and update post rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
chouetz committed Feb 12, 2025
1 parent 5ea6a0f commit ff2ceb4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
1 change: 0 additions & 1 deletion .github/workflows/create_rc_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ jobs:
env:
MATRIX: ${{ matrix.value }}
run: |
git fetch
if ${{ env.IS_AGENT6_RELEASE == 'true' }}; then
inv -e release.create-rc -r "$MATRIX" --slack-webhook=${{ secrets.AGENT6_RELEASE_SLACK_WEBHOOK }} --patch-version
else
Expand Down
4 changes: 2 additions & 2 deletions tasks/libs/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,8 @@ def set_gitconfig_in_ci(ctx):
Set username and email when runing git "write" commands in CI
"""
if running_in_ci():
set_git_config('user.name', 'github-actions[bot]')
set_git_config('user.email', 'github-actions[bot]@users.noreply.github.com')
set_git_config(ctx, 'user.name', 'github-actions[bot]')
set_git_config(ctx, 'user.email', 'github-actions[bot]@users.noreply.github.com')


@contextmanager
Expand Down
11 changes: 2 additions & 9 deletions tasks/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
get_last_commit,
get_last_release_tag,
is_agent6,
set_git_config,
try_git_command,
)
from tasks.libs.common.gomodules import get_default_modules
Expand Down Expand Up @@ -1350,14 +1349,7 @@ def bump_integrations_core(ctx, slack_webhook=None):
"""
Create a PR to bump the integrations core fields in the release.json file
"""
github_workflow_url = ""
if os.environ.get("GITHUB_ACTIONS"):
set_git_config('user.name', 'github-actions[bot]')
set_git_config('user.email', 'github-actions[bot]@users.noreply.github.com')
github_server_url = os.environ.get("GITHUB_SERVER_URL")
github_run_id = os.environ.get("GITHUB_RUN_ID")
github_workflow_url = f"{github_server_url}/{GITHUB_REPO_NAME}/actions/runs/{github_run_id}"

github_workflow_url = f"{os.environ.get('GITHUB_SERVER_URL', 'github.com')}/{GITHUB_REPO_NAME}/actions/runs/{os.environ.get('GITHUB_RUN_ID', '1')}"
commit_hash = get_git_references(ctx, "integrations-core", "HEAD").split()[0]

rj = load_release_json()
Expand All @@ -1373,6 +1365,7 @@ def bump_integrations_core(ctx, slack_webhook=None):
ctx.run("git add release.json")

commit_message = "bump integrations core to HEAD"
set_gitconfig_in_ci(ctx)
ok = try_git_command(ctx, f"git commit -m '{commit_message}'")
if not ok:
raise Exit(
Expand Down
12 changes: 12 additions & 0 deletions tasks/unit_tests/release_tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import os
import re
import sys
import unittest
Expand Down Expand Up @@ -786,6 +787,7 @@ def test_no_changes(self, version_mock, print_mock, _):
}
),
)
@patch.dict(os.environ, {'GITHUB_ACTIONS': 'true'})
@patch('os.chdir', new=MagicMock())
def test_changes_new_commit_first_repo(self, version_mock, print_mock, _):
with mock_git_clone():
Expand All @@ -796,6 +798,8 @@ def test_changes_new_commit_first_repo(self, version_mock, print_mock, _):
c = MockContext(
run={
'git rev-parse --abbrev-ref HEAD': Result("main"),
'git config user.name github-actions[bot]': Result(""),
'git config user.email github-actions[bot]@users.noreply.github.com': Result(""),
'git ls-remote -h https://github.com/DataDog/omnibus-software "refs/heads/main"': Result(
"4n0th3rc0mm1t9 refs/heads/main"
),
Expand Down Expand Up @@ -867,6 +871,7 @@ def test_changes_new_commit_first_repo(self, version_mock, print_mock, _):
),
)
@patch('os.chdir', new=MagicMock())
@patch.dict(os.environ, {'GITHUB_ACTIONS': 'false'})
def test_changes_new_commit_all_repo(self, version_mock, print_mock, _):
with mock_git_clone():
next = MagicMock()
Expand Down Expand Up @@ -1018,6 +1023,7 @@ def test_changes_new_release_one_repo(self, version_mock, print_mock, _):
}
),
)
@patch.dict(os.environ, {'GITHUB_ACTIONS': 'true'})
@patch('os.chdir', new=MagicMock())
def test_changes_new_commit_second_repo_branch_out(self, version_mock, print_mock, _):
with mock_git_clone():
Expand All @@ -1028,6 +1034,8 @@ def test_changes_new_commit_second_repo_branch_out(self, version_mock, print_moc
c = MockContext(
run={
'git rev-parse --abbrev-ref HEAD': Result("main"),
'git config user.name github-actions[bot]': Result(""),
'git config user.email github-actions[bot]@users.noreply.github.com': Result(""),
'git ls-remote -h https://github.com/DataDog/omnibus-software "refs/heads/7.55.x"': Result(
"4n0th3rc0mm1t0 refs/heads/main"
),
Expand Down Expand Up @@ -1264,6 +1272,7 @@ def test_update_module_optional_in_agent_7(self):
class TestTagModules(unittest.TestCase):
@patch('tasks.release.__tag_single_module', new=MagicMock(side_effect=[[str(i)] for i in range(2)]))
@patch('tasks.release.agent_context', new=MagicMock())
@patch.dict(os.environ, {'GITHUB_ACTIONS': 'false'})
def test_2_tags(self):
c = MockContext(run=Result("yolo"))
with patch('tasks.release.get_default_modules') as mock_modules:
Expand All @@ -1276,6 +1285,7 @@ def test_2_tags(self):

@patch('tasks.release.__tag_single_module', new=MagicMock(side_effect=[[str(i)] for i in range(3)]))
@patch('tasks.release.agent_context', new=MagicMock())
@patch.dict(os.environ, {'GITHUB_ACTIONS': 'false'})
def test_3_tags(self):
c = MockContext(run=Result("yolo"))
with patch('tasks.release.get_default_modules') as mock_modules:
Expand All @@ -1288,6 +1298,7 @@ def test_3_tags(self):

@patch('tasks.release.__tag_single_module', new=MagicMock(side_effect=[[str(i)] for i in range(4)]))
@patch('tasks.release.agent_context', new=MagicMock())
@patch.dict(os.environ, {'GITHUB_ACTIONS': 'false'})
def test_4_tags(self):
c = MockContext(run=Result("yolo"))
with patch('tasks.release.get_default_modules') as mock_modules:
Expand All @@ -1304,6 +1315,7 @@ def test_4_tags(self):

@patch('tasks.release.__tag_single_module', new=MagicMock(side_effect=[[str(i)] for i in range(100)]))
@patch('tasks.release.agent_context', new=MagicMock())
@patch.dict(os.environ, {'GITHUB_ACTIONS': 'false'})
def test_100_tags(self):
c = MockContext(run=Result("yolo"))
with patch('tasks.release.get_default_modules') as mock_modules:
Expand Down

0 comments on commit ff2ceb4

Please sign in to comment.