Skip to content

CI Set COMMIT_MESSAGE to allow commit markers detection in unit-tests.yml - #32501

Merged
lesteve merged 12 commits into
scikit-learn:mainfrom
thomass-dev:ci-retrieve-commit-message
Oct 16, 2025
Merged

lesteve merged 12 commits into
scikit-learn:mainfrom
thomass-dev:ci-retrieve-commit-message

Conversation

@thomass-dev

@thomass-dev thomass-dev commented Oct 14, 2025 •

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Partially addresses #32434.

changes of behaviour based on commit markers e.g. [float32], [all random seeds]. I had a look and my thinking so far would be to refrain from using CI-provider specific environment variable in bash scripts (e.g. Azure-specific BUILD_REASON is currently used in build_tools/test_script.sh or in build_tools/azure/get_commit_message.py but I would avoid doing a similar thing for GHA). Instead we should have a step in the yaml that sets environment variable (or job output if we think it's better to use job output), which the bash script can then use.

[float32] seems the easiest thing to start with

What does this implement/fix? Explain your changes.

Retrieve and set the latest commit message as COMMIT_MESSAGE environment variable in .github/workflows/unit-tests.yml to allow commit markers detection in build_tools/azure/test_script.sh.

@github-actions

github-actions Bot commented Oct 14, 2025 •

Copy link
Copy Markdown

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 8a8f2f2. Link to the linter CI: here

@thomass-dev
thomass-dev force-pushed the ci-retrieve-commit-message branch 3 times, most recently from 7ef4425 to bbb1cf3 Compare October 14, 2025 15:23
@thomass-dev thomass-dev changed the title CI Set COMMIT_MESSAGE envar to allow commit markers detection in unit-tests.yml CI Set COMMIT_MESSAGE to allow commit markers detection in unit-tests.yml Oct 14, 2025
@thomass-dev
thomass-dev force-pushed the ci-retrieve-commit-message branch 2 times, most recently from 0cfb0f7 to 337f547 Compare October 15, 2025 08:39
@thomass-dev
thomass-dev force-pushed the ci-retrieve-commit-message branch from 337f547 to d6b8053 Compare October 15, 2025 08:44
Comment thread .github/workflows/unit-tests.yml Resolved
Comment thread build_tools/azure/test_script.sh Resolved

@lesteve lesteve left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Definitely goes in the right direction and is not too complicated which is always nice.

To test this it would be good to:

  • modify test_script.sh to add -v to the pytest command
  • push a commit with [float32] in the commit message
  • make sure in the CI log that tests with global_dtype fixture are not skipped with float32 e.g. sklearn/cluster/tests/test_affinity_propagation.py test_affinity_propagation.

Other than this a few minor comments.

Comment thread .github/workflows/unit-tests.yml Outdated
outputs:
message: ${{ steps.git-log.outputs.message }}
steps:
- uses: actions/checkout@v5

@lesteve lesteve Oct 15, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would use the same pattern we use in wheels.yml since we know it works and I find it a bit simpler.

steps:
- name: Checkout scikit-learn
uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.head.sha }}

The reason it works is likely than on a push this ${{ github.event.pull_request.head.sha }} is empty and that in this case, the default behaviour kicks in which does the right thing and checkout the branch.

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.

You should be happy with 0928f4f.

Comment thread .github/workflows/unit-tests.yml Resolved
Comment thread build_tools/azure/test_script.sh Resolved
Comment thread build_tools/azure/test_script.sh Resolved
@thomass-dev
thomass-dev force-pushed the ci-retrieve-commit-message branch from b453ae8 to d569aa6 Compare October 15, 2025 13:02
@thomass-dev

thomass-dev commented Oct 15, 2025 •

Copy link
Copy Markdown
Contributor Author

@lesteve after downloading the logs of the commit 14b727f

I can confirm that the [float32] is taken in account.

2025-10-15T13:31:48.4937707Z cluster/tests/test_affinity_propagation.py::test_affinity_propagation_fit_non_convergence[float32] 
2025-10-15T13:31:48.4951621Z [gw0]�[36m [  5%] �[0m�[32mPASSED�[0m cluster/tests/test_affinity_propagation.py::test_affinity_propagation_fit_non_convergence[float32] 
2025-10-15T13:31:48.4979346Z cluster/tests/test_affinity_propagation.py::test_affinity_propagation_fit_non_convergence[float64] 
2025-10-15T13:31:48.5009278Z [gw0]�[36m [  5%] �[0m�[32mPASSED�[0m cluster/tests/test_affinity_propagation.py::test_affinity_propagation_fit_non_convergence[float64] 
2025-10-15T13:31:48.5010015Z cluster/tests/test_affinity_propagation.py::test_affinity_propagation_equal_mutual_similarities[float32] 
2025-10-15T13:31:48.5014140Z [gw3]�[36m [  5%] �[0m�[32mPASSED�[0m inspection/tests/test_partial_dependence.py::test_partial_dependence_easy_target[1-est0] 
2025-10-15T13:31:48.5020369Z inspection/tests/test_partial_dependence.py::test_partial_dependence_easy_target[1-est1] 
2025-10-15T13:31:48.5047554Z [gw2]�[36m [  5%] �[0m�[32mPASSED�[0m ensemble/tests/test_bagging.py::test_sparse_regression[csr_matrix] 
2025-10-15T13:31:48.5049691Z ensemble/tests/test_bagging.py::test_sparse_regression[csr_array] 
2025-10-15T13:31:48.5062892Z [gw0]�[36m [  5%] �[0m�[32mPASSED�[0m cluster/tests/test_affinity_propagation.py::test_affinity_propagation_equal_mutual_similarities[float32] 
2025-10-15T13:31:48.5148058Z cluster/tests/test_affinity_propagation.py::test_affinity_propagation_equal_mutual_similarities[float64] 
2025-10-15T13:31:48.5165767Z [gw0]�[36m [  5%] �[0m�[32mPASSED�[0m cluster/tests/test_affinity_propagation.py::test_affinity_propagation_equal_mutual_similarities[float64] 
2025-10-15T13:31:48.5166523Z cluster/tests/test_affinity_propagation.py::test_affinity_propagation_predict_non_convergence[float32] 
2025-10-15T13:31:48.5172057Z [gw0]�[36m [  5%] �[0m�[32mPASSED�[0m cluster/tests/test_affinity_propagation.py::test_affinity_propagation_predict_non_convergence[float32] 
2025-10-15T13:31:48.5205401Z cluster/tests/test_affinity_propagation.py::test_affinity_propagation_predict_non_convergence[float64] 
2025-10-15T13:31:48.5215699Z [gw0]�[36m [  5%] �[0m�[32mPASSED�[0m cluster/tests/test_affinity_propagation.py::test_affinity_propagation_predict_non_convergence[float64] 
2025-10-15T13:31:48.5252394Z cluster/tests/test_affinity_propagation.py::test_affinity_propagation_non_convergence_regressiontest[float32] 
2025-10-15T13:31:48.5266484Z [gw0]�[36m [  5%] �[0m�[32mPASSED�[0m cluster/tests/test_affinity_propagation.py::test_affinity_propagation_non_convergence_regressiontest[float32] 
2025-10-15T13:31:48.5345810Z cluster/tests/test_affinity_propagation.py::test_affinity_propagation_non_convergence_regressiontest[float64] 
2025-10-15T13:31:48.5346861Z [gw1]�[36m [  5%] �[0m�[32mPASSED�[0m cluster/tests/test_optics.py::test_dbscan_optics_parity[float64-csr_array-euclidean-20-0.5] 
2025-10-15T13:31:48.5375266Z cluster/tests/test_optics.py::test_min_samples_edge_case[float32] 
2025-10-15T13:31:48.5376324Z [gw0]�[36m [  5%] �[0m�[32mPASSED�[0m cluster/tests/test_affinity_propagation.py::test_affinity_propagation_non_convergence_regressiontest[float64] 
2025-10-15T13:31:48.5377143Z cluster/tests/test_affinity_propagation.py::test_equal_similarities_and_preferences[float32] 
2025-10-15T13:31:48.5378042Z [gw0]�[36m [  5%] �[0m�[32mPASSED�[0m cluster/tests/test_affinity_propagation.py::test_equal_similarities_and_preferences[float32] 
2025-10-15T13:31:48.5378693Z cluster/tests/test_affinity_propagation.py::test_equal_similarities_and_preferences[float64] 
2025-10-15T13:31:48.5379986Z [gw0]�[36m [  5%] �[0m�[32mPASSED�[0m cluster/tests/test_affinity_propagation.py::test_equal_similarities_and_preferences[float64] 
2025-10-15T13:31:48.5569319Z cluster/tests/test_affinity_propagation.py::test_affinity_propagation_random_state 
2025-10-15T13:31:48.5574438Z [gw0]�[36m [  5%] �[0m�[32mPASSED�[0m cluster/tests/test_affinity_propagation.py::test_affinity_propagation_random_state 
2025-10-15T13:31:48.5582008Z [gw1]�[36m [  5%] �[0m�[32mPASSED�[0m cluster/tests/test_optics.py::test_min_samples_edge_case[float32] 

@lesteve

lesteve commented Oct 15, 2025 •

Copy link
Copy Markdown
Member

Great, you can push a commit without [float32] marker while still keeping the -v and make sure that float32 are skipped in this case. I am expecting this to work with 99.9% chance but going all the way to 100% would be nice.

@thomass-dev
thomass-dev force-pushed the ci-retrieve-commit-message branch from 14b727f to ebefd0c Compare October 16, 2025 08:37
@thomass-dev

thomass-dev commented Oct 16, 2025 •

Copy link
Copy Markdown
Contributor Author

@lesteve after removing the [float32] marker in ebefd0c, i can confirm that related tests are skipped.

https://github.com/scikit-learn/scikit-learn/actions/runs/18555391796/job/52891580166?pr=32501

[...]

 cluster/tests/test_affinity_propagation.py::test_affinity_propagation_fit_non_convergence[float32] 
[gw0] [  5%] SKIPPED cluster/tests/test_affinity_propagation.py::test_affinity_propagation_fit_non_convergence[float32]

cluster/tests/test_affinity_propagation.py::test_affinity_propagation_equal_mutual_similarities[float32] 
[gw0] [  5%] SKIPPED cluster/tests/test_affinity_propagation.py::test_affinity_propagation_equal_mutual_similarities[float32] 

[...]

@thomass-dev

Copy link
Copy Markdown
Contributor Author

Let me know when i can remove the last commit.

@lesteve

lesteve commented Oct 16, 2025

Copy link
Copy Markdown
Member

Looks good thanks, feel free to revert the debug changes about -v.

with
multiline
comments
Comment thread .github/workflows/unit-tests.yml Outdated
echo 'message<<EOF'
echo "${message}"
echo EOF
} >> "${GITHUB_OUTPUT}"

@lesteve lesteve Oct 16, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually very good catch this is something I was wondering about and then forgot: is multi-line variables allowed in GITHUB_OUTPUT?

My crude understanding was that it's one line per variable but this would need to be double-checked.

we don't really need multi-line comment for [float32] but we kind of do for [all global random seeds], since the current format is something like:

message [all random seeds]
test_first
test_second

Having said this, if it's too annoying to support we can decide to change the format.

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.

Following the documentation, multi-line variable is supported this way.

In addition, the marker is verified using the regex if [[ "$COMMIT_MESSAGE" =~ \[float32\] ]];, which is working on multi-line.

Also, you can see in the commit 6e361bc (https://github.com/scikit-learn/scikit-learn/actions/runs/18561787134/job/52912450590?pr=32501) with a float32 marker and a multi-line comment, that the marker is catched:

image image

And the COMMIT_MESSAGE variable is well set:

image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OK great, it seems like we are all good then!

TEST COMMIT
WITH
[float32]
MARKER
-
TO REVERT
This reverts commit 6e361bc.
@thomass-dev
thomass-dev marked this pull request as ready for review October 16, 2025 13:45

@lesteve lesteve left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@lesteve
lesteve enabled auto-merge (squash) October 16, 2025 14:47
@lesteve
lesteve merged commit 6e22281 into scikit-learn:main Oct 16, 2025
@thomass-dev
thomass-dev deleted the ci-retrieve-commit-message branch October 20, 2025 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants