|
| 1 | +# merged in python-package.yml workflow |
| 2 | + |
| 3 | +name: roundup-ci |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: [ "master" ] |
| 8 | +# pull_request: |
| 9 | +# branches: [ "master" ] |
| 10 | +# schedule: |
| 11 | +# - cron '0 11 * * 1-5' |
| 12 | + |
| 13 | +jobs: |
| 14 | + test: |
| 15 | + name: CI build test |
| 16 | + |
| 17 | + runs-on: ubuntu-latest |
| 18 | + # use below if running on multiple OS's. |
| 19 | + # runs-on: ${{ matrix.os }} |
| 20 | + |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + # Run in all these versions of Python |
| 25 | + python-version: [ "2.7", "3.10", "3.9", "3.8", "3.6" ] |
| 26 | + # use for multiple os or ubuntu versions |
| 27 | + # os: [ubuntu-latest, macos-latest, windows-latest] |
| 28 | + |
| 29 | + #env: |
| 30 | + # OS: ${{ matrix.os }} |
| 31 | + # PYTHON: ${{ matrix.python-version }} |
| 32 | + |
| 33 | + steps: |
| 34 | + # Checkout the latest code from the repo |
| 35 | + - name: Checkout source |
| 36 | + uses: actions/checkout@v3 |
| 37 | + |
| 38 | + # Setup which version of Python to use |
| 39 | + - name: Set Up Python ${{ matrix.python-version }} |
| 40 | + uses: actions/setup-python@v3 |
| 41 | + with: |
| 42 | + python-version: ${{ matrix.python-version }} |
| 43 | + |
| 44 | + # Display the Python version being used |
| 45 | + - name: Display Python version |
| 46 | + run: python -c "import sys; print(sys.version)" |
| 47 | + |
| 48 | + # Install the databases |
| 49 | + - name: Install postgres |
| 50 | + run: | |
| 51 | + apt-get install postgresql |
| 52 | + # Disable fsync for speed, don't care about data durability when testing |
| 53 | + sudo sed -i -e '$a\fsync = off' /etc/postgresql/*/*/postgresql.conf |
| 54 | + sudo service postgresql restart; sleep 30 |
| 55 | + # set up postgresql database |
| 56 | + psql -c "CREATE ROLE rounduptest WITH CREATEDB LOGIN PASSWORD 'rounduptest';" -U postgres |
| 57 | + |
| 58 | + - name: Install mysql |
| 59 | + run: | |
| 60 | + apt-get install mysql |
| 61 | + # set up mysql database |
| 62 | + sudo sed -i -e '/^\[mysqld\]/,/^\[mysql/s/^max_allowed_packet.*/max_allowed_packet = 500M/' /etc/mysql/my.cnf |
| 63 | + cat /etc/mysql/my.cnf |
| 64 | + sudo service mysql restart |
| 65 | + mysql -u root -e 'GRANT ALL ON rounduptest.* TO rounduptest@localhost IDENTIFIED BY "rounduptest";' |
| 66 | + # HACK: workaround mysql bug: http://bugs.mysql.com/bug.php?id=74901 |
| 67 | + # needed for test_mysql.mysqlDBTest.testFilteringSpecialChars |
| 68 | + # plus others. Otherwise we get: |
| 69 | + # COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4' |
| 70 | + sed -i 's/CREATE DATABASE \%s/CREATE DATABASE \%s COLLATE utf8_general_ci/' roundup/backends/back_mysql.py |
| 71 | + |
| 72 | + - name: Update pip |
| 73 | + run: python -m pip install --upgrade pip |
| 74 | + |
| 75 | + - name: Install db libraries |
| 76 | + run: pip install psycopg2 mysqlclient |
| 77 | + |
| 78 | + - name: Install auxilary packages |
| 79 | + run: | |
| 80 | + pip install beautifulsoup4 brotli gpg jinja2 markdown2 \ |
| 81 | + pyjwt pytz whoosh |
| 82 | + |
| 83 | + - name: Install aux packages that need versions differences |
| 84 | + # if zstd fails install, keep going with test, don't abort |
| 85 | + run: | |
| 86 | + pip install zstd || true |
| 87 | + if "$${{ PYTHON_VERSION }} != "2."* ]]; then |
| 88 | + pip install Markdown; fi |
| 89 | + |
| 90 | + - name: Install pytest and other packages needed for running tests |
| 91 | + run: pip install codecov flake8 pytest pytest-cov requests |
| 92 | + |
| 93 | + - name: Test build roundup and install locale so lang tests work. |
| 94 | + run: | |
| 95 | + ${{ matrix.python-version }} setup.py install |
| 96 | + (cd locale; make local_install; ls -lR locale/de/LC_MESSAGES) |
| 97 | + |
| 98 | + - name: run flake8 in warn only mode |
| 99 | + run: | |
| 100 | + # stop the build for Python syntax errors or undefined names |
| 101 | + flake8 roundup --count --select=E9,F63,F7,F82 --show-source --statistics |
| 102 | + # exit-zero treats all errors as warnings. |
| 103 | + # The GitHub editor is 127 chars wide |
| 104 | + flake8 roundup --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 105 | + |
| 106 | + # Run the tests using pytest with test files in tests directory. |
| 107 | + - name: Run tests |
| 108 | + run: pytest -v tests |
| 109 | + |
| 110 | + - name: Upload coverage to Codecov |
| 111 | + # see: https://github.com/codecov/codecov-action#usage |
| 112 | + uses: codecov/codecov-action@v3 |
| 113 | + with: |
| 114 | + verbose: true |
| 115 | + |
| 116 | + - name: test build_doc |
| 117 | + run: | |
| 118 | + ${{ matrix.python-version }} ./setup.py build_doc |
0 commit comments