summaryrefslogtreecommitdiffstats
path: root/extras/hs-test/script/compress.sh
blob: 1f0205c1efb8ba7d268046bff28d68ed89c9344c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash

# if failed-summary.log is not empty, exit status = 1
if [ -s "${HS_ROOT}/summary/failed-summary.log" ]
then
    if [ -n "${WORKSPACE}" ]
    then
        echo -n "Copying docker logs..."
        dirs=$(jq -r '.[0] | .SpecReports[] | select(.State == "failed") | .LeafNodeText' ${HS_ROOT}/summary/report.json)
        for dirName in $dirs; do
            logDir=/tmp/hs-test/$dirName
            if [ -d "$logDir" ]; then
                mkdir -p ${WORKSPACE}/archives/summary
                cp -r $logDir ${WORKSPACE}/archives/summary/
            fi
        done
        echo "Done."

        echo -n "Copying failed test logs into build log archive directory (${WORKSPACE}/archives)... "
        mkdir -p ${WORKSPACE}/archives/summary
        cp -a ${HS_ROOT}/summary/* ${WORKSPACE}/archives/summary
        echo "Done."

        echo -n "Compressing files in ${WORKSPACE}/archives from test runs... "
        cd ${WORKSPACE}/archives
        find . -type f \( -name "*.json" -o -name "*.log" \) -exec gzip {} \;
        echo "Done."

    else
        echo "Not compressing files in temporary directories from test runs."
    fi
    exit 1
fi