| 1 | #!/bin/bash |
| 2 | ## ------------------------------------------------------------------------ |
| 3 | ## |
| 4 | ## SPDX-License-Identifier: LGPL-2.1-or-later |
| 5 | ## Copyright (C) 2018 - 2022 by the deal.II authors |
| 6 | ## |
| 7 | ## This file is part of the deal.II library. |
| 8 | ## |
| 9 | ## Part of the source code is dual licensed under Apache-2.0 WITH |
| 10 | ## LLVM-exception OR LGPL-2.1-or-later. Detailed license information |
| 11 | ## governing the source code and code contributions can be found in |
| 12 | ## LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. |
| 13 | ## |
| 14 | ## ------------------------------------------------------------------------ |
| 15 | set -eu |
| 16 | |
| 17 | BASE_URL="https://cdash.dealii.org" |
| 18 | |
| 19 | # Script to query CDash on the command line and create a formatted table |
| 20 | |
| 21 | links=false |
| 22 | regex=".*" |
| 23 | |
| 24 | print_help() { |
| 25 | echo "Usage: query_testsuite [-c|--commit <commit>] [-l|--links] [-h|--help]" |
| 26 | echo "" |
| 27 | echo "Queries the CDash on the command line and creates a formatted table" |
| 28 | echo "compatible with markdown" |
| 29 | echo "" |
| 30 | echo "Options:" |
| 31 | echo " -r (--regex) : only show results for hosts/commits matching the specified regex" |
| 32 | echo " -l (--links) : include hyperlinks" |
| 33 | echo " -h (--help) : print this help message" |
| 34 | } |
| 35 | |
| 36 | until [[ "$*" == "" ]]; do |
| 37 | if [[ "$1" == -h || "$1" == --help ]]; then |
| 38 | print_help |
| 39 | exit 1 |
| 40 | elif [[ "$1" == -l || "$1" == --links ]]; then |
| 41 | links=true |
| 42 | elif [[ "$1" == -r || "$1" == --regex ]]; then |
| 43 | shift |
| 44 | regex="$1" |
| 45 | else |
| 46 | print_help |
| 47 | exit 1 |
| 48 | fi |
| 49 | shift |
| 50 | done |
| 51 | |
| 52 | if [ -z "$(command -v jq)" ]; then |
| 53 | echo "Error: need jq executable in path" |
| 54 | echo "Please install jq (sudo apt install jq, sudo yum install jq)" |
| 55 | exit 1 |
| 56 | fi |
| 57 | |
| 58 | query_testsuite() { |
| 59 | |
| 60 | echo "| Host | Configuration | Commit | Build errors | Build warnings | Failing tests | Passing tests |" |
| 61 | echo "| - | - | - | :-: | :-: | :-: | :-: |" |
| 62 | |
| 63 | curl -s "${BASE_URL}/api/v1/index.php?project=deal.II" | |
| 64 | jq -r ".buildgroups | .[] | .builds | .[] | .id , .site , .buildname, .update.files, .compilation.error, .compilation.warning, .test.fail, .test.pass" | |
| 65 | paste -d ' ' - - - - - - - - | |
| 66 | sort -n | |
| 67 | if $links; then |
| 68 | awk "{ print \$2, |
| 69 | \"[\" \$3 \"](${BASE_URL}/buildSummary.php?buildid=\" \$1 \")\", \ |
| 70 | \"[\" \$4 \"](${BASE_URL}/viewUpdate.php?buildid=\" \$1 \")\", \ |
| 71 | \"[\" \$5 \"](${BASE_URL}/viewBuildError.php?buildid=\" \$1 \")\", \ |
| 72 | \"[\" \$6 \"](${BASE_URL}/viewBuildError.php?type=1&buildid=\" \$1 \")\", \ |
| 73 | \"[\" \$7 \"](${BASE_URL}/viewTest.php?onlyfailed&buildid=\" \$1 \")\", \ |
| 74 | \"[\" \$8 \"](${BASE_URL}/viewTest.php?onlypassed&buildid=\" \$1 \")\" |
| 75 | }" |
| 76 | else |
| 77 | awk '{$1=""; print $0}' |
| 78 | fi | |
| 79 | sed -e 's#^ ##' -e 's# # | #g' -e 's#^#| #' -e 's#$# |#' | |
| 80 | grep -P "${regex}" | |
| 81 | cat |
| 82 | } |
| 83 | |
| 84 | query_testsuite |