Skip to content

Conversation

@michaeljmarshall
Copy link
Member

@michaeljmarshall michaeljmarshall commented Apr 20, 2021

Motivation

Currently, when there are changes made to code and documentation in the same PR, many of the tests are skipped because the conditional logic is not being parsed as expected.

@jerrypeng noticed this issue on this PR: #10254.

Modifications

Fix the usage of ${{}}.

Verifying this change

I ran tests in my personal GitHub repository to validate this change. Here is the PR that shows it: https://github.com/michaeljmarshall/pulsar/pull/2/checks. I used echo to validate what changed. (Note that the PR uses the base of #10254 to reproduce the problem.)

Does this pull request potentially affect one of the following parts:

This affects all tests that run for PRs that include changes to documentation and code.

@michaeljmarshall
Copy link
Member Author

@lhotari, @sijie, @eolivelli - PTAL. This is an urgent fix that should be merged as soon as we're good with it.

@lhotari
Copy link
Member

lhotari commented Apr 20, 2021

Thank you @michaeljmarshall for investigating and debugging this. I'll review this soon.

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

LGTM. Good work @michaeljmarshall!

@michaeljmarshall
Copy link
Member Author

@lhotari thanks!

I added comments to this staging PR michaeljmarshall#2 to show where and how I tested the changes.

I haven't been able to find explicit documentation on this specific case of interpolation yet. However, it does seem that this change produces the expected outcome for the affected tests.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

@lhotari
Copy link
Member

lhotari commented Apr 20, 2021

I added comments to this staging PR michaeljmarshall#2 to show where and how I tested the changes.

Yes, really good. I checked that while reviewing.

I haven't been able to find explicit documentation on this specific case of interpolation yet. However, it does seem that this change produces the expected outcome for the affected tests.

The documentation is here: https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#about-contexts-and-expressions . However there isn't a clear answer.
What seems to happen is that when using this syntax:

if: ${{ steps.changes.outputs.all_count > steps.changes.outputs.docs_count }}

the values are compared as string values and not numeric values.
In the example case, "40" > "7" is false.

When using the other syntax, the explicit expressions ${{ .... }} will trigger the autodetection of the value. This converts them into numbers

if: ${{ steps.changes.outputs.all_count }} > ${{ steps.changes.outputs.docs_count }}

Now 40 > 7 is true.

There is no documentation about how to explicitly convert value to a number. I believe that your fix is the correct way to do it. Thanks for saving my day @michaeljmarshall !

@lhotari
Copy link
Member

lhotari commented Apr 20, 2021

There is no documentation about how to explicitly convert value to a number. I believe that your fix is the correct way to do it.

I found the documentation. 'Literals': https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#literals . The fix is the correct way to convert to numbers for comparison.

@michaeljmarshall
Copy link
Member Author

@lhotari thank you for finding and sharing the documentation!

@lhotari
Copy link
Member

lhotari commented Apr 20, 2021

Just sharing more from the documentation: It that seems fromJSON function would also be a way to parse a number in a string as a number.

something like this could possibly work too.

if: ${{ fromJSON(steps.changes.outputs.all_count) > fromJSON(steps.changes.outputs.docs_count) }}

(I think this is very verbose compared to the solution in this PR)

fromJSON("40") > fromJSON("7") -> 40 > 7 -> true

@sijie sijie added this to the 2.8.0 milestone Apr 20, 2021
@sijie sijie merged commit 358c72f into apache:master Apr 20, 2021
codelipenghui pushed a commit that referenced this pull request Apr 28, 2021
…and run centos7 & windows cpp build only when there are cpp changes (#10376)

Fixes #10373

### Motivation

Tests should be skipped for PR builds that only contain documentation changes. This is currently broken.

A new build has been introduced for building the CPP client on Windows. Make the changes in `ci-cpp-build-centos7.yaml` and `ci-cpp-build-windows.yaml` so that the builds run only when there are changes in CPP client files (or the workflow definitions). 

### Modifications

Refactor logic to be less error prone. Use [`fromJSON`](https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#fromjson) function to parse a number in a string as a number. 

### Additional Context

#10276
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.

4 participants