Skip to content

fix: merge extra-options with fixed base/head PR SHAs#35

Merged
njjetha merged 2 commits into
qualcomm:mainfrom
njjetha:commit-msg-check
Apr 17, 2026
Merged

fix: merge extra-options with fixed base/head PR SHAs#35
njjetha merged 2 commits into
qualcomm:mainfrom
njjetha:commit-msg-check

Conversation

@njjetha
Copy link
Copy Markdown
Contributor

@njjetha njjetha commented Apr 14, 2026

Summary

Add a prepare step that merges caller-supplied extra-options JSON with the fixed base and head values derived from the pull_request event.
Use jq -sc to produce compact single-line output required by GITHUB_OUTPUT, and pass extra-options via env to prevent shell injection.

@njjetha njjetha changed the title test fix: merge extra-options with fixed base/head PR SHAs Apr 14, 2026
@njjetha njjetha self-assigned this Apr 14, 2026
@njjetha njjetha requested a review from mynameistechno April 14, 2026 15:16
@mynameistechno mynameistechno requested a review from ynancher April 15, 2026 15:55
enable-commit-email-check: true
enable-commit-msg-check: false # change to true to see some commit message check failures
commit-msg-check-extra-options: '{"check-blank-line": false}'
enable-commit-msg-check: true # change to true to see some commit message check failures
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.

can we make this change in the README file as well please

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.

As we already mentioned in README checker is optional its repo maintainer responsibility whether they want to enable it for there repo or not. We enable it for testing purpose in test-preflight.yml file.

EXTRA_OPTIONS: ${{ inputs.extra-options }}
run: |
FIXED='{"base":"${{ github.event.pull_request.base.sha }}","head":"${{ github.event.pull_request.head.sha }}"}'
MERGED=$(printf '%s\n%s' "$EXTRA_OPTIONS" "$FIXED" | jq -sc '.[0] * .[1]')
Copy link
Copy Markdown
Contributor

@ynancher ynancher Apr 16, 2026

Choose a reason for hiding this comment

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

If i dont give any extra options parameter it should fall back to default options. I tried testing this and it failed with this error:

Image

@njjetha could you please check?

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.

@ynancher I provided no extra-options it is taking default options
https://github.com/qualcomm/qcom-reusable-workflows/actions/runs/24497250895/job/71594992739
image

Check the changes https://github.com/qualcomm/qcom-reusable-workflows/pull/35/changes#diff-f63eb61e18c2ea800fd5c5855ed5cfd9f3cf45c2b1bc434f0483a24da12bc511R22

You need to set the value like this commit-msg-check-extra-options: '{}'

Although action failed because sub-char-limit is 50 and commit subject is more than 50 characters.

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.

I understand the current behavior. However, is it possible for the checker to gracefully handle the case where the extra-options input is not provided, rather than failing?
Since the workflow already defines default values for this input, a user who is satisfied with the defaults should not be required to explicitly pass the parameter with an empty value.

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.

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.

But it is not taking the input as {} during execution:
Inputs
extra-options:
It is parsing it as null

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.

Copy link
Copy Markdown
Contributor Author

@njjetha njjetha Apr 16, 2026

Choose a reason for hiding this comment

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

Ahh, I got it https://github.com/qualcomm/qcom-reusable-workflows/blob/main/.github/workflows/reusable-qcom-preflight-checks-orchestrator.yml#L37
Basically it set the value to default empty string due to which it is failing. I fixed that in commit a0b208a

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@njjetha njjetha force-pushed the commit-msg-check branch 4 times, most recently from bb42821 to 1e0072c Compare April 16, 2026 10:28
- name: Prepare action options
id: prepare-options
env:
EXTRA_OPTIONS: ${{ inputs.extra-options }}
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.

making this EXTRA_OPTIONS: ${{ inputs.extra-options || '{}' }}
will help us solve this issue, even in cases where the user hasn't explicitly added the extra options parameter in the preflight-checks-orchestrator.yml file

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.

Copy link
Copy Markdown
Contributor Author

@njjetha njjetha Apr 16, 2026

Choose a reason for hiding this comment

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

I am not sure why your action is failing but when I set commit-msg-check-extra-options: '{}' it is passing successfully you can check my workflow is successful.
https://github.com/qualcomm/qcom-reusable-workflows/actions/runs/24519688177/workflow

I can add the fallback ${{ inputs.extra-options || '{}' }} as an extra safety measure.
While callers who don't need extra options will simply omit the commit-msg-check-extra-options input entirely (relying on the declared default: '{}'), the || '{}' guards against the edge case where a caller explicitly passes an empty string ""

Add a prepare step that merges caller-supplied extra-options JSON with
the fixed base and head values derived from the pull_request event.
Use jq -sc to produce compact single-line output required by
GITHUB_OUTPUT, and pass extra-options via env to prevent shell
injection.

Signed-off-by: Neeraj Jetha <njetha@qti.qualcomm.com>
@njjetha njjetha force-pushed the commit-msg-check branch 2 times, most recently from 8668a88 to 31d2af8 Compare April 16, 2026 16:08
Add the `|| '{}'` fallback to the extra-options expression to guard
against the edge case where a caller explicitly passes an empty string
"" as the input value.

Signed-off-by: Neeraj Jetha <njetha@qti.qualcomm.com>
@njjetha njjetha merged commit 54edb08 into qualcomm:main Apr 17, 2026
10 checks passed
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.

4 participants