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

Use jq to make parsing GECKODRIVER API call reproducible #2945

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

GregSutcliffe
Copy link
Contributor

@GregSutcliffe GregSutcliffe commented Nov 1, 2024

Description
The curl call to the GitHub API to get the latest release of GECKODRIVER fails intermittently. The call looks like this:

curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest

On investigation, this appears to be because GitHub itself isn't consistent it how it returns the API data - sometimes it's a nicely formatted output, eg:

# cat good_response.json
{
  "url": "https://api.github.com/repos/mozilla/geckodriver/releases/168891133",
  "assets_url": "https://api.github.com/repos/mozilla/geckodriver/releases/168891133/assets",
  "upload_url": "https://uploads.github.com/repos/mozilla/geckodriver/releases/168891133/assets{?name,label}",
  "html_url": "https://github.com/mozilla/geckodriver/releases/tag/v0.35.0",
...

but sometimes it removes the newlines:

cat bad_response.json
{"url":"https://api.github.com/repos/mozilla/geckodriver/releases/168891133","assets_url":"https://api.github.com/repos/mozilla/geckodriver/releases/168891133/assets","upload_url":"https://uploads.github.com/repos/mozilla/geckodriver/releases/168891133/assets{?name,label}","html_url":"https://github.com/mozilla/geckodriver/releases/tag/v0.35.0"...

This second form causes the grep/sed combo to fail, since the grep now matches the entire output instead of one line.

This PR fixes the issue by using JQ to parse the output, which works regardless of form:

# cat /tmp/good_response.json | jq -r '.tag_name' | sed 's/v//'
0.35.0

# cat /tmp/bad_response.json | jq -r '.tag_name' | sed 's/v//'                                                                                                                         
0.35.0

Signed commits

  • Yes, I signed my commits.

@sgoggins sgoggins added docker Related to our Docker images admin Administrative/housekeeping/community tasks labels Nov 4, 2024
Copy link
Member

@sgoggins sgoggins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!!

@sgoggins sgoggins merged commit ede2912 into chaoss:main Nov 4, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
admin Administrative/housekeeping/community tasks docker Related to our Docker images
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants