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

feat(ci): add script to validate each commit in PR #1955

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

inosmeet
Copy link

Purpose of PR?:
Implement feature that ensures that each commit of PR is separately compiles.
Closes: #616

If the changes in this PR are manually verified, list down the scenarios covered::
Manually tested in fork, with both appropriate commits that should and does compile as well as invalid commits that should and does fail.

Checklist:

  • Bug fix. Fixes #
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • PR Title follows the convention of <type>(<scope>): <subject>
  • Commit has unit tests
  • Commit has integration tests

@inosmeet
Copy link
Author

cc @Ankurk99 @achrefbensaad

@inosmeet
Copy link
Author

Hey @daemon1024!
Can I get a review?
Thanks!

Copy link
Member

@Ankurk99 Ankurk99 left a comment

Choose a reason for hiding this comment

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

Hey, thanks for the PR. I have a few suggestions.
Also, did you test these changes anywhere?

Comment on lines 18 to 21
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.23
Copy link
Member

Choose a reason for hiding this comment

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

Consider using go-version-file: KubeArmor/go.mod for defining go version

cd KubeArmor
echo "Building KubeArmor for commit $commit..."
if make build; then
echo "✅ Commit $commit compiled successfully."
Copy link
Member

Choose a reason for hiding this comment

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

I would also recommend showing the error in the logs

Copy link
Author

Choose a reason for hiding this comment

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

GitHub Actions captures all logs from make build, do we need to add manual logs?
for example, here's the log from GH action when i was testing manually:

Error: ./main.go:40:68: syntax error: unexpected newline in argument list; possibly missing comma or )
Error: ./main.go:41:4: syntax error: unexpected return at end of statement
make: *** [Makefile:26: build] Error 1
❌ Commit e52b12d577936188e5b7aea2c9ddb30fb6b60b17 failed to compile!
=========================================
Error: Process completed with exit code 1.

@inosmeet
Copy link
Author

did you test these changes anywhere?

Thanks for reviewing!
Yeah, I manually tested these in my fork.
I followed these steps:

  1. Made a PR to my fork which included a couple of commits that were appropriate (which passed).
  2. On top of the appropriate commits, I deliberately made a few commits that had some faults (which failed as the should).

I'm not sure whether there should be a test for this?

@inosmeet inosmeet requested a review from Ankurk99 January 31, 2025 10:32
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.

Add Github action to check if each commit is compiling
2 participants