Skip to content
ci.yml 4.56 KiB
Newer Older
name: CI
on:
      - main
  pull_request:
  schedule:
    - cron: "17 3 * * 0"
defaults:
  run:
    # required by https://github.com/snok/install-poetry#windows
    shell: bash

Andreas Klöckner's avatar
Andreas Klöckner committed
    name: Lint and typecheck Python
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v1
        with:
        uses: snok/install-poetry@v1.2.1
          version: "1.1.11"
          virtualenvs-create: true

      #- name: Cache python dependencies
      #  uses: actions/cache@v2
      #  id: cache
      #  with:
      #    path: ~/.cache/pypoetry
      #    key: poetry-${{ hashFiles('**/poetry.lock') }}-${{ matrix.python-version }}
      #    restore-keys: |
      #      poetry-${{ hashFiles('**/poetry.lock') }}-${{ matrix.python-version }}
      - name: Install Dependencies
        run: poetry install
      #  if: steps.cache.outputs.cache-hit != 'true'
        run: |
          poetry run flake8 relate course accounts
          poetry run flake8 --extend-ignore Q000 tests
      - name: "Mypy"
        run: poetry run mypy relate course
      - name: "Safety"
        run: bash ./.ci/run-safety.sh
Andreas Klöckner's avatar
Andreas Klöckner committed
      - name: "Sphinx"
        run: |
            cp local_settings_example.py local_settings.py
            (cd doc; poetry run make html SPHINXOPTS="-W --keep-going -n")
Andreas Klöckner's avatar
Andreas Klöckner committed
  frontend:
    name: Lint JS/build frontend (Node ${{ matrix.node-version }})
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: ['12', '14', '16']
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v2
      with:
          node-version: ${{ matrix.node-version }}
    - name: Install
      run: npm install

    - name: ESLint
      run: npx eslint relate/static/js/*.js

    - name: Rollup build
      run: npm run build
  pytest:
    name: Python ${{ matrix.python-version }} - ${{ matrix.suite }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ['3.6', '3.9', '3.x']
        suite: ['base', 'postgres', 'expensive']
    services:
        postgres:
          image: postgres
          env:
              POSTGRES_PASSWORD: relatepgpass
              POSTGRES_DB: test_relate
          options: >-
              --health-cmd pg_isready
              --health-interval 10s
              --health-timeout 5s
              --health-retries 5
          ports:
              - 5432:5432
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v1
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install Poetry
        uses: snok/install-poetry@v1.2.1
          virtualenvs-create: true

      #- name: Cache python dependencies
      #  uses: actions/cache@v2
      #  id: cache
      #  with:
      #    path: ~/.cache/pypoetry
      #    key: poetry-${{ hashFiles('**/poetry.lock') }}-${{ matrix.python-version }}
      #    restore-keys: |
      #      poetry-${{ hashFiles('**/poetry.lock') }}-${{ matrix.python-version }}
      - name: Install Dependencies
        run: poetry install
      #  if: steps.cache.outputs.cache-hit != 'true'
      - name: Install OS dependencies
        env:
          DEBIAN_FRONTEND: noninteractive
        run: |
          sudo apt-get install gettext
      - name: Run test suite
        env:
          RL_CI_TEST: ${{ matrix.suite }}
          bash ./.ci/run-tests-for-ci.sh
      - name: Test command line tool
        if: matrix.suite == 'base'
        run: |
          git clone https://github.com/inducer/relate-sample
          cd relate-sample

          poetry run relate validate .
          poetry run relate test-code questions/autograded-python-example.yml
          poetry run relate expand-yaml flows/quiz-test.yml > /dev/null
  pytest-windows:
    name: Python - Windows
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v1
        with:
          python-version: '3.x'
      - name: Install Poetry
        uses: snok/install-poetry@v1.2.1
          version: "1.1.11"
          virtualenvs-create: true
      - name: Configure Poetry
        run: |
          poetry config virtualenvs.in-project true
      - name: Install Dependencies
        run: poetry install
      - name: Run test suite
        env:
          RELATE_LOCAL_TEST_SETTINGS: "local_settings_example.py"
        run: |
          poetry run pytest -rxsw --cov-config=setup.cfg --cov-report=xml --cov=. --tb=native