-
Notifications
You must be signed in to change notification settings - Fork 237
feat: Enable additional linter rules just for new changes #1817
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
Changes from 8 commits
2c95c28
4931122
7fc40b0
5787bed
c4f4f6e
0b70311
045d944
7595b9d
b22a3df
2531cd9
576bbc4
8e8d95d
c7a7988
0320163
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,58 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
# Incrementally fetch git history until we find the merge base with the target branch | ||
# Usage: ./fetch-base-incrementally.sh <base-ref> | ||
|
||
if [ $# -eq 0 ]; then | ||
echo "Error: No base branch specified" | ||
echo "Usage: $0 <base-ref>" | ||
exit 1 | ||
fi | ||
|
||
BASE_REF="$1" | ||
echo "Fetching git history to find merge base with $BASE_REF branch..." | ||
|
||
# Check if we have the merge base and print it | ||
check_merge_base() { | ||
if MERGE_BASE=$(git merge-base HEAD "origin/$BASE_REF" 2>/dev/null); then | ||
echo "✓ Found merge base: $(git rev-parse --short "$MERGE_BASE")" | ||
return 0 | ||
fi | ||
return 1 | ||
} | ||
|
||
FETCH_INCREMENT=50 # How many commits to deepen on each iteration | ||
MAX_ITERATIONS=10 # The number of times to deepen before we just fetch everything | ||
|
||
# Start with a minimal fetch of just the base ref | ||
git fetch --depth=1 origin "$BASE_REF" >/dev/null 2>&1 | ||
|
||
# Now deepen to get history from both branches | ||
echo "→ Fetching up to $FETCH_INCREMENT commits of shared history..." | ||
git fetch --deepen=$FETCH_INCREMENT origin HEAD "$BASE_REF" | ||
|
||
# Check if we already have the merge base | ||
if check_merge_base; then | ||
exit 0 | ||
fi | ||
|
||
# Incrementally deepen by FETCH_INCREMENT commits at a time | ||
for i in $(seq 1 $MAX_ITERATIONS); do | ||
echo "→ Need more history, fetching up to $FETCH_INCREMENT additional commits..." | ||
git fetch --deepen=$FETCH_INCREMENT origin HEAD "$BASE_REF" | ||
|
||
if check_merge_base; then | ||
exit 0 | ||
fi | ||
done | ||
|
||
# Final fallback to full fetch if needed | ||
echo "⚠ Branch history is deep, fetching all commits..." | ||
git fetch --unshallow origin "$BASE_REF" || git fetch origin "$BASE_REF" | ||
|
||
# Verify we found it | ||
if ! check_merge_base; then | ||
echo "✗ Failed to find merge base with $BASE_REF even after full fetch" | ||
exit 1 | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,21 @@ jobs: | |
- name: Checkout EigenDA | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #4.2.2 | ||
|
||
# Fetch git history of the base branch so golangci-lint can analyze only the diff | ||
# between the feature branch and base branch (via --new-from-rev flag) | ||
- name: Fetch base branch history | ||
if: github.event_name == 'pull_request' | ||
run: bash .github/scripts/fetch-base-incrementally.sh "${{ github.event.pull_request.base.ref }}" | ||
samlaf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- uses: jdx/mise-action@v2 | ||
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. can we use the hash here as well please. 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. You mean for mise? I can open a separate PR for that if you'd like, since it's not related to this linter change. |
||
with: | ||
version: ${{ env.MISE_VERSION }} | ||
experimental: true | ||
- run: go version | ||
- run: make lint | ||
|
||
- name: Run linter | ||
run: | | ||
# Use PR base branch if available, otherwise the command line flag is ignored and master is used | ||
golangci-lint run --new-from-rev=origin/${{ github.event.pull_request.base.ref || 'master' }} | ||
samlaf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- run: make fmt-check |
Uh oh!
There was an error while loading. Please reload this page.