-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
test: run patch tests for optional modifications #3793
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
Open
aldy505
wants to merge
9
commits into
master
Choose a base branch
from
aldy505/test/run-patch-tests-optional-modifications
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
51cf17e
test: run patch tests for optional modifications
aldy505 dc9ea6d
ci: wrong concurrency rule
aldy505 9a4cd1f
Potential fix for code scanning alert no. 11: Workflow does not conta…
aldy505 6792bfc
fix: missing end if block
aldy505 b2ed6b4
ci: patch should be silent
aldy505 f7236de
fix: use -p0 flag
aldy505 1bfe113
ci: remove pull_request event trigger
aldy505 b2ba39f
ci: run optional-modifications job on directory changes
aldy505 711dd84
ci: run optional-modifications job on GHA file changes
aldy505 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Optional Modifications | ||
|
||
on: | ||
# NOTE(reinaldy): This `pull_request` trigger should be removed once we have it tested on the PR. | ||
pull_request: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "0 0 */7 * *" | ||
|
||
concurrency: | ||
group: ${{ github.ref_name || github.sha }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
test-apply-patch: | ||
name: Test Apply Patch | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Apply patches | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
set -e | ||
|
||
# For each directory in `optional-modifications/patches/`, we will try to execute: | ||
# `patch < optional-modifications/patches/<dir>/<file>.patch` | ||
# with `<file>` being the name of the file in the directory that we loop through. | ||
# | ||
# If the patch fails, we will open a GitHub issue with the failing patch file. | ||
# To prevent so many issues created, we will check first whether there is already | ||
# an issue open with the same patch `<dir>` (without the file name). | ||
|
||
for patch_dir in optional-modifications/patches/*; do | ||
echo "::group::Checking for existing issue for $patch_dir" | ||
|
||
issue_title="[Optional Modification Failure] $patch_dir" | ||
issue_body=("Failure during applying patches for $patch_dir:") | ||
|
||
for patch_file in "$patch_dir"/*.patch; do | ||
echo "::debug::Checking for existing issue for $patch_file" | ||
patch_base_file_name=$(basename "$patch_file" .patch) | ||
if ! patch -f --dry-run < "$patch_file"; then | ||
problem=$(patch -f --dry-run < "$patch_file") | ||
issue_body+=($problem) | ||
echo "::error::Patch $patch_file failed to apply" | ||
fi | ||
done | ||
|
||
# If the length of `issue_body` array is greater than 1, | ||
# then we have a problem and we need to open an issue. | ||
if [ "${#issue_body[@]}" -gt 1 ]; then | ||
issue_exists=$(gh issue list --search "$issue_title in:title" --state open --json title --jq 'if length == 0 then empty end') | ||
if [ -z "$issue_exists" ]; then | ||
echo "::debug::Creating issue for $patch_dir" | ||
gh issue create --title "$issue_title" --body "${issue_body[*]}" | ||
fi | ||
|
||
echo "::debug::Reset the repository state" | ||
git reset --hard | ||
|
||
echo "::endgroup::" | ||
done | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These seem like cheap tests, only testing if the patch would apply cleanly. I think we can run these on PR for information and on master to create a new issue.
The "heavy" tests would be the ones which apply the patches and test if they actually work. This might be tricky.
At this point I'm wondering if we should spin off these patches into their own repos (for externals too) and find a way to apply these at install step easily. This would also offload the maintenance burden to whoever created the patches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not just tricky. If it's something like this external Kafka with auth + TLS support, you'd need to spawn an actual external Kafka with those configurations. Yet, I do think it is too heavy to do, and this minimal tests should work fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's also why I want these in their own repos so those repo owners would be thinking about these, not us 😅