Skip to content

Commit ff2ceb4

Browse files
committed
fix tests and update post rebase
1 parent 5ea6a0f commit ff2ceb4

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

.github/workflows/create_rc_pr.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ jobs:
119119
env:
120120
MATRIX: ${{ matrix.value }}
121121
run: |
122-
git fetch
123122
if ${{ env.IS_AGENT6_RELEASE == 'true' }}; then
124123
inv -e release.create-rc -r "$MATRIX" --slack-webhook=${{ secrets.AGENT6_RELEASE_SLACK_WEBHOOK }} --patch-version
125124
else

tasks/libs/common/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,8 @@ def set_gitconfig_in_ci(ctx):
506506
Set username and email when runing git "write" commands in CI
507507
"""
508508
if running_in_ci():
509-
set_git_config('user.name', 'github-actions[bot]')
510-
set_git_config('user.email', 'github-actions[bot]@users.noreply.github.com')
509+
set_git_config(ctx, 'user.name', 'github-actions[bot]')
510+
set_git_config(ctx, 'user.email', 'github-actions[bot]@users.noreply.github.com')
511511

512512

513513
@contextmanager

tasks/release.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
get_last_commit,
3737
get_last_release_tag,
3838
is_agent6,
39-
set_git_config,
4039
try_git_command,
4140
)
4241
from tasks.libs.common.gomodules import get_default_modules
@@ -1350,14 +1349,7 @@ def bump_integrations_core(ctx, slack_webhook=None):
13501349
"""
13511350
Create a PR to bump the integrations core fields in the release.json file
13521351
"""
1353-
github_workflow_url = ""
1354-
if os.environ.get("GITHUB_ACTIONS"):
1355-
set_git_config('user.name', 'github-actions[bot]')
1356-
set_git_config('user.email', 'github-actions[bot]@users.noreply.github.com')
1357-
github_server_url = os.environ.get("GITHUB_SERVER_URL")
1358-
github_run_id = os.environ.get("GITHUB_RUN_ID")
1359-
github_workflow_url = f"{github_server_url}/{GITHUB_REPO_NAME}/actions/runs/{github_run_id}"
1360-
1352+
github_workflow_url = f"{os.environ.get('GITHUB_SERVER_URL', 'github.com')}/{GITHUB_REPO_NAME}/actions/runs/{os.environ.get('GITHUB_RUN_ID', '1')}"
13611353
commit_hash = get_git_references(ctx, "integrations-core", "HEAD").split()[0]
13621354

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

13751367
commit_message = "bump integrations core to HEAD"
1368+
set_gitconfig_in_ci(ctx)
13761369
ok = try_git_command(ctx, f"git commit -m '{commit_message}'")
13771370
if not ok:
13781371
raise Exit(

tasks/unit_tests/release_tests.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import os
34
import re
45
import sys
56
import unittest
@@ -786,6 +787,7 @@ def test_no_changes(self, version_mock, print_mock, _):
786787
}
787788
),
788789
)
790+
@patch.dict(os.environ, {'GITHUB_ACTIONS': 'true'})
789791
@patch('os.chdir', new=MagicMock())
790792
def test_changes_new_commit_first_repo(self, version_mock, print_mock, _):
791793
with mock_git_clone():
@@ -796,6 +798,8 @@ def test_changes_new_commit_first_repo(self, version_mock, print_mock, _):
796798
c = MockContext(
797799
run={
798800
'git rev-parse --abbrev-ref HEAD': Result("main"),
801+
'git config user.name github-actions[bot]': Result(""),
802+
'git config user.email github-actions[bot]@users.noreply.github.com': Result(""),
799803
'git ls-remote -h https://github.com/DataDog/omnibus-software "refs/heads/main"': Result(
800804
"4n0th3rc0mm1t9 refs/heads/main"
801805
),
@@ -867,6 +871,7 @@ def test_changes_new_commit_first_repo(self, version_mock, print_mock, _):
867871
),
868872
)
869873
@patch('os.chdir', new=MagicMock())
874+
@patch.dict(os.environ, {'GITHUB_ACTIONS': 'false'})
870875
def test_changes_new_commit_all_repo(self, version_mock, print_mock, _):
871876
with mock_git_clone():
872877
next = MagicMock()
@@ -1018,6 +1023,7 @@ def test_changes_new_release_one_repo(self, version_mock, print_mock, _):
10181023
}
10191024
),
10201025
)
1026+
@patch.dict(os.environ, {'GITHUB_ACTIONS': 'true'})
10211027
@patch('os.chdir', new=MagicMock())
10221028
def test_changes_new_commit_second_repo_branch_out(self, version_mock, print_mock, _):
10231029
with mock_git_clone():
@@ -1028,6 +1034,8 @@ def test_changes_new_commit_second_repo_branch_out(self, version_mock, print_moc
10281034
c = MockContext(
10291035
run={
10301036
'git rev-parse --abbrev-ref HEAD': Result("main"),
1037+
'git config user.name github-actions[bot]': Result(""),
1038+
'git config user.email github-actions[bot]@users.noreply.github.com': Result(""),
10311039
'git ls-remote -h https://github.com/DataDog/omnibus-software "refs/heads/7.55.x"': Result(
10321040
"4n0th3rc0mm1t0 refs/heads/main"
10331041
),
@@ -1264,6 +1272,7 @@ def test_update_module_optional_in_agent_7(self):
12641272
class TestTagModules(unittest.TestCase):
12651273
@patch('tasks.release.__tag_single_module', new=MagicMock(side_effect=[[str(i)] for i in range(2)]))
12661274
@patch('tasks.release.agent_context', new=MagicMock())
1275+
@patch.dict(os.environ, {'GITHUB_ACTIONS': 'false'})
12671276
def test_2_tags(self):
12681277
c = MockContext(run=Result("yolo"))
12691278
with patch('tasks.release.get_default_modules') as mock_modules:
@@ -1276,6 +1285,7 @@ def test_2_tags(self):
12761285

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

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

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

0 commit comments

Comments
 (0)