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

Fetch changed files from PR in chunks #3117

Merged
merged 2 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/eamxx-sa-sanitizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:
jobs:
gcc-openmp:
runs-on: [self-hosted, ghci-snl-cpu, gcc]
name: gcc-openmp / cov
name: gcc-openmp / valg
steps:
- name: Check out the repository
uses: actions/checkout@v4
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/eamxx-sa-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,22 @@ jobs:
pattern=$(IFS=\|; echo "${paths[*]}")

# Use the GitHub API to get the list of changed files
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }}/files")
changed_files=$(echo "$response" | grep -o '"filename": *"[^"]*"' | sed 's/"filename": *//; s/"//g')
# There are page size limits, so do it in chunks
page=1
while true; do
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/E3SM-Project/scream/pulls/${{ github.event.number }}/files?per_page=100&page=$page")

# Check if the response is empty, and break if it is
[ -z "$response" ] && break

changed_files+=$(echo "$response" | grep -o '"filename": *"[^"]*"' | sed 's/"filename": *//; s/"//g')$'\n'

# Check if there are more pages, and quite if there aren't
[[ $(echo "$response" | jq '. | length') -lt 100 ]] && break

page=$((page + 1))
done

# Check for matches and echo the matching files (or "" if none)
matching_files=$(echo "$changed_files" | grep -E "^($pattern)" || echo "")
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/eamxx-scripts-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,22 @@ jobs:
pattern=$(IFS=\|; echo "${paths[*]}")

# Use the GitHub API to get the list of changed files
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }}/files")
changed_files=$(echo "$response" | grep -o '"filename": *"[^"]*"' | sed 's/"filename": *//; s/"//g')
# There are page size limits, so do it in chunks
page=1
while true; do
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/E3SM-Project/scream/pulls/${{ github.event.number }}/files?per_page=100&page=$page")

# Check if the response is empty, and break if it is
[ -z "$response" ] && break

changed_files+=$(echo "$response" | grep -o '"filename": *"[^"]*"' | sed 's/"filename": *//; s/"//g')$'\n'

# Check if there are more pages, and quite if there aren't
[[ $(echo "$response" | jq '. | length') -lt 100 ]] && break

page=$((page + 1))
done

# Check for matches and echo the matching files (or "" if none)
matching_files=$(echo "$changed_files" | grep -E "^($pattern)" || echo "")
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/eamxx-v1-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,22 @@ jobs:
pattern=$(IFS=\|; echo "${paths[*]}")

# Use the GitHub API to get the list of changed files
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }}/files")
changed_files=$(echo "$response" | grep -o '"filename": *"[^"]*"' | sed 's/"filename": *//; s/"//g')
# There are page size limits, so do it in chunks
page=1
while true; do
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/E3SM-Project/scream/pulls/${{ github.event.number }}/files?per_page=100&page=$page")

# Check if the response is empty, and break if it is
[ -z "$response" ] && break

changed_files+=$(echo "$response" | grep -o '"filename": *"[^"]*"' | sed 's/"filename": *//; s/"//g')$'\n'

# Check if there are more pages, and quite if there aren't
[[ $(echo "$response" | jq '. | length') -lt 100 ]] && break

page=$((page + 1))
done

# Check for matches and echo the matching files (or "" if none)
matching_files=$(echo "$changed_files" | grep -E "^($pattern)" || echo "")
Expand Down
Loading