-
Notifications
You must be signed in to change notification settings - Fork 359
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Validate Commits | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
validate-commits: | ||
name: Check if KubeArmor compiles for every commit | ||
runs-on: ubuntu-20.04 | ||
timeout-minutes: 60 | ||
steps: | ||
- name: Configure git | ||
run: | | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "[email protected]" | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.23 | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Validate each commit | ||
run: | | ||
# Loop through each commit in the PR from oldest to newest | ||
for commit in $(git rev-list --reverse ${{ github.event.pull_request.base.sha }}..${{ github.sha }}); do | ||
echo "=========================================" | ||
echo "Checking out commit $commit..." | ||
git checkout $commit | ||
|
||
# Attempt to build the project | ||
cd KubeArmor | ||
echo "Building KubeArmor for commit $commit..." | ||
if make build; then | ||
echo "✅ Commit $commit compiled successfully." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also recommend showing the error in the logs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GitHub Actions captures all logs from
|
||
else | ||
echo "❌ Commit $commit failed to compile!" | ||
echo "=========================================" | ||
exit 1 | ||
fi | ||
cd - | ||
echo "=========================================" | ||
done |
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.
Consider using
go-version-file: KubeArmor/go.mod
for defining go version