Skip to content

Use stream name instead of stream id to order unread topics in the next_unread_topic_from_message_id algorithm. #2906

Use stream name instead of stream id to order unread topics in the next_unread_topic_from_message_id algorithm.

Use stream name instead of stream id to order unread topics in the next_unread_topic_from_message_id algorithm. #2906

Workflow file for this run

name: Linting & tests
on:
push:
branches: [main]
tags: ["*"]
pull_request:
workflow_dispatch:
# Cancel previous runs within same workflow and if within a PR (all branch runs complete)
# (head_ref [branch name] is unique to and only for PRs, otherwise use always-unique run_id)
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
mypy:
runs-on: ubuntu-latest
name: Lint - Type consistency (mypy)
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-python@v4
with:
python-version: 3.7
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Install with type-checking tools
run: pip install .[typing]
- name: Run mypy
run: ./tools/run-mypy
ruff:
runs-on: ubuntu-latest
name: Lint - PEP8 & more (ruff)
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-python@v4
with:
python-version: 3.7
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Install with linting tools
run: pip install .[linting]
- name: Run ruff
run: ruff zulipterminal/ tests/ setup.py `tools/python_tools.py`
isort:
runs-on: ubuntu-latest
name: Lint - Import order (isort)
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-python@v4
with:
python-version: 3.7
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Install with linting tools
# NOTE: Install pytest so that isort recognizes it as a known library
run: pip install .[linting] && pip install pytest
- name: Run isort
run: ./tools/run-isort-check
black:
runs-on: ubuntu-latest
name: Lint - Code formatting (black)
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-python@v4
with:
python-version: 3.7
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Install with linting tools
run: pip install .[linting]
- name: Check code & tests meet black standards
run: black --check zulipterminal/ tests/ setup.py `tools/python_tools.py`
spellcheck:
runs-on: ubuntu-latest
name: Lint - Spellcheck
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-python@v4
with:
python-version: 3.7
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Install with linting tools
run: pip install .[linting]
- name: Check spelling
run: ./tools/run-spellcheck
hotkeys:
runs-on: ubuntu-latest
name: Lint - Hotkeys linting & docs sync check
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-python@v4
with:
python-version: 3.7
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Minimal install
run: pip install .
- name: Run lint-hotkeys
run: ./tools/lint-hotkeys
docstrings:
runs-on: ubuntu-latest
name: Lint - Docstrings linting & docs sync check
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-python@v4
with:
python-version: 3.7
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Minimal install
run: pip install .
- name: Run lint-docstring
run: ./tools/lint-docstring
base_pytest:
runs-on: ubuntu-latest
name: Install & test - CPython 3.7 (ubuntu), codecov
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- name: Install Python version
uses: actions/setup-python@v4
with:
python-version: 3.7
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Output Python version
run: python --version
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Ensure regular package installs from checkout
run: pip install .
- name: Install test dependencies
run: pip install .[testing]
- name: Run tests with pytest
run: pytest --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
isolated-commits:
runs-on: ubuntu-latest
name: Ensure isolated PR commits
needs:
- mypy
- ruff
- isort
- black
- spellcheck
- hotkeys
- docstrings
- base_pytest
steps:
- uses: actions/checkout@v3
if: github.event_name == 'pull_request'
with:
persist-credentials: false
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- uses: actions/setup-python@v4
if: github.event_name == 'pull_request'
with:
python-version: 3.7
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Run check-branch
if: github.event_name == 'pull_request'
# Note that we install at each step since dependencies may change
run:
git fetch https://github.com/zulip/zulip-terminal main;
CHECK="pip install .[linting,testing,typing] && ./tools/lint-all && pytest" ./tools/check-branch FETCH_HEAD
pytest-on-other-platforms:
needs: isolated-commits
strategy:
# Not failing fast allows all matrix jobs to try & finish even if one fails early
fail-fast: false
matrix:
env:
- {PYTHON: 3.8, OS: ubuntu-latest, NAME: "CPython 3.8 (ubuntu)", EXPECT: "Linux"}
- {PYTHON: 3.9, OS: ubuntu-latest, NAME: "CPython 3.9 (ubuntu)", EXPECT: "Linux"}
- {PYTHON: "3.10", OS: ubuntu-latest, NAME: "CPython 3.10 (ubuntu)", EXPECT: "Linux"}
- {PYTHON: "3.11", OS: ubuntu-latest, NAME: "CPython 3.11 (ubuntu)", EXPECT: "Linux"}
- {PYTHON: 'pypy-3.7', OS: ubuntu-latest, NAME: "PyPy 3.7 (ubuntu)", EXPECT: "Linux"}
- {PYTHON: 'pypy-3.8', OS: ubuntu-latest, NAME: "PyPy 3.8 (ubuntu)", EXPECT: "Linux"}
- {PYTHON: 'pypy-3.9', OS: ubuntu-latest, NAME: "PyPy 3.9 (ubuntu)", EXPECT: "Linux"}
- {PYTHON: '3.x', OS: macos-latest, NAME: "CPython 3.x [latest] (macos)", EXPECT: "MacOS"}
env:
EXPECT: ${{ matrix.env.EXPECT }}
runs-on: ${{ matrix.env.OS }}
name: Install & test - ${{ matrix.env.NAME}}
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- name: Install Python version ${{ matrix.env.PYTHON }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.env.PYTHON }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Output Python version
run: python --version
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Ensure libxml-related libraries are installed (some pypy versions don't have wheels)
if: startsWith(matrix.env.PYTHON, 'pypy-')
run: sudo apt install libxml2-dev libxslt1-dev
- name: Ensure regular package installs from checkout
run: pip install .
- name: Check we detect the platform correctly
run: python -c "from zulipterminal.platform_code import detected_platform; import os; e, d = os.environ['EXPECT'], detected_platform(); assert d == e, f'{d} != {e}'"
- name: Install test dependencies
run: pip install .[testing]
- name: Run tests with pytest
run: pytest --cov-report=