https://gitlab.com/tezos/tezos
Raw File
Tip revision: 81301dd08ec57b85f9a09e61de488f3960135dfb authored by Arvid Jakobsson on 28 March 2024, 11:34:37 UTC
CIAO: remove functions for writing external jobs
Tip revision: 81301dd
report_coverage.sh
#!/bin/sh

set -eu

if [ -z "$(find "$BISECT_FILE" -maxdepth 1 -name '*.corrupt.json' -print -quit)" ]; then
  # Compute coverage
  make coverage-report
  # Rewrite the summary output to remove information points matching the coverage regexp below
  make coverage-report-summary | sed 's@Coverage: [[:digit:]]\+/[[:digit:]]\+ (\(.*%\))@Coverage: \1@'
  make coverage-report-cobertura
  exit 0
else
  # Corrupt coverage files were detected
  echo "Corrupted coverage files were generated by the following jobs, please report this in https://gitlab.com/tezos/tezos/-/issues/1529: "
  find "$BISECT_FILE" -maxdepth 1 -name '*.corrupt.json' -exec \
    jq -r '"  • Job `" + .job_name + "` (" + .job_web_url + ")"' \{\} \;

  if [ "${SLACK_COVERAGE_TOKEN:-}" != "" ]; then
    slack_msg=$(
      echo "⚠️ Corrupted coverage file(s) found in pipeline <$CI_PIPELINE_URL|#$CI_PIPELINE_ID> ⚠️"
      echo
      find "$BISECT_FILE" -maxdepth 1 -name '*.corrupt.json' -exec \
        jq -r '"  • Job <" + .job_web_url + "|#" + (.job_id|tostring) + "> (`" + .job_name + "`)"' \{\} \;
    )
    curl --silent \
      -H "Authorization: Bearer $SLACK_COVERAGE_TOKEN" \
      -d "channel=$SLACK_COVERAGE_CHANNEL" \
      -d "text=${slack_msg}" \
      -X POST https://slack.com/api/chat.postMessage -o slack-response.json
    jq --exit-status '.ok' < slack-response.json > /dev/null || {
      echo "Slack notification unsuccessful, response received:"
      jq < slack-response.json
      exit 1
    }
    echo "Slack notification posted to channel $SLACK_COVERAGE_CHANNEL"
  fi

  exit 64
fi
back to top