Skip to content

Instantly share code, notes, and snippets.

@EverlastingBugstopper
Last active August 24, 2022 10:14
Show Gist options
  • Save EverlastingBugstopper/d6aa0d9a49bcf39f2df53e1cfb9bb88a to your computer and use it in GitHub Desktop.
Save EverlastingBugstopper/d6aa0d9a49bcf39f2df53e1cfb9bb88a to your computer and use it in GitHub Desktop.

Revisions

  1. EverlastingBugstopper revised this gist Sep 23, 2021. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions rover_check_markdown.sh
    Original file line number Diff line number Diff line change
    @@ -59,4 +59,11 @@ if [ $CHECK_SUCCESS = "false" ]; then
    echo $(_jq '.message')
    done
    fi

    CHECK_URL=$(echo $CHECK_OUTPUT | jq '.data.target_url')
    if [ $CHECK_URL != null ]; then
    echo ""
    echo "See more details in [Apollo Studio]($CHECK_URL)"
    fi

    echo ""
  2. EverlastingBugstopper revised this gist Sep 23, 2021. 1 changed file with 22 additions and 22 deletions.
    44 changes: 22 additions & 22 deletions rover_check_markdown.sh
    Original file line number Diff line number Diff line change
    @@ -6,30 +6,35 @@ CHECK_OUTPUT=$(rover subgraph check my-graph --schema ./products.graphql --name

    CHECK_SUCCESS=$(echo $CHECK_OUTPUT | jq '.data.success')

    if [ "$CHECK_SUCCESS" = "true" ]; then
    if [ $CHECK_SUCCESS = "true" ]; then
    echo "### Check Success"
    echo ""
    echo $CHECK_OUTPUT | jq '.data'
    echo "#### Change Details"
    echo ""
    fi

    CHANGES=$(echo "${CHECK_OUTPUT}" | jq '.data.changes')
    if [ "$CHANGES" != "null" ]; then
    echo "#### Change Details"
    echo ""
    echo "| Severity | Code | Description |"
    echo "| -------- | ---- | ----------- |"
    CHANGE_SIZE=$(echo "${CHECK_OUTPUT}" | jq -r '.data.changes | length')
    if [ "$CHANGE_SIZE" = "0" ]; then
    echo "No changes"
    fi

    for CHANGE in $(echo "${CHECK_OUTPUT}" | jq -r '.data.changes[] | @base64'); do
    _jq() {
    echo ${CHANGE} | base64 --decode | jq -r ${1}
    }
    if [ "$CHANGE_SIZE" != "0" ]; then
    echo "| Severity | Code | Description |"
    echo "| -------- | ---- | ----------- |"

    CHANGE_SEVERITY=$(_jq '.severity')
    CHANGE_CODE=$(_jq '.code')
    CHANGE_DESCRIPTION=$(_jq '.description')
    echo "| $CHANGE_SEVERITY | $CHANGE_CODE | $CHANGE_DESCRIPTION |"
    done
    for CHANGE in $(echo "${CHECK_OUTPUT}" | jq -r '.data.changes[] | @base64'); do
    _jq() {
    echo ${CHANGE} | base64 -d | jq -r ${1}
    }

    CHANGE_SEVERITY=$(_jq '.severity')
    CHANGE_CODE=$(_jq '.code')
    CHANGE_DESCRIPTION=$(_jq '.description')
    echo "| $CHANGE_SEVERITY | $CHANGE_CODE | $CHANGE_DESCRIPTION |"
    done
    fi
    echo ""
    fi

    @@ -42,7 +47,7 @@ if [ $CHECK_SUCCESS = "false" ]; then
    echo ""
    for BUILD_ERROR in $(echo "${CHECK_OUTPUT}" | jq -r '.error.details.build_errors[] | @base64'); do
    _jq() {
    echo ${BUILD_ERROR} | base64 --decode | jq -r ${1}
    echo ${BUILD_ERROR} | base64 -d | jq -r ${1}
    }
    BUILD_ERROR_CODE=$(_jq '.code')
    if [ $BUILD_ERROR_CODE != "null" ]; then
    @@ -53,10 +58,5 @@ if [ $CHECK_SUCCESS = "false" ]; then

    echo $(_jq '.message')
    done

    CHECK_URL=$(echo $CHECK_OUTPUT | jq '.data.target_url')
    if [ $CHECK_URL != null ]; then
    echo ""
    echo "See more details in [Apollo Studio]($CHECK_URL)"
    fi
    fi
    echo ""
  3. EverlastingBugstopper revised this gist Sep 23, 2021. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions rover_check_markdown.sh
    Original file line number Diff line number Diff line change
    @@ -6,13 +6,14 @@ CHECK_OUTPUT=$(rover subgraph check my-graph --schema ./products.graphql --name

    CHECK_SUCCESS=$(echo $CHECK_OUTPUT | jq '.data.success')

    if [ $CHECK_SUCCESS = "true" ]; then
    if [ "$CHECK_SUCCESS" = "true" ]; then
    echo "### Check Success"
    echo ""
    echo $CHECK_OUTPUT | jq '.data'
    fi

    if [ $(echo "${CHECK_OUTPUT}" | jq '.data.changes') != "null" ]; then
    CHANGES=$(echo "${CHECK_OUTPUT}" | jq '.data.changes')
    if [ "$CHANGES" != "null" ]; then
    echo "#### Change Details"
    echo ""
    echo "| Severity | Code | Description |"
  4. EverlastingBugstopper created this gist Sep 22, 2021.
    61 changes: 61 additions & 0 deletions rover_check_markdown.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,61 @@
    #! /bin/bash
    # This script performs a subgraph check and generates a markdown file from Rover's JSON output

    # Change the following line to refer to your graph ref, schema, and subgraph name
    CHECK_OUTPUT=$(rover subgraph check my-graph --schema ./products.graphql --name products --output json)

    CHECK_SUCCESS=$(echo $CHECK_OUTPUT | jq '.data.success')

    if [ $CHECK_SUCCESS = "true" ]; then
    echo "### Check Success"
    echo ""
    echo $CHECK_OUTPUT | jq '.data'
    fi

    if [ $(echo "${CHECK_OUTPUT}" | jq '.data.changes') != "null" ]; then
    echo "#### Change Details"
    echo ""
    echo "| Severity | Code | Description |"
    echo "| -------- | ---- | ----------- |"

    for CHANGE in $(echo "${CHECK_OUTPUT}" | jq -r '.data.changes[] | @base64'); do
    _jq() {
    echo ${CHANGE} | base64 --decode | jq -r ${1}
    }

    CHANGE_SEVERITY=$(_jq '.severity')
    CHANGE_CODE=$(_jq '.code')
    CHANGE_DESCRIPTION=$(_jq '.description')
    echo "| $CHANGE_SEVERITY | $CHANGE_CODE | $CHANGE_DESCRIPTION |"
    done

    echo ""
    fi

    if [ $CHECK_SUCCESS = "false" ]; then
    echo "### Check Failure"
    echo ""
    echo $CHECK_OUTPUT | jq -r '.error.message'
    echo ""
    echo "#### Error Details"
    echo ""
    for BUILD_ERROR in $(echo "${CHECK_OUTPUT}" | jq -r '.error.details.build_errors[] | @base64'); do
    _jq() {
    echo ${BUILD_ERROR} | base64 --decode | jq -r ${1}
    }
    BUILD_ERROR_CODE=$(_jq '.code')
    if [ $BUILD_ERROR_CODE != "null" ]; then
    echo -n "$BUILD_ERROR_CODE: "
    else
    echo -n "UNKNOWN: "
    fi

    echo $(_jq '.message')
    done

    CHECK_URL=$(echo $CHECK_OUTPUT | jq '.data.target_url')
    if [ $CHECK_URL != null ]; then
    echo ""
    echo "See more details in [Apollo Studio]($CHECK_URL)"
    fi
    fi