view .github/workflows/ci-test.yml @ 6841:3671c0f6352e

More fixes to yaml using linter: https://rhysd.github.io/actionlint/
author John Rouillard <rouilj@ieee.org>
date Wed, 31 Aug 2022 17:56:55 -0400
parents 8ee17804086e
children d8d4600c49eb
line wrap: on
line source

# merged in python-package.yml workflow

name: roundup-ci

on: 
    push:
        branches: [ "master" ]
#    pull_request:
#        branches: [ "master" ]
#    schedule:
#        - cron '0 11 * * 1-5'

jobs:
  test:
    name: CI build test

    runs-on: ubuntu-latest
    # use below if running on multiple OS's.
    # runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        # Run in all these versions of Python
        python-version: [ "2.7", "3.10", "3.9", "3.8", "3.6" ]
    # use for multiple os or ubuntu versions
    #    os: [ubuntu-latest, macos-latest, windows-latest]

    #env:
    #  OS: ${{ matrix.os }}
    #  PYTHON: ${{ matrix.python-version }}

    steps:
      # Checkout the latest code from the repo
      - name: Checkout source
        uses: actions/checkout@v3

      # Setup which version of Python to use
      - name: Set Up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v3
        with:
          python-version: ${{ matrix.python-version }}

      # Display the Python version being used
      - name: Display Python version
        run: python -c "import sys; print(sys.version)"

      # Install the databases
      - name: Install postgres
        run: |
          apt-get install postgresql
          # 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

      - name: Install mysql
        run: |
          apt-get install mysql
          # 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 'GRANT ALL ON rounduptest.* TO rounduptest@localhost IDENTIFIED BY "rounduptest";'
          # HACK: workaround mysql bug: http://bugs.mysql.com/bug.php?id=74901
          #   needed for test_mysql.mysqlDBTest.testFilteringSpecialChars
          # plus others. Otherwise we get:
          # COLLATION 'utf8_bin' is not valid for CHARACTER SET 'utf8mb4'
          sed -i 's/CREATE DATABASE \%s/CREATE DATABASE \%s COLLATE utf8_general_ci/' roundup/backends/back_mysql.py

      - name: Update pip
        run: python -m pip install --upgrade pip

      - name: Install db libraries
        run: pip install psycopg2 mysqlclient

      - name: Install auxilary packages
        run: |
          pip install beautifulsoup4 brotli gpg jinja2 markdown2 \
              pyjwt pytz whoosh

      - name: Install aux packages that need versions differences
        # if zstd fails install, keep going with test, don't abort
        run: |
          pip install zstd || true
          if "$${{ matrix.python-version }}" != "2."* ]]; then 
              pip install Markdown; fi

      - name: Install pytest and other packages needed for running tests
        run: pip install codecov flake8 pytest pytest-cov requests

      - name: Test build roundup and install locale so lang tests work.
        run: |
          ${{ matrix.python-version }} setup.py install
          (cd locale; make local_install; ls -lR locale/de/LC_MESSAGES)

      - name: run flake8 in warn only mode
        run: |
            # stop the build for Python syntax errors or undefined names
            flake8 roundup --count --select=E9,F63,F7,F82 --show-source --statistics
            # exit-zero treats all errors as warnings.
            #   The GitHub editor is 127 chars wide
            flake8 roundup --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

      # Run the tests using pytest with test files in tests directory.
      - name: Run tests
        run: pytest -v tests

      - name: Upload coverage to Codecov
        # see: https://github.com/codecov/codecov-action#usage
        uses: codecov/codecov-action@v3
        with:
          verbose: true

      - name: test build_doc
        run: |
          ${{ matrix.python-version }} ./setup.py build_doc

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