view .travis.yml @ 7752:b2dbab2b34bc

fix(refactor): multiple fixups using ruff linter; more testing. Converting to using the ruff linter and its rulesets. Fixed a number of issues. admin.py: sort imports use immutable tuples as default value markers for parameters where a None value is valid. reduced some loops to list comprehensions for performance used ternary to simplify some if statements named some variables to make them less magic (e.g. _default_savepoint_setting = 1000) fixed some tests for argument counts < 2 becomes != 2 so 3 is an error. moved exception handlers outside of loops for performance where exception handler will abort loop anyway. renamed variables called 'id' or 'dir' as they shadow builtin commands. fix translations of form _("string %s" % value) -> _("string %s") % value so translation will be looked up with the key before substitution. end dicts, tuples with a trailing comma to reduce missing comma errors if modified simplified sorted(list(self.setting.keys())) to sorted(self.setting.keys()) as sorted consumes whole list. in if conditions put compared variable on left and threshold condition on right. (no yoda conditions) multiple noqa: suppression removed unneeded noqa as lint rulesets are a bit different do_get - refactor output printing logic: Use fast return if not special formatting is requested; use isinstance with a tuple rather than two isinstance calls; cleaned up flow and removed comments on algorithm as it can be easily read from the code. do_filter, do_find - refactor output printing logic. Reduce duplicate code. do_find - renamed variable 'value' that was set inside a loop. The loop index variable was also named 'value'. do_pragma - added hint to use list subcommand if setting was not found. Replaced condition 'type(x) is bool' with 'isinstance(x, bool)' for various types. test_admin.py added testing for do_list better test coverage for do_get includes: -S and -d for multilinks, error case for -d with non-link. better testing for do_find including all output modes better testing for do_filter including all output modes fixed expected output for do_pragma that now includes hint to use pragma list if setting not found.
author John Rouillard <rouilj@ieee.org>
date Fri, 01 Mar 2024 14:53:18 -0500
parents b7a8d9664938
children 5ac9253d2a5f
line wrap: on
line source

# check syntax using:
#  https://config.travis-ci.com/explore

# have commit skip build by adding '[skip travis]' to commit message.

os: linux

language: python

cache: pip

#I would like to build and test the maint-1.6 and trunk/default
#but we need different environments for these:
#  maint-1.6 only python 2, install only psycopg2 version with support for
#     psycopg1 
branches:
  except:
     - /^dependabot\/.*$/
#  only:
#    - default
#    - maint-1.6

dist: focal

python:
  - 2.7
#  - 3.10.4
#  - 3.9
#  - 3.8
#  - 3.6
#  - 3.11-dev
#  - nightly
#  - pypy3

services:
  - mysql
  - postgresql
  - redis

jobs:
    allow_failures:  # releases not ready for prime time yet.
      - python: nightly
      - python: 3.11-dev
      - python: pypy3

addons:
  apt:
    #sources:
    #  - sourceline: ppa:xapian-backports/ppa

    packages:
      # Required to build/install the xapian-binding
      - libxapian-dev
      # Required to install gpg
      - swig
      # Required to build gpgme.
      - gpgsm
      - libgpgme-dev

before_install:
  # deal with setuptools error:
  # pkg_resources.extern.packaging.version.InvalidVersion: Invalid
  #    version: '0.23ubuntu1' (package: distro-info)
  - sudo apt-get remove distro-info
  # pin setuptools to try to get gpgme to build
  - pip install "setuptools<66"
  - if [[ $TRAVIS_PYTHON_VERSION == "3."* ]]; then sudo apt-get install python3-gpg; fi
  # build xapian
  - echo "$TRAVIS_PYTHON_VERSION"
  # Sphinx required to build the xapian python bindings. Use 1.8.5 on
  # older python and newest on newer.
  - if [[ $TRAVIS_PYTHON_VERSION == "2."* ]]; then pip install sphinx==1.8.5; fi
  - if [[ $TRAVIS_PYTHON_VERSION == '3.'* ]] ; then pip install sphinx; fi
  - if [[ $TRAVIS_PYTHON_VERSION == "nightly" ]]; then pip install sphinx; fi
  - XAPIAN_VER=$(dpkg -l libxapian-dev | tail -n 1 | awk '{print $3}' | cut -d '-' -f 1); echo $XAPIAN_VER
  # force specific version 1.4.19 for python 3.12 for debugging
  # #REMOVE# - if [[ $TRAVIS_PYTHON_VERSION == "nightly" ]]; then XAPIAN_VER=1.4.19; fi; echo $XAPIAN_VER
  - cd /tmp
  - curl -s -O https://oligarchy.co.uk/xapian/$XAPIAN_VER/xapian-bindings-$XAPIAN_VER.tar.xz
  - tar -Jxvf xapian-bindings-$XAPIAN_VER.tar.xz
  - cd xapian-bindings-$XAPIAN_VER/
  - echo $TRAVIS_PYTHON_VERSION
  - if [[ $TRAVIS_PYTHON_VERSION == "2."* ]]; then ./configure --prefix=$VIRTUAL_ENV --with-python --disable-documentation; fi
  # edit the configure script. distutils.sysconfig.get_config_vars('SO')
  #  doesn't work for 3.11 or newer.
  # Change distutils.sysconfig... to just sysconfig and SO to EXT_SUFFIX
  # to get valid value.
  - if [[ $TRAVIS_PYTHON_VERSION == "3."* ]]; then sed -i -e '/PYTHON3_SO=/s/distutils\.//g' -e '/PYTHON3_SO=/s/"SO"/"EXT_SUFFIX"/g' configure; ./configure --prefix=$VIRTUAL_ENV --with-python3 --disable-documentation; fi
  - if [[ $TRAVIS_PYTHON_VERSION == "nightly" ]]; then sed -i -e '/PYTHON3_SO=/s/distutils\.//g' -e '/PYTHON3_SO=/s/"SO"/"EXT_SUFFIX"/g' configure; ./configure --prefix=$VIRTUAL_ENV --with-python3 --disable-documentation; fi
  - if [[ $TRAVIS_PYTHON_VERSION == "pypy3" ]]; then sed -i -e '/PYTHON3_SO=/s/distutils\.//g' -e '/PYTHON3_SO=/s/"SO"/"EXT_SUFFIX"/g' configure; ./configure --prefix=$VIRTUAL_ENV --with-python3 --disable-documentation; fi
  - case "$TRAVIS_PYTHON_VERSION" in disable) echo skipping xapian build;; *) make && make install; esac

  - PATH=$VIRTUAL_ENV/bin:$PATH

  # libgpg-error
  - LIBGPG_ERROR_VERSION=1.43
  - cd /tmp
  - curl -s -O https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2
  - tar -jxvf libgpg-error-$LIBGPG_ERROR_VERSION.tar.bz2
  - cd libgpg-error-$LIBGPG_ERROR_VERSION
  - ./configure --prefix=$VIRTUAL_ENV
  - make && make install

  # libassuan
  - LIBASSUAN_VERSION=2.5.5
  - cd /tmp
  - curl -s -O https://www.gnupg.org/ftp/gcrypt/libassuan/libassuan-$LIBASSUAN_VERSION.tar.bz2
  - tar -jxvf libassuan-$LIBASSUAN_VERSION.tar.bz2
  - cd libassuan-$LIBASSUAN_VERSION
  - ./configure --prefix=$VIRTUAL_ENV
  - make && make install

  # gpgme
  #- GPGME_VERSION=1.18.0
  #- cd /tmp
  - pip install "setuptools<66"
  #- curl -s -O https://www.gnupg.org/ftp/gcrypt/gpgme/gpgme-$GPGME_VERSION.tar.bz2
  #- tar -jxf gpgme-$GPGME_VERSION.tar.bz2
  #- cd gpgme-$GPGME_VERSION
  #- ./configure --prefix=$VIRTUAL_ENV
  #- make && make install

  # change back to the checked out repository directory
  - cd $TRAVIS_BUILD_DIR

install:
  - if [[ $TRAVIS_PYTHON_VERSION == "3.4"* ]]; then  pip install mysqlclient==1.3.14; fi
  - if [[ $TRAVIS_PYTHON_VERSION != "3.4"* ]]; then pip install mysqlclient; fi
  # https://issues.roundup-tracker.org/issue2551267
  - if [[ $TRAVIS_PYTHON_VERSION == "3."* ]]; then pip install gpg; fi
  - pip install psycopg2
  - pip install redis
  - pip install pytz whoosh pyjwt requests
  - pip install jinja2
  - pip install pytest-cov
  - pip install beautifulsoup4
  - if [[ $TRAVIS_PYTHON_VERSION != "3.4"* ]]; then pip install docutils; fi
  - if [[ $TRAVIS_PYTHON_VERSION != "3.4"* ]]; then pip install mistune==0.8.4; fi
  - if [[ $TRAVIS_PYTHON_VERSION != "3.4"* && $TRAVIS_PYTHON_VERSION != "2."* ]]; then pip install Markdown; fi
  - pip install 'markdown2<=2.4.8'
  - pip install brotli==1.0.9
  # zstd fails to build under python nightly aborting test.
  # allow testing to still happen if the optional package doesn't install.
  - pip install zstd || true

before_script:
  # set up mysql database
  - sudo sed -i -e '/^\[mysqld\]/,/^\[mysql/s/^max_allowed_packet.*/max_allowed_packet = 500M/' /etc/mysql/my.cnf
  - cat /etc/mysql/my.cnf
  - sudo service mysql restart
  - mysql -u root -e 'CREATE USER "rounduptest"@"localhost" IDENTIFIED WITH mysql_native_password BY "rounduptest"; GRANT ALL on rounduptest.* TO "rounduptest"@"localhost";'

  # Disable fsync for speed, don't care about data durability when testing
  - sudo sed -i -e '$a\fsync = off' /etc/postgresql/*/*/postgresql.conf
  - sudo service postgresql restart; sleep 30
  # set up postgresql database
  - psql -c "CREATE ROLE rounduptest WITH CREATEDB LOGIN PASSWORD 'rounduptest';" -U postgres
  - psql -c "CREATE ROLE rounduptest_schema LOGIN PASSWORD 'rounduptest';" -U postgres
  - psql -c "CREATE DATABASE rounduptest_schema;" -U postgres
  - psql -c "GRANT CREATE ON DATABASE rounduptest_schema TO rounduptest_schema;" -U postgres

  # build the .mo translation files and install them into a tree
  # (locale/locale under roundup directory root) 
  # suitable for use by gettext.
  - (cd locale; make local_install; ls -lR locale/de/LC_MESSAGES)

script:
  - PATH=$VIRTUAL_ENV/bin:$PATH
  - export LD_LIBRARY_PATH=$VIRTUAL_ENV/lib:$LD_LIBRARY_PATH
  - python -c "import sys; print('python version ', sys.version)"
  - if [[ "$TRAVIS_PYTHON_VERSION" != "2."* ]]; then
    python -m pytest -r a \
      --durations=20 \
      -W default \
      -W "ignore:SelectableGroups:DeprecationWarning" \
      -W "ignore:the imp module:DeprecationWarning:gpg.gpgme:15" \
      -W "ignore:'U' mode::docutils.io" \
      -W "ignore:unclosed:ResourceWarning:roundup.roundup.demo" \
      -W "ignore:unclosed file:ResourceWarning:enum" \
      -v --maxfail=5 test/ --cov=roundup;
    fi
  - if [[ "$TRAVIS_PYTHON_VERSION" == "2."* ]]; then
    python -m pytest -v -r a --maxfail=5 test/ --cov=roundup;
    fi
  - python -m pip install sphinx-tabs
  - ./setup.py build_doc

after_success:
  # from https://docs.codecov.com/docs/codecov-uploader#integrity-checking-the-uploader
  - curl https://keybase.io/codecovsecurity/pgp_keys.asc | \
    gpg --no-default-keyring --keyring trustedkeys.gpg --import # One-time step
  - curl -Os https://uploader.codecov.io/latest/linux/codecov
  - curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
  - curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig
  - gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
  - shasum -a 256 -c codecov.SHA256SUM
  - chmod +x codecov
  - ./codecov -t ${CODECOV_TOKEN}

Roundup Issue Tracker: http://roundup-tracker.org/