-
Notifications
You must be signed in to change notification settings - Fork 111
Add script to check if a library is supported by the GraalVM Reachability Metadata repository #811
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
base: master
Are you sure you want to change the base?
Changes from all commits
0742e36
600eac8
4bd1a83
da3ebb0
c675cd5
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,47 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Copyright and related rights waived via CC0 | ||
| # | ||
| # You should have received a copy of the CC0 legalcode along with this | ||
| # work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| if [ "$#" -ne 1 ]; then | ||
| echo "Usage: $0 <groupId>:<artifactId>:<version>" | ||
|
Member
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. If the library is not parsing properly we need to display nice errors.
Member
Author
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. I've added an additional check if the argument provided to the command is in the GAV format (displaying an error if wrong format is used). |
||
| exit 1 | ||
| fi | ||
|
|
||
| GAV="$1" | ||
|
|
||
| if ! [[ "$GAV" =~ ^[^:]+:[^:]+:[^:]+$ ]]; then | ||
| echo "Invalid library format: '$GAV'" | ||
| echo "Expected format: <groupId>:<artifactId>:<version>" | ||
| exit 1 | ||
| fi | ||
|
|
||
| IFS=':' read -r GROUP ARTIFACT VERSION <<< "$GAV" | ||
|
|
||
| REMOTE_BASE_URL="https://raw.githubusercontent.com/oracle/graalvm-reachability-metadata/master/metadata" | ||
| REMOTE_INDEX_URL="$REMOTE_BASE_URL/$GROUP/$ARTIFACT/index.json" | ||
|
|
||
| INDEX_CONTENT=$(curl -fsSL "$REMOTE_INDEX_URL" 2>/dev/null || true) | ||
|
|
||
| if [[ -z "$INDEX_CONTENT" ]]; then | ||
| echo "Library $GAV is NOT supported by the GraalVM Reachability Metadata repository." | ||
| exit 1 | ||
| fi | ||
|
|
||
| FOUND=$( | ||
| awk -v ver="$VERSION" ' | ||
| /"tested-versions"[[:space:]]*:/ {inside=1; next} | ||
| inside && /\]/ {inside=0} | ||
| inside && $0 ~ "\"" ver "\"" {print "yes"} | ||
| ' <<< "$INDEX_CONTENT" | ||
| ) | ||
|
|
||
| if [ "$FOUND" = "yes" ]; then | ||
| echo "Library $GAV is supported by the GraalVM Reachability Metadata repository." | ||
| else | ||
| echo "Library $GAV is NOT supported by the GraalVM Reachability Metadata repository." | ||
| 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.
On which OS-es does this script work?
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.
Maybe mention that in the readme.
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.
The script should have native support on Linux and macOS, while Windows can run it through channels such as
WSLorWindows Git Bash. I've added a line in the README explaining this.