Skip to content

Commit 0cfd35c

Browse files
committed
Reviewers comments
1 parent 0bcd572 commit 0cfd35c

4 files changed

Lines changed: 50 additions & 20 deletions

File tree

changelog-analysis/Jenkinsfile.create-smart-test-runs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pipeline {
22
agent any
33

44
parameters {
5+
string(name: 'RELEASE_TAG', description: 'Current release tag (e.g., firefox-v145.0)')
56
string(name: 'MILESTONE_ID', description: 'TestRail milestone ID')
67
}
78

@@ -12,7 +13,7 @@ pipeline {
1213
environment {
1314
PATH = "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:${env.PATH}"
1415
GITHUB_TOKEN = credentials('github-token')
15-
SLACK_WEBHOOK = credentials('slack-mobile-alerts-tooling-webhook')
16+
SLACK_WEBHOOK = credentials('slack-mobile-alerts-sandbox-webhook')
1617
}
1718

1819
stages {
@@ -35,7 +36,11 @@ pipeline {
3536
stage('Install Dependencies') {
3637
steps {
3738
dir('changelog-analysis') {
38-
sh 'pip3 install --no-cache-dir -r requirements.txt'
39+
sh '''
40+
set -e
41+
python3 -m venv .venv
42+
.venv/bin/pip install --no-cache-dir -r requirements.txt
43+
'''
3944
}
4045
}
4146
}
@@ -45,14 +50,14 @@ pipeline {
4550
dir('changelog-analysis') {
4651
script {
4752
def output = sh(
48-
script: 'python3 run_release_selection.py',
53+
script: ".venv/bin/python3 run_release_selection.py --head_tag ${params.RELEASE_TAG} --milestone_id ${params.MILESTONE_ID}",
4954
returnStdout: true
5055
).trim()
5156

5257
echo output
5358

54-
def headMatch = output =~ /Head tag from latest_tags\.json:\s+(\S+)/
55-
def baseMatch = output =~ /Base tag \(previous version\):\s+(\S+)/
59+
def headMatch = output =~ /Head tag:\s+(\S+)/
60+
def baseMatch = output =~ /Base tag:\s+(\S+)/
5661

5762
env.HEAD_TAG = headMatch ? headMatch[0][1] : 'unknown'
5863
env.BASE_TAG = baseMatch ? baseMatch[0][1] : 'unknown'

changelog-analysis/get_change_log.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,33 @@ def map_files_to_components(files: List[str], rules) -> Tuple[Set[str], List[str
131131

132132

133133
def get_changed_files(owner: str, repo: str, base: str, head: str) -> List[str]:
134-
url = f"https://api.github.com/repos/{owner}/{repo}/compare/{base}...{head}"
135-
response = requests.get(url, headers=_github_headers())
136-
response.raise_for_status()
137-
138-
all_files = [f["filename"] for f in response.json().get("files", [])]
139-
filtered = [f for f in all_files if not is_ignored_path(f)]
134+
commit_shas = []
135+
page = 1
136+
while True:
137+
response = requests.get(
138+
f"https://api.github.com/repos/{owner}/{repo}/compare/{base}...{head}",
139+
headers=_github_headers(),
140+
params={"per_page": 100, "page": page},
141+
)
142+
response.raise_for_status()
143+
commits = response.json().get("commits", [])
144+
commit_shas.extend(c["sha"] for c in commits)
145+
if len(commits) < 100:
146+
break
147+
page += 1
148+
149+
all_files: Set[str] = set()
150+
for sha in commit_shas:
151+
response = requests.get(
152+
f"https://api.github.com/repos/{owner}/{repo}/commits/{sha}",
153+
headers=_github_headers(),
154+
)
155+
response.raise_for_status()
156+
all_files.update(f["filename"] for f in response.json().get("files", []))
140157

158+
filtered = [f for f in sorted(all_files) if not is_ignored_path(f)]
141159
print(f"Total changed files (raw): {len(all_files)}")
142160
print(f"After filtering ignored paths: {len(filtered)}")
143-
144161
return filtered
145162

146163

changelog-analysis/run_release_selection.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,24 @@ def main():
2222
description="Smart release test selection based on changelog diff.",
2323
epilog="Tags are read from testrail/latest_tags.json when not provided explicitly.",
2424
)
25-
parser.add_argument("base_tag", nargs="?", help="Previous release tag")
26-
parser.add_argument("head_tag", nargs="?", help="Current release tag")
25+
parser.add_argument("--base_tag", help="Previous release tag")
26+
parser.add_argument("--head_tag", help="Current release tag")
2727
parser.add_argument("--milestone_id", type=int, help="TestRail milestone ID")
2828
args = parser.parse_args()
2929

30-
if args.base_tag and args.head_tag:
30+
if args.head_tag and not args.base_tag:
31+
head_tag = args.head_tag
32+
base_tag = get_base_tag(head_tag, IOS_OWNER, IOS_REPO)
33+
elif args.base_tag and args.head_tag:
3134
base_tag, head_tag = args.base_tag, args.head_tag
3235
elif args.base_tag or args.head_tag:
33-
parser.error("Provide both base_tag and head_tag, or neither.")
36+
parser.error("Provide both --base_tag and --head_tag, or only --head_tag.")
3437
else:
3538
head_tag = read_head_tag()
36-
print(f"Head tag from latest_tags.json: {head_tag}")
3739
base_tag = get_base_tag(head_tag, IOS_OWNER, IOS_REPO)
38-
print(f"Base tag (previous version): {base_tag}")
40+
41+
print(f"Head tag: {head_tag}")
42+
print(f"Base tag: {base_tag}")
3943

4044
print(f"\nComparing {base_tag}{head_tag}")
4145

testrail/Jenkinsfile.create-milestone

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ pipeline {
4242
stage('Install Dependencies') {
4343
steps {
4444
dir('testrail') {
45-
sh 'pip3 install --no-cache-dir -r requirements.txt'
45+
sh '''
46+
set -e
47+
python3 -m venv .venv
48+
.venv/bin/pip install --no-cache-dir -r requirements.txt
49+
'''
4650
}
4751
}
4852
}
@@ -75,7 +79,7 @@ EOF
7579
steps {
7680
dir('testrail') {
7781
script {
78-
def result = sh(script: 'python3 testrail_main_ios.py', returnStatus: true)
82+
def result = sh(script: '.venv/bin/python3 testrail_main_ios.py', returnStatus: true)
7983
if (result == 0) {
8084
echo "✅ Milestone created successfully"
8185
env.MILESTONE_CREATED = 'true'

0 commit comments

Comments
 (0)