Skip to content

Add CI check for API since annotation version on branches >= 24 - #14196

Open
Pearl1594 wants to merge 2 commits into
mainfrom
ci-param-cs-version
Open

Pearl1594 wants to merge 2 commits into
mainfrom
ci-param-cs-version

Conversation

@Pearl1594

Copy link
Copy Markdown
Contributor

Description

This PR addresses: #14041 (comment)

It checks the following:

  • a new field, with since = "4.24" - Flagged
  • a new field, with since = "24.0" - Pass
  • a new field, no since - Flagged
  • editing description on an existing field that never had since - No op
  • brand-new @APICommand class with no since - Flagged
  • editing an existing @APICommand's description - No op

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@boring-cyborg boring-cyborg Bot added component:integration Python Warning... Python code Ahead! labels Sep 17, 2026
@codecov

codecov Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 20.44%. Comparing base (27722a5) to head (58931a5).
⚠️ Report is 64 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #14196      +/-   ##
============================================
+ Coverage     19.91%   20.44%   +0.53%     
- Complexity    20175    21413    +1238     
============================================
  Files          6372     6487     +115     
  Lines        577139   589337   +12198     
  Branches      70682    72248    +1566     
============================================
+ Hits         114913   120513    +5600     
- Misses       449664   455695    +6031     
- Partials      12562    13129     +567     
Flag Coverage Δ
uitests 3.70% <ø> (-0.01%) ⬇️
unittests 21.75% <ø> (+0.57%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Pearl1594
Pearl1594 requested a review from shwstppr September 17, 2026 19:22
@Pearl1594 Pearl1594 added this to the 24.0 milestone Sep 17, 2026
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

🔴 Test Coverage Grade: D — Marginal

Metric Value
Line coverage 25.49%
Branch coverage 19.79%

Grade Scale

Grade Line Coverage Meaning
🟢 A ≥ 80% Excellent - this code sleeps well at night 😴
🟡 B 60-79% Good - almost there, don't stop now 😉
🟠 C 40-59% Acceptable - your code is wearing a seatbelt, but no airbags 😬
🔴 D 20-39% Marginal - boldly shipping where no test has gone before 🖖
⛔ F < 20% Failing - tests? what tests? 🔥

Branch coverage is shown as a secondary signal. Grade is determined by line coverage.
View full Actions run

@nvazquez
nvazquez marked this pull request as ready for review September 18, 2026 14:24
Copilot AI lite review requested due to automatic review settings September 18, 2026 14:24
@nvazquez nvazquez closed this Sep 18, 2026
@nvazquez nvazquez reopened this Sep 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The checker currently won’t scan Java files outside the repo root and can miss common @Parameter fields with default initializers, undermining the CI check’s intended coverage.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds a GitHub Actions CI check to enforce correct since usage for newly added @APICommand/@Parameter/@Param annotations on branches using the post-4.x version scheme (major >= 24), to prevent accidental since="4.xx" usage and to require since on brand-new API surface.

Changes:

  • Introduces a new workflow that runs on PRs touching **/*.java and executes a repository script.
  • Adds a Python script that diffs PR base/head commits and flags (a) newly added since="4.*" and (b) brand-new annotations missing since.
File summaries
File Description
.github/workflows/check-since-annotation.yml Adds a PR workflow to run the “since annotation” validation on Java changes.
.github/scripts/check_since_annotations.py Implements diff-based detection of old-scheme since values and missing since on newly introduced API annotations.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/scripts/check_since_annotations.py
Comment on lines +66 to +72
def git_diff(base: str, head: str) -> str:
return subprocess.run(
["git", "diff", "--no-color", "--unified=0", base, head, "--", "*.java"],
check=True,
capture_output=True,
text=True,
).stdout

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not required.

@nvazquez

Copy link
Copy Markdown
Contributor

Thanks @Pearl1594 I'm largely fine with the changes - please check if the Copilot comments are relevant. I have closed/reopened the PR to trigger new CI jobs

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI lite review requested due to automatic review settings October 23, 2026 11:57
@Pearl1594

Copy link
Copy Markdown
Contributor Author

@DaanHoogland I've addressed one of the comments, I think this is good to merge

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open issues
1 resolved since last review

Review effort: Lite

Comment on lines +50 to +56
def read_project_version(pom_path: str) -> str:
with open(pom_path, encoding="utf-8") as f:
content = f.read()
match = VERSION_RE.search(content)
if not match:
raise SystemExit(f"Could not find the cloudstack project version in {pom_path}")
return match.group(1)
Comment on lines +41 to +58

ANNOTATION_START_RE = re.compile(r"@(Param|Parameter|APICommand)\s*\(")
SINCE_RE = re.compile(r'since\s*=\s*"(4\.\d[\w.]*)"')
HAS_SINCE_RE = re.compile(r"\bsince\s*=")
VERSION_RE = re.compile(r"<artifactId>cloudstack</artifactId>\s*<version>([^<]+)</version>")
FIELD_DECL_RE = re.compile(r"^\s*(?:private|protected|public)\b[^=;(){}]*?(\w+)\s*(?:=[^;]*)?;\s*$")
CLASS_DECL_RE = re.compile(r"^\s*(?:public\s+)?(?:final\s+)?class\s+(\w+)")


def read_project_version(pom_path: str) -> str:
with open(pom_path, encoding="utf-8") as f:
content = f.read()
match = VERSION_RE.search(content)
if not match:
raise SystemExit(f"Could not find the cloudstack project version in {pom_path}")
return match.group(1)


Comment on lines +151 to +157
for candidate in remainder.splitlines():
candidate = candidate.strip()
if not candidate:
continue
decl_match = decl_re.match(candidate)
break # only look at the next non-blank added line

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 40%)
C Security Rating on New Code (required ≥ B)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE



def read_project_version(pom_path: str) -> str:
with open(pom_path, encoding="utf-8") as f:
Comment on lines +67 to +72
return subprocess.run(
["git", "diff", "--no-color", "--unified=0", base, head, "--", "*.java"],
check=True,
capture_output=True,
text=True,
).stdout

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:integration Python Warning... Python code Ahead!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants