Skip to content

Commit ed62e69

Browse files
authored
Merge pull request #3117 from E3SM-Project/bartgol/workflows/fix-pre-process-pr
Fetch changed files from PR in chunks
2 parents 37dea04 + 0f2c4ba commit ed62e69

File tree

4 files changed

+49
-10
lines changed

4 files changed

+49
-10
lines changed

.github/workflows/eamxx-sa-sanitizer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ env:
2424
jobs:
2525
gcc-openmp:
2626
runs-on: [self-hosted, ghci-snl-cpu, gcc]
27-
name: gcc-openmp / cov
27+
name: gcc-openmp / valg
2828
steps:
2929
- name: Check out the repository
3030
uses: actions/checkout@v4

.github/workflows/eamxx-sa-testing.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,22 @@ jobs:
6767
pattern=$(IFS=\|; echo "${paths[*]}")
6868
6969
# Use the GitHub API to get the list of changed files
70-
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
71-
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }}/files")
72-
changed_files=$(echo "$response" | grep -o '"filename": *"[^"]*"' | sed 's/"filename": *//; s/"//g')
70+
# There are page size limits, so do it in chunks
71+
page=1
72+
while true; do
73+
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
74+
"https://api.github.com/repos/E3SM-Project/scream/pulls/${{ github.event.number }}/files?per_page=100&page=$page")
75+
76+
# Check if the response is empty, and break if it is
77+
[ -z "$response" ] && break
78+
79+
changed_files+=$(echo "$response" | grep -o '"filename": *"[^"]*"' | sed 's/"filename": *//; s/"//g')$'\n'
80+
81+
# Check if there are more pages, and quite if there aren't
82+
[[ $(echo "$response" | jq '. | length') -lt 100 ]] && break
83+
84+
page=$((page + 1))
85+
done
7386
7487
# Check for matches and echo the matching files (or "" if none)
7588
matching_files=$(echo "$changed_files" | grep -E "^($pattern)" || echo "")

.github/workflows/eamxx-scripts-tests.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,22 @@ jobs:
5050
pattern=$(IFS=\|; echo "${paths[*]}")
5151
5252
# Use the GitHub API to get the list of changed files
53-
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
54-
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }}/files")
55-
changed_files=$(echo "$response" | grep -o '"filename": *"[^"]*"' | sed 's/"filename": *//; s/"//g')
53+
# There are page size limits, so do it in chunks
54+
page=1
55+
while true; do
56+
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
57+
"https://api.github.com/repos/E3SM-Project/scream/pulls/${{ github.event.number }}/files?per_page=100&page=$page")
58+
59+
# Check if the response is empty, and break if it is
60+
[ -z "$response" ] && break
61+
62+
changed_files+=$(echo "$response" | grep -o '"filename": *"[^"]*"' | sed 's/"filename": *//; s/"//g')$'\n'
63+
64+
# Check if there are more pages, and quite if there aren't
65+
[[ $(echo "$response" | jq '. | length') -lt 100 ]] && break
66+
67+
page=$((page + 1))
68+
done
5669
5770
# Check for matches and echo the matching files (or "" if none)
5871
matching_files=$(echo "$changed_files" | grep -E "^($pattern)" || echo "")

.github/workflows/eamxx-v1-testing.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,22 @@ jobs:
5454
pattern=$(IFS=\|; echo "${paths[*]}")
5555
5656
# Use the GitHub API to get the list of changed files
57-
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
58-
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }}/files")
59-
changed_files=$(echo "$response" | grep -o '"filename": *"[^"]*"' | sed 's/"filename": *//; s/"//g')
57+
# There are page size limits, so do it in chunks
58+
page=1
59+
while true; do
60+
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
61+
"https://api.github.com/repos/E3SM-Project/scream/pulls/${{ github.event.number }}/files?per_page=100&page=$page")
62+
63+
# Check if the response is empty, and break if it is
64+
[ -z "$response" ] && break
65+
66+
changed_files+=$(echo "$response" | grep -o '"filename": *"[^"]*"' | sed 's/"filename": *//; s/"//g')$'\n'
67+
68+
# Check if there are more pages, and quite if there aren't
69+
[[ $(echo "$response" | jq '. | length') -lt 100 ]] && break
70+
71+
page=$((page + 1))
72+
done
6073
6174
# Check for matches and echo the matching files (or "" if none)
6275
matching_files=$(echo "$changed_files" | grep -E "^($pattern)" || echo "")

0 commit comments

Comments
 (0)