-
Notifications
You must be signed in to change notification settings - Fork 118
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
Use pagination when requesting github API #1168
Use pagination when requesting github API #1168
Conversation
7bb87a3
to
d14728d
Compare
/test-ubuntu-integration-e2e-main |
/test-centos-integration-release-1-3 |
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.
Some changes needed.
lib/releases.sh
Outdated
if [ -z "${GITHUB_TOKEN:-}" ]; then | ||
release="$(curl -sL "${1}")" || ( set -x && exit 1 ) | ||
last_page=$(curl -s -I "${1}" -H "Authorization: token $GITHUB_TOKEN" | grep '^link:' | sed -e 's/^link:.*page=//g' -e 's/>.*$//g') || (set -x && exit 1) |
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.
(set -x && exit 1)
creates a subshell, the parenthesis does that, so the exit 1
exits only that subshell, and not the script. If you want to perform two actions, use curly braces, {set -x && exit 1}
.
Also, you want to assign the subshell output of $( ... )
with quotes, so do last_page="$( ... )"
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.
shellcheck complaining about {set -x && exit 1}
and ${set -x && exit 1}
not working as expected do you know what is wrong
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.
${set -x ...}
is definitely wrong, but what does it complain about { set -x ... }
?
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.
You need semicolon at the end { set -x && exit 1; }
.
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.
thanks! done
lib/releases.sh
Outdated
else | ||
release="$(curl -H "Authorization: token ${GITHUB_TOKEN}" -sL "${1}")" || ( set -x && exit 1 ) | ||
last_page=$(curl -s -I "${1}" | grep '^link:' | sed -e 's/^link:.*page=//g' -e 's/>.*$//g') || (set -x && exit 1) |
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.
same here
lib/releases.sh
Outdated
# selection is possible given specific enough prefix, like v1.3.0-pre | ||
release_tag="$(echo "$release" | jq -r "[.[].tag_name | select( startswith(\"${2:-}\"))] | .[0]")" | ||
# default last page to 1 | ||
last_page=${last_page:-1} |
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.
Quotes do no harm here either.
lib/releases.sh
Outdated
url="${1}?page=${current_page}" | ||
|
||
if [ -z "${GITHUB_TOKEN:-}" ]; then | ||
release="$(curl -sL "${url}")" || (set -x && exit 1) |
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.
same as the first one
lib/releases.sh
Outdated
if [ -z "${GITHUB_TOKEN:-}" ]; then | ||
release="$(curl -sL "${url}")" || (set -x && exit 1) | ||
else | ||
release="$(curl -H "Authorization: token ${GITHUB_TOKEN}" -sL "${url}")" || (set -x && exit 1) |
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.
same as the first one
lib/releases.sh
Outdated
# The order is exactly as released in Github. | ||
# Downside is that selecting official releases only isn't possible, while pre-release | ||
# selection is possible given specific enough prefix, like v1.3.0-pre | ||
release_tag="$(echo "$release" | jq -r "[.[].tag_name | select( startswith(\"${2:-}\"))] | .[0]")" |
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.
Add curlys to $release
lib/releases.sh
Outdated
# selection is possible given specific enough prefix, like v1.3.0-pre | ||
release_tag="$(echo "$release" | jq -r "[.[].tag_name | select( startswith(\"${2:-}\"))] | .[0]")" | ||
# if release tag found | ||
if [[ "$release_tag" != "null" ]]; then |
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.
same
d14728d
to
be8b0df
Compare
4ec57f1
to
ba20246
Compare
/test-centos-integration-release-1-3 |
/test-ubuntu-integration-e2e-main |
ba20246
to
cfe8652
Compare
/test-ubuntu-integration-e2e-main |
/lgtm |
/test-centos-integration-release-1-3 |
/test-ubuntu-e2e-integration-main |
/assign @furkatgofurov7 |
/hold |
cfe8652
to
8376ca5
Compare
/test-centos-integration-release-1-3 |
command -v jq &>/dev/null && echo "Failed to fetch CAPI release from Github" && exit 1 | ||
fi | ||
|
||
if [[ "$CAPM3RELEASE" == "" ]]; then | ||
command -v jq &> /dev/null && echo "Failed to fetch CAPM3 release from Github" && exit 1 | ||
command -v jq &>/dev/null && echo "Failed to fetch CAPM3 release from Github" && exit 1 | ||
fi | ||
|
||
if [[ "$BMORELEASE" == "" ]]; then | ||
command -v jq &> /dev/null && echo "Failed to fetch BMO release from Github" && exit 1 | ||
command -v jq &>/dev/null && echo "Failed to fetch BMO release from Github" && exit 1 | ||
fi |
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.
Why remove the space here? I think it is easier to read with the space so we should add it back.
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.
it was auto reformatted by editor formatter! do we have coding style for that
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.
@tuminoid any input on this? I'm inclined to approve it as just a matter of preference if there are no objections.
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.
That space is completely up to personal taste. I tend to have the space there for readability, but it doesn't really matter.
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.
Alright I'm putting lgtm then 🙂
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.
Checked locally, it works fine
/approve
/hold to address the comments from @lentzi90
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: furkatgofurov7 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test-ubuntu-e2e-integration-main |
1 similar comment
/test-ubuntu-e2e-integration-main |
/lgtm |
/hold cancel |
Fix #1162