Skip to content

chore(ci): fix numerical comparison#2316

Merged
cristiand391 merged 1 commit into
mainfrom
cd/string-comparison
Jul 29, 2025
Merged

chore(ci): fix numerical comparison#2316
cristiand391 merged 1 commit into
mainfrom
cd/string-comparison

Conversation

@cristiand391
Copy link
Copy Markdown
Member

@cristiand391 cristiand391 commented Jul 29, 2025

What does this PR do?

Fix the string comparison done in the nightly PR workflow that was blocking new nightly releases after the 2.100.0 RC, see copilot explanation below ⏬

Acceptance Criteria

How do you know this change is successful? What is the scope of this change? What tests test the criteria (or why no tests)?

The Acceptance Criteria can be copied from the work item if they exist there but it is useful to have on the PR when reviewing the code.

Testing Notes

Successfully created a 2.100.1 nightly from this branch:
https://github.com/salesforcecli/cli/actions/runs/16606422530/job/46979279048

docs:
https://docs.github.com/en/actions/reference/workflows-and-actions/expressions#operators

🪄 fixed by copilot agent using sonnet 4, prompt:

// open file: cli/.github/workflows/make-pr-for-nightly.yml

this workflows isn't triggering none of the "Build night PR" steps, the "Log  version info" outputs this:

\`\`\`
Run echo "[INFO] Semver version in 'latest-rc' is: $STEPS_LATEST_RC_VERSION_VERSION"
[INFO] Semver version in 'latest-rc' is: 2.99.6
[INFO] Semver minor in 'latest-rc' is: 99
[INFO] Semver version in 'main' is: 2.100.0
[INFO] Semver minor in 'main' is: 100
\`\`\`

⬇️

The issue is that GitHub Actions is likely treating the step outputs as strings, not numbers, when doing the comparison. When comparing strings, '100' > '99' is actually false because string comparison is lexicographic (character by character), and '1' comes before '9' in ASCII.

The fix I applied wraps the step outputs with fromJSON() to convert the string values to numbers before comparison. This ensures that:

fromJSON('100') > fromJSON('99') evaluates to true (numeric comparison)
Instead of '100' > '99' which evaluates to false (string comparison)
With your current values:

latest-rc minor: 99
main (package.json) minor: 100
Now the condition fromJSON(100) > fromJSON(99) will correctly evaluate to true, and the "Build nightly PR (patch)" step should execute.The fix I applied wraps the step outputs with fromJSON() to convert the string values to numbers before comparison. This ensures that:

fromJSON('100') > fromJSON('99') evaluates to true (numeric comparison)
Instead of '100' > '99' which evaluates to false (string comparison)
With your current values:

latest-rc minor: 99
main (package.json) minor: 100
Now the condition fromJSON(100) > fromJSON(99) will correctly evaluate to true, and the "Build nightly PR (patch)" step should execute.

What issues does this PR fix or reference?

[skip-validate-pr]

Copy link
Copy Markdown
Contributor

@iowillhoit iowillhoit left a comment

Choose a reason for hiding this comment

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

NOTE: The deprecation failure is expected salesforcecli/plugin-agent#175

@cristiand391 cristiand391 merged commit 1e0c400 into main Jul 29, 2025
36 of 37 checks passed
@cristiand391 cristiand391 deleted the cd/string-comparison branch July 29, 2025 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants