Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip gradle check for non code related changes #13085

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .github/workflows/gradle-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,27 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: tj-actions/changed-files@v44
id: changed-files

- id: run-gradle-check
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
run_gradle_check=false

for filename in ${ALL_CHANGED_FILES}; do
# Run gradle check if file ends in [java/gradle/json]
Copy link
Member

Choose a reason for hiding this comment

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

I like the spirit here but there are many files that can fail the build that don't meet these extensions:

Copy link
Member Author

Choose a reason for hiding this comment

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

We can do an inverse set where we skip gradle check if the changes are limited to certain file types

Copy link
Member

Choose a reason for hiding this comment

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

If going this route, I'd rather do a strictly positive list. If the commits only affects: [CHANGELOG*.md, README.md, ...] then skip

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 to @peternied 's suggestion, other examples are: version.properties, bwcVersions, ....

Copy link
Member Author

Choose a reason for hiding this comment

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

That sounds good. I was just bouncing the idea across.
I'll work on refining and testing this out.
Thanks folks.

Copy link
Member

Choose a reason for hiding this comment

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

I find paths-ignore as an easier option. We can keep on adding to the list and also manage file-types, directories, etc. This won't even initiate the workflow run for ignored paths. Example: #13477

Copy link
Member Author

Choose a reason for hiding this comment

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

That sounds good. I'll close out this PR and we can keep adding to paths-ignore

if [[ $filename =~ \.(java|gradle|json)$ ]]; then
run_gradle_check=true
break
fi
done

echo "run_check=$run_gradle_check" >> $GITHUB_OUTPUT

- name: Setup environment variables (PR)
if: github.event_name == 'pull_request_target'
if: github.event_name == 'pull_request_target' && steps.run-gradle-check.outputs.run_check == true
run: |
echo "pr_from_sha=$(jq --raw-output .pull_request.head.sha $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
echo "pr_from_clone_url=$(jq --raw-output .pull_request.head.repo.clone_url $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
Expand All @@ -50,13 +69,15 @@ jobs:
echo "pr_number=Null" >> $GITHUB_ENV

- name: Checkout opensearch-build repo
if: steps.run-gradle-check.outputs.run_check == true
uses: actions/checkout@v4
with:
repository: opensearch-project/opensearch-build
ref: main
path: opensearch-build