aboutsummaryrefslogtreecommitdiffhomepage
path: root/.travis-ci.sh
blob: 593b254d62f910b0654c1096a967e562a4a4736f (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash

# This script is triggered from the script section of .travis.yml
# It runs the appropriate commands depending on the task requested.

set -e

COVERITY_SCAN_BUILD_URL="https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh"

SPELLINGBLACKLIST=$(cat <<-BLACKLIST
      -wholename "./.git/*"
BLACKLIST
)

if [[ $TASK = 'spellintian' ]]; then
  # run spellintian only if it is the requested task, ignoring duplicate words
  spellingfiles=$(eval "find ./ -type f -and ! \( \
      $SPELLINGBLACKLIST \
      \) | xargs")
  # count the number of spellintian errors, ignoring duplicate words
  spellingerrors=$(zrun spellintian $spellingfiles 2>&1 | grep -v "\(duplicate word\)" | wc -l)
  if [[ $spellingerrors -ne 0 ]]; then
    # print the output for info
    zrun spellintian $spellingfiles | grep -v "\(duplicate word\)"
    echo "Found $spellingerrors spelling errors via spellintian, ignoring duplicates"
    exit 1;
  else
    echo "Found $spellingerrors spelling errors via spellintian, ignoring duplicates"
  fi;
elif [[ $TASK = 'spellintian-duplicates' ]]; then
  # run spellintian only if it is the requested task
  spellingfiles=$(eval "find ./ -type f -and ! \( \
      $SPELLINGBLACKLIST \
      \) | xargs")
  # count the number of spellintian errors
  spellingerrors=$(zrun spellintian $spellingfiles 2>&1 | wc -l)
  if [[ $spellingerrors -ne 0 ]]; then
    # print the output for info
    zrun spellintian $spellingfiles
    echo "Found $spellingerrors spelling errors via spellintian"
    exit 1;
  else
    echo "Found $spellingerrors spelling errors via spellintian"
  fi;
elif [[ $TASK = 'codespell' ]]; then
  # run codespell only if it is the requested task
  spellingfiles=$(eval "find ./ -type f -and ! \( \
      $SPELLINGBLACKLIST \
      \) | xargs")
  # count the number of codespell errors
  spellingerrors=$(zrun codespell --check-filenames --check-hidden --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" $spellingfiles 2>&1 | wc -l)
  if [[ $spellingerrors -ne 0 ]]; then
    # print the output for info
    zrun codespell --check-filenames --check-hidden --quiet 2 --regex "[a-zA-Z0-9][\\-'a-zA-Z0-9]+[a-zA-Z0-9]" $spellingfiles
    echo "Found $spellingerrors spelling errors via codespell"
    exit 1;
  else
    echo "Found $spellingerrors spelling errors via codespell"
  fi;
elif [[ $TASK = 'coverity' ]]; then
  # Run Coverity Scan unless token is zero length
  # The Coverity Scan script also relies on a number of other COVERITY_SCAN_
  # variables set in .travis.yml
  if [[ ${#COVERITY_SCAN_TOKEN} -ne 0 ]]; then
    curl -s $COVERITY_SCAN_BUILD_URL | bash
  else
    echo "Skipping Coverity Scan as no token found, probably a Pull Request"
  fi;
elif [[ $TASK = 'sanitize' ]]; then
  # Run sanitized compile
  travis_fold start "make_sanitize"
  make sanitize;
  travis_fold end "make_sanitize"
elif [[ $TASK = 'windows' ]]; then
  # Run sanitized compile
  travis_fold start "make_windows"
  make windows;
  travis_fold end "make_windows"
  
  if [ "$(git describe)" == "$(git describe --abbrev=0)" ]; then
    mkdir ./deployment
    mkdir ./deployment/backends
    mkdir ./deployment/docs
    cp ./midimonster.exe ./deployment/
    cp ./backends/*.dll ./deployment/backends/
    cp ./monster.cfg ./deployment/monster.cfg
    cp ./backends/*.md ./deployment/docs/
    cp -r ./configs ./deployment/
    cd ./deployment
    zip -r "./midimonster-$(git describe)-windows.zip" "./"
    rm -v !("*.zip")
  fi


else
  # Otherwise compile as normal
  travis_fold start "make"
  make full;

if [ "$(git describe)" == "$(git describe --abbrev=0)" ]; then
  mkdir ./deployment
  mkdir ./deployment/backends
  mkdir ./deployment/docs
  cp ./midimonster ./deployment/
  cp ./backends/*.so ./deployment/backends/
  cp ./monster.cfg ./deployment/monster.cfg
  cp ./backends/*.md ./deployment/docs/
  cp -r ./configs ./deployment/
  cd ./deployment
  tar czf "midimonster-$(git describe)-linux64.tgz" *
  rm -v !("*.tgz")
  fi

  travis_fold end "make"
fi