|
| 1 | +# merged in python-package.yml workflow |
| 2 | + |
| 3 | +name: roundup-ci |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + # skip if github.ref is 'refs/heads/maint-1.6' |
| 8 | + # aka github.ref_name of 'maint-1.6' |
| 9 | + # see https://github.com/orgs/community/discussions/26253 |
| 10 | + # for mechanism to control matrix based on branch |
| 11 | + branches: [ "*", '!maint-1.6' ] |
| 12 | +# pull_request: |
| 13 | +# branches: [ "master" ] |
| 14 | + schedule: |
| 15 | + # monthly build/check |
| 16 | + - cron: '23 17 1 * *' |
| 17 | + |
| 18 | +# GITHUB_TOKEN only has read repo context. |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + |
| 22 | +concurrency: |
| 23 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 24 | + cancel-in-progress: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + test: |
| 28 | + name: CI build test |
| 29 | + |
| 30 | + # run the finalizer for coveralls even if one or more |
| 31 | + # matrix runs fail. |
| 32 | + continue-on-error: true |
| 33 | + |
| 34 | + #runs-on: ubuntu-latest |
| 35 | + # use below if running on multiple OS's. |
| 36 | + runs-on: ${{ matrix.os }} |
| 37 | + |
| 38 | + strategy: |
| 39 | + fail-fast: false |
| 40 | + max-parallel: 4 |
| 41 | + matrix: |
| 42 | + # Run in all these versions of Python |
| 43 | + python-version: [ "2.7", "3.10", "3.9", "3.8", "3.6", "3.11-dev" ] |
| 44 | + |
| 45 | + # use for multiple os or ubuntu versions |
| 46 | + #os: [ubuntu-latest, macos-latest, windows-latest] |
| 47 | + os: [ubuntu-latest, ubuntu-22.04] |
| 48 | + |
| 49 | + # if the ones above fail. fail the build |
| 50 | + experimental: [false] |
| 51 | + |
| 52 | + include: |
| 53 | + # example: if 3.12 fails the jobs still succeeds |
| 54 | + # - python-version: 3.12 |
| 55 | + # experimental: [true] |
| 56 | + # version 2.7 not available on unbuntu-22.04 github |
| 57 | + # - python-version: 2.7 |
| 58 | + # os: ubuntu-22.04 |
| 59 | + # experimental: true |
| 60 | + - python-version: 3.11-dev |
| 61 | + os: ubuntu-22.04 |
| 62 | + experimental: [true] |
| 63 | + |
| 64 | + exclude: |
| 65 | + # skip all python versions on 22.04 except explicitly included |
| 66 | + - os: ubuntu-22.04 |
| 67 | + |
| 68 | + env: |
| 69 | + # get colorized pytest output even without a controlling tty |
| 70 | + PYTEST_ADDOPTS: "--color=yes" |
| 71 | + # OS: ${{ matrix.os }} |
| 72 | + PYTHON_VERSION: ${{ matrix.python-version }} |
| 73 | + |
| 74 | + steps: |
| 75 | + # Checkout the latest code from the repo |
| 76 | + - name: Checkout source |
| 77 | + # example directives: |
| 78 | + # disable step |
| 79 | + # if: {{ false }} |
| 80 | + # continue running if step fails |
| 81 | + # continue-on-error: true |
| 82 | + uses: actions/checkout@v3 |
| 83 | + |
| 84 | + # Setup version of Python to use |
| 85 | + - name: Set Up Python ${{ matrix.python-version }} |
| 86 | + uses: actions/setup-python@v4 |
| 87 | + with: |
| 88 | + python-version: ${{ matrix.python-version }} |
| 89 | + cache: 'pip' |
| 90 | + |
| 91 | + # Display the Python version being used |
| 92 | + - name: Display Python and key module versions |
| 93 | + run: | |
| 94 | + python -c "import sys; print('python version: ', sys.version)" |
| 95 | + python -c "import sqlite3; print('sqlite3 version, sqlite version: ', sqlite3.version, sqlite3.sqlite_version)" |
| 96 | +
|
| 97 | + # Install the databases |
| 98 | + - name: Install mysql/mariadb |
| 99 | + run: | |
| 100 | + #set -xv |
| 101 | + # mysql is pre-installed and active but this is the install command |
| 102 | + # sudo apt-get install mysql-server mysql-client |
| 103 | + # set up mysql database |
| 104 | + sudo sed -i -e '/^\[mysqld\]/,/^\[mysql/s/^#* *max_allowed_packet.*/max_allowed_packet = 500M/' /etc/mysql/mysql.conf.d/mysqld.cnf; sleep 3 |
| 105 | + #tail -n +0 /etc/mysql/my.cnf /etc/mysql/mysql.conf.d/mysqld.cnf |
| 106 | + #grep max_allowed /etc/mysql/mysql.conf.d/mysqld.cnf |
| 107 | + #ls /etc/mysql/conf.d/ /etc/mysql/mysql.conf.d/ |
| 108 | + #sleep 5 |
| 109 | + sudo service mysql restart |
| 110 | + #sleep 10 |
| 111 | + #ps -ef | grep mysqld |
| 112 | + #sudo netstat -anp | grep mysqld |
| 113 | + sudo mysql -u root -proot -e 'CREATE USER "rounduptest"@"localhost" IDENTIFIED WITH mysql_native_password BY "rounduptest"; GRANT ALL on rounduptest.* TO "rounduptest"@"localhost";' |
| 114 | +
|
| 115 | + - name: Install postgres |
| 116 | + run: | |
| 117 | + sudo apt-get install postgresql |
| 118 | + # Disable fsync for speed, don't care about data durability |
| 119 | + # when testing |
| 120 | + sudo sed -i -e '$a\fsync = off' /etc/postgresql/*/*/postgresql.conf |
| 121 | + sudo service postgresql restart; sleep 10 |
| 122 | + # set up postgresql database |
| 123 | + sudo -u postgres psql -c "CREATE ROLE rounduptest WITH CREATEDB LOGIN PASSWORD 'rounduptest';" -U postgres |
| 124 | +
|
| 125 | + - name: install redis |
| 126 | + run: | |
| 127 | + sudo apt-get install redis |
| 128 | + pip install redis |
| 129 | +
|
| 130 | + - name: Update pip |
| 131 | + run: python -m pip install --upgrade pip |
| 132 | + |
| 133 | + - name: Install python db libraries |
| 134 | + run: pip install psycopg2 mysqlclient |
| 135 | + |
| 136 | + - name: Install auxiliary packages |
| 137 | + run: | |
| 138 | + sudo apt-get install swig gpgsm libgpgme-dev |
| 139 | + # pygments for markdown2 to highlight code blocks |
| 140 | + pip install markdown2 pygments |
| 141 | + # docutils for ReStructuredText |
| 142 | + pip install beautifulsoup4 brotli docutils gpg jinja2 \ |
| 143 | + mistune==0.8.4 pyjwt pytz whoosh |
| 144 | +
|
| 145 | + - name: Install aux packages that need versions differences |
| 146 | + # if zstd fails install, keep going with test, don't abort |
| 147 | + run: | |
| 148 | + set -xv |
| 149 | + pip install zstd || true |
| 150 | + if [[ "$PYTHON_VERSION" != "2."* ]]; then |
| 151 | + pip install Markdown; fi |
| 152 | +
|
| 153 | + - name: Install xapian |
| 154 | + run: | |
| 155 | + sudo apt-get install libxapian-dev |
| 156 | + # Sphinx required to build the xapian python bindings. Use 1.8.5 on |
| 157 | + # older python and newest on newer. |
| 158 | + if [[ $PYTHON_VERSION == "2."* ]]; then pip install sphinx==1.8.5; fi |
| 159 | + if [[ $PYTHON_VERSION == '3.'* ]] ; then pip install sphinx; fi |
| 160 | + XAPIAN_VER=$(dpkg -l libxapian-dev | tail -n 1 | awk '{print $3}' | cut -d '-' -f 1); echo $XAPIAN_VER |
| 161 | + cd /tmp |
| 162 | + curl -s -O https://oligarchy.co.uk/xapian/$XAPIAN_VER/xapian-bindings-$XAPIAN_VER.tar.xz |
| 163 | + tar -Jxvf xapian-bindings-$XAPIAN_VER.tar.xz |
| 164 | + cd xapian-bindings-$XAPIAN_VER/ |
| 165 | + if [[ $PYTHON_VERSION == "2."* ]]; then ./configure --prefix=$VIRTUAL_ENV --with-python --disable-documentation; fi |
| 166 | + # edit the configure script. |
| 167 | + # distutils.sysconfig.get_config_vars('SO') doesn't work for |
| 168 | + # 3.11 or newer. |
| 169 | + # Change distutils.sysconfig... to just sysconfig and SO |
| 170 | + # to EXT_SUFFIX to get valid value. |
| 171 | + if [[ $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 |
| 172 | + case "$PYTHON_VERSION" in nightly) echo skipping xapian build;; *) make && sudo make install; esac |
| 173 | +
|
| 174 | + - name: Install pytest and other packages needed for running tests |
| 175 | + run: pip install codecov flake8 mock pytest pytest-cov requests |
| 176 | + |
| 177 | + - name: Test build roundup and install locale so lang tests work. |
| 178 | + run: | |
| 179 | + sudo apt-get install gettext |
| 180 | + python setup.py build |
| 181 | + (cd locale; make local_install; ls -lR locale/de/LC_MESSAGES) |
| 182 | +
|
| 183 | + - name: run flake8 - abort for syntax error, otherwise warn only |
| 184 | + run: | |
| 185 | + # stop the build for Python syntax errors or undefined names |
| 186 | + # talgettext is a utility function ignore it. |
| 187 | + flake8 roundup --count --select=E9,F63,F7,F82 --show-source --statistics --extend-exclude talgettext.py |
| 188 | + # exit-zero treats all errors as warnings. |
| 189 | + # The GitHub editor is 127 chars wide |
| 190 | + flake8 roundup --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 191 | +
|
| 192 | + # Run the tests using pytest with test files in tests directory. |
| 193 | + - name: Run tests |
| 194 | + run: | |
| 195 | + if [[ "$PYTHON_VERSION" != "2."* ]]; then |
| 196 | + pytest -r a \ |
| 197 | + -W default \ |
| 198 | + -W "ignore:SelectableGroups:DeprecationWarning" \ |
| 199 | + -W "ignore:the imp module:DeprecationWarning:gpg.gpgme:15" \ |
| 200 | + -W "ignore:'U' mode::docutils.io" \ |
| 201 | + -W "ignore:unclosed:ResourceWarning:roundup.roundup.demo" \ |
| 202 | + -W "ignore:unclosed file:ResourceWarning:enum" \ |
| 203 | + -v test/ --cov=roundup |
| 204 | + if [[ "$PYTHON_VERSION" != "3.6" ]]; then |
| 205 | + # coverage before 3.6 doesn't support lcov output |
| 206 | + coverage lcov |
| 207 | + fi |
| 208 | + else |
| 209 | + # python2 case |
| 210 | + pytest -v -r a test/ --cov=roundup |
| 211 | + fi |
| 212 | +
|
| 213 | + - name: Upload coverage to Codecov |
| 214 | + # see: https://github.com/codecov/codecov-action#usage |
| 215 | + uses: codecov/codecov-action@v3 |
| 216 | + with: |
| 217 | + verbose: true |
| 218 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 219 | + |
| 220 | + - name: Upload coverage to Coveralls |
| 221 | + # python 2.7 and 3.6 versions of coverage can't produce lcov files. |
| 222 | + if: matrix.python-version != '2.7' && matrix.python-version != '3.6' |
| 223 | + uses: coverallsapp/github-action@master |
| 224 | + with: |
| 225 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 226 | + path-to-lcov: coverage.lcov |
| 227 | + parallel: run-{{ matrix.python-version }}-{{ matrix.os }} |
| 228 | + |
| 229 | + - name: test build_doc |
| 230 | + run: | |
| 231 | + python ./setup.py build_doc |
| 232 | +
|
| 233 | + #- name: test docker build current version ubuntu-latest |
| 234 | + # if: matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' |
| 235 | + # run: | |
| 236 | + # docker build -t roundup-app-dev -f scripts/Docker/Dockerfile . |
| 237 | + # mkdir tracker; chmod 777 tracker |
| 238 | + # docker run -d --rm -p 9017:8080 \ |
| 239 | + # -v $PWD/tracker:/usr/src/app/tracker \ |
| 240 | + # roundup-app-dev:latest demo |
| 241 | + # expect 200 |
| 242 | + # curl --fail http://localhost:9017/demo/ > /dev/null |
| 243 | + |
| 244 | + #- name: test docker build released pip version |
| 245 | + # run: | |
| 246 | + # docker build -t roundup-app-rel --build-arg="source=pypi" \ |
| 247 | + # -f scripts/Docker/Dockerfile . |
| 248 | + |
| 249 | + |
| 250 | + # in parallel build codecov requires a finish step |
| 251 | + finish: |
| 252 | + needs: test |
| 253 | + runs-on: ubuntu-latest |
| 254 | + steps: |
| 255 | + - name: Coveralls Finished |
| 256 | + uses: coverallsapp/github-action@master |
| 257 | + with: |
| 258 | + github-token: ${{ secrets.github_token }} |
| 259 | + parallel-finished: true |
0 commit comments