1version: ~> 1.0
2dist: bionic
3language: python
4addons:
5  apt:
6    packages: [libapr1-dev, libaprutil1-dev, liblz4-dev, libutf8proc-dev, swig,
7               firefox-geckodriver, python3-tidylib]
8  homebrew:
9    packages: [python@3.9, subversion, geckodriver, tidy-html5]
10  firefox: latest
11cache:
12  ccache: true
13  directories:
14  - "$HOME/.cache/pip"
15  - "$HOME/.pyenv"
16  - "$HOME/src"
17  - "$HOME/Library/Caches/Homebrew"
18before_install:
19- set -e
20- test -d "$HOME/.pip" || mkdir "$HOME/.pip"
21- |
22  {
23    echo "[global]"
24    echo "cache-dir = $HOME/.cache/pip"
25    echo "[list]"
26    echo "format = columns"
27  } >"$HOME/.pip/pip.conf"
28- |
29  if [ "$TRAVIS_OS_NAME" = linux ]; then
30    : ${pyver:=$TRAVIS_PYTHON_VERSION}
31  elif [ "$TRAVIS_OS_NAME" = osx ]; then
32    python_prefix="$(brew --prefix python@3.9)"
33    export PATH="$python_prefix/libexec/bin:$PATH"
34    pyver="$(python -c 'import sys; print("%d.%d" % sys.version_info[:2])')"
35    venvdir="$HOME/venv-$pyver"
36    python -m venv "$venvdir"
37    source "$venvdir/bin/activate"
38    # Link Subversion bindings to the virtualenv
39    if [ "$build" != minimum ]; then
40      python_global="$python_prefix/libexec/bin/python"
41      print_sitelib='from distutils.sysconfig import get_python_lib; print(get_python_lib())'
42      sitelib_global="$($python_global -c "$print_sitelib")"
43      sitelib_venv="$(python -c "$print_sitelib")"
44      ln -s "$sitelib_global/svn" "$sitelib_venv/svn"
45      ln -s "$sitelib_global/libsvn" "$sitelib_venv/libsvn"
46      python -c 'from svn import core; print(str(core.SVN_VERSION, "ascii"))'
47    fi
48  else
49    echo "Unknown environment: '$TRAVIS_OS_NAME'"
50    exit 1
51  fi
52- pip install --upgrade pip setuptools wheel
53- python --version
54- pip list
55install:
56- set -e
57- |
58  if [ "$TRAVIS_BUILD_STAGE_NAME" = Test ]; then
59    requires='Jinja2 selenium pytidylib'
60    if [ "$build" != minimum ]; then requires="$requires Babel Pygments docutils textile pytz"; fi
61    if [ "$tracdb" = postgresql ]; then requires="$requires psycopg2"; fi
62    if [ "$tracdb" = mysql ]; then requires="$requires PyMySQL"; fi
63  else
64    requires='Jinja2 Babel'
65  fi
66  pip install $requires
67  python -c 'import sys, pkg_resources as p; p.require(sys.argv[1:])' $requires
68- pip list
69- |
70  if [ "$build" != minimum -a "$TRAVIS_BUILD_STAGE_NAME" = Test -a "$TRAVIS_OS_NAME" = linux ]; then
71  (
72    set -ex
73    test -d "$HOME/src" || mkdir "$HOME/src"
74    svnver=1.14.1
75    svnurl="https://archive.apache.org/dist/subversion/subversion-$svnver.tar.bz2"
76    svnsrc="$HOME/src/subversion-$svnver.tar.bz2"
77    svnpybin="$HOME/src/subversion-${svnver}-py${pyver}.tar.gz"
78    if ! tar xzf "$svnpybin" -C / || \
79      [ "$(python -c 'from svn import core; print(str(core.SVN_VER_NUM, "ascii"))')" != "$svnver" ];
80    then
81      curl -o "/tmp/subversion-$svnver.tar.bz2" "$svnurl"
82      mv "/tmp/subversion-$svnver.tar.bz2" "$svnsrc"
83      if git --git-dir "$HOME/src/py3c" count-objects >/dev/null 2>&1; then
84        git --git-dir "$HOME/src/py3c" fetch origin
85      else
86        rm -rf "$HOME/src/py3c"
87        git clone --mirror https://github.com/encukou/py3c "$HOME/src/py3c"
88      fi
89      test -d "$HOME/work" || mkdir "$HOME/work"
90      tar xaf "$svnsrc" -C "$HOME/work"
91      git --git-dir "$HOME/src/py3c" archive --format=tar --prefix=py3c/ v1.1 | tar xf - -C "$HOME/work"
92      set +ex
93      cd "$HOME/work/subversion-$svnver"
94      set -ex
95      prefix="$(python -c 'import sys; print(sys.prefix)')"
96      ./autogen.sh
97      ./configure \
98        --prefix="$prefix" \
99        --with-apr=/usr/bin/apr-1-config \
100        --with-apr-util=/usr/bin/apu-1-config \
101        --with-swig=/usr/bin/swig \
102        --with-py3c="$HOME/work/py3c" \
103        --without-apxs \
104        --without-doxygen \
105        --without-berkeley-db \
106        --without-gpg-agent \
107        --without-gnome-keyring \
108        --without-kwallet \
109        --without-jdk \
110        --disable-javahl \
111        PERL=none \
112        RUBY=none \
113        PYTHON="$(python -c 'import sys; print(sys.executable)')"
114      sitedir="$(python -c '\
115        import os, sys; \
116        print(os.path.join(sys.prefix, "lib", \
117                           "python{0}.{1}".format(*sys.version_info), \
118                           "site-packages")); \
119        ')"
120      # travis-ci environment has 2 cpu cores
121      make -j3 \
122        swig_pydir="$sitedir/libsvn" \
123        swig_pydir_extra="$sitedir/svn" \
124        all swig-py
125      make \
126        DESTDIR=/tmp/subversion-bin \
127        swig_pydir="$sitedir/libsvn" \
128        swig_pydir_extra="$sitedir/svn" \
129        install install-swig-py
130      tar czf "$svnpybin" -C /tmp/subversion-bin "${prefix#/}"
131      tar xzf "$svnpybin" -C /
132    fi
133    python -c 'from svn import core; print(str(core.SVN_VERSION, "ascii"))'
134  )
135  fi
136- |
137  case "$tracdb" in
138    sqlite)   tracdb_uri='sqlite:test.db' ;;
139    postgresql) tracdb_uri='postgres://tracuser:password@localhost/trac?schema=tractest' ;;
140    mysql)    tracdb_uri='mysql://tracuser:password@localhost/trac?charset=utf8mb4' ;;
141    *)        tracdb_uri= ;;
142  esac
143  echo ".uri = $tracdb_uri" >Makefile.cfg
144- echo "$tracdb_version"
145before_script:
146- |
147  case "$tracdb" in
148    postgresql)
149      if [ "$TRAVIS_OS_NAME" = osx ]; then
150        rm -rf /usr/local/var/postgres
151        pg_ctl initdb --pgdata /usr/local/var/postgres
152        pg_ctl -w start --pgdata /usr/local/var/postgres --log /usr/local/var/postgres/postgresql.log || {
153          rc=$?
154          cat /usr/local/var/postgres/postgresql.log
155          exit $rc
156        }
157        createuser -s postgres
158      fi
159      tracdb_version="PostgreSQL: $(psql -U postgres -t -c 'SELECT version()')"
160      echo "$tracdb_version"
161      psql -U postgres -e -c "CREATE USER tracuser NOSUPERUSER NOCREATEDB CREATEROLE PASSWORD 'password';"
162      psql -U postgres -e -c "CREATE DATABASE trac OWNER tracuser;"
163      tracdb_uri='postgres://tracuser:password@localhost/trac?schema=tractest'
164      ;;
165    mysql)
166      tracdb_version="MySQL: $(mysql -u root -sN -e 'SELECT version()')"
167      echo "$tracdb_version"
168      mysql -u root -v -e "CREATE DATABASE trac DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;"
169      mysql -u root -v -e "CREATE USER tracuser@localhost IDENTIFIED BY 'password';"
170      mysql -u root -v -e "GRANT ALL ON trac.* TO tracuser@localhost; FLUSH PRIVILEGES;"
171      tracdb_uri='mysql://tracuser:password@localhost/trac?charset=utf8mb4'
172      ;;
173    sqlite)
174      tracdb_version=
175      tracdb_uri='sqlite:test.db'
176      ;;
177    *)
178      tracdb_version=
179      tracdb_uri=
180      ;;
181  esac
182  echo ".uri = $tracdb_uri" >Makefile.cfg
183- echo "$tracdb_version"
184script:
185- set -e
186- if [ "$build" != minimum ]; then make compile; fi
187- make Trac.egg-info unit-test functional-test;
188before_deploy:
189- cat contrib/travis/edgewall_host_key >> $HOME/.ssh/known_hosts
190- keyfile=/tmp/id_rsa
191- openssl aes-256-cbc -K $encrypted_c097e63a4ddf_key -iv $encrypted_c097e63a4ddf_iv
192  -in contrib/travis/id_rsa.enc -out "$keyfile".base64 -d
193- cat "$keyfile".base64 | base64 --decode >"$keyfile"
194- chmod 0600 "$keyfile"
195- pip install setuptools-git
196- make compile release
197notifications:
198  email:
199    recipients:
200      secure: lIn4a3G6ww61t3o12DS4aWwEwD6Hl2kxcsZgkxvhU2MgzviJ5j3EBV5F/BlbQmR1BqM51qgDOXoQTO+y9cvzAYBkIy/gfLqZjAl0hfZep6iGZgl1cnUW4c5i9+wkF8PzTaQm+q9gwlIQ7JVedWw9jzHBIn80tCgTcavahAzyelk=
201jobs:
202  include:
203  - {os: linux, python: '3.9', env: 'tracdb= build=minimum'}
204  - {os: linux, python: '3.9', env: 'tracdb='}
205  - {os: linux, python: '3.8', env: 'tracdb='}
206  - {os: linux, python: '3.7', env: 'tracdb='}
207  - {os: linux, python: '3.6', env: 'tracdb='}
208  - {os: linux, python: '3.5', env: 'tracdb='}
209  - {os: linux, python: '3.9', env: 'tracdb=sqlite'}
210  - {os: linux, python: '3.9', env: 'tracdb=postgresql', services: postgresql}
211  - {os: linux, python: '3.9', env: 'tracdb=mysql', services: mysql}
212  - {os: osx, osx_image: xcode12.2, language: generic, env: 'tracdb= build=minimum'}
213  - {os: osx, osx_image: xcode12.2, language: generic, env: 'tracdb='}
214  - {os: osx, osx_image: xcode12.2, language: generic, env: 'tracdb=sqlite'}
215  - {os: osx, osx_image: xcode12.2, language: generic, env: 'tracdb=postgresql'}
216  - stage: deploy
217    before_script: skip
218    script: skip
219    deploy:
220      provider: script
221      skip_cleanup: true
222      script: scp -i "$keyfile" dist/Trac-* travis@edgewall.org:/var/ftp/pub/trac/incoming
223      on:
224        repo: edgewall/trac
225        all_branches: true
226