Migrate internal code to use Direct Message terminology #3683
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
permissions: | |
contents: read | |
env: | |
LINTING_PYTHON_VERSION: 3.8 | |
jobs: | |
mypy: | |
runs-on: ubuntu-latest | |
name: Lint - Type consistency (mypy) | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.LINTING_PYTHON_VERSION }} | |
cache: 'pip' | |
cache-dependency-path: 'setup.py' | |
- name: Install with type-checking tools, stubs & minimal test libraries | |
run: pip install .[typing,testing_minimal] | |
- name: Run mypy | |
run: ./tools/run-mypy | |
ruff: | |
runs-on: ubuntu-latest | |
name: Lint - PEP8 & more (ruff) | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.LINTING_PYTHON_VERSION }} | |
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@v4 | |
with: | |
persist-credentials: false | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.LINTING_PYTHON_VERSION }} | |
cache: 'pip' | |
cache-dependency-path: 'setup.py' | |
- name: Install with linting tools & minimal test libraries | |
# NOTE: Install pytest so that isort recognizes it as a known library | |
run: pip install .[linting,minimal_testing] | |
- name: Run isort | |
run: ./tools/run-isort-check | |
black: | |
runs-on: ubuntu-latest | |
name: Lint - Code format (black) | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.LINTING_PYTHON_VERSION }} | |
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 (codespell, typos) | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.LINTING_PYTHON_VERSION }} | |
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 & docs sync (lint-hotkeys) | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.LINTING_PYTHON_VERSION }} | |
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 & docs sync (lint-docstring) | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.LINTING_PYTHON_VERSION }} | |
cache: 'pip' | |
cache-dependency-path: 'setup.py' | |
- name: Minimal install | |
run: pip install . | |
- name: Run lint-docstring | |
run: ./tools/lint-docstring | |
gitlint: | |
runs-on: ubuntu-latest | |
name: Lint - Commit text format (gitlint) | |
steps: | |
- name: 'PR commits +1' | |
if: github.event_name == 'pull_request' | |
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}" | |
- name: 'Checkout PR branch and all PR commits' | |
if: github.event_name == 'pull_request' | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
ref: ${{ github.event.pull_request.head.sha }} | |
fetch-depth: ${{ env.PR_FETCH_DEPTH }} | |
- uses: actions/setup-python@v5 | |
if: github.event_name == 'pull_request' | |
with: | |
python-version: ${{ env.LINTING_PYTHON_VERSION }} | |
cache: 'pip' | |
cache-dependency-path: 'setup.py' | |
- name: Install with gitlint | |
if: github.event_name == 'pull_request' | |
run: pip install .[gitlint] | |
- name: Run gitlint | |
if: github.event_name == 'pull_request' | |
run: | |
git fetch https://github.com/zulip/zulip-terminal main; | |
gitlint --commits FETCH_HEAD..${{ github.event.pull_request.head.sha }} | |
base_pytest: | |
runs-on: ubuntu-latest | |
name: Install & test - CPython 3.7 (ubuntu), codecov | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Install Python version | |
uses: actions/setup-python@v5 | |
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 | |
- gitlint | |
steps: | |
- uses: actions/checkout@v4 | |
if: github.event_name == 'pull_request' | |
with: | |
persist-credentials: false | |
ref: ${{ github.event.pull_request.head.sha }} | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
if: github.event_name == 'pull_request' | |
with: | |
python-version: ${{ env.LINTING_PYTHON_VERSION }} | |
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: 'pypy-3.10', OS: ubuntu-latest, NAME: "PyPy 3.10 (ubuntu)", EXPECT: "Linux"} | |
- {PYTHON: '3.11', OS: macos-latest, NAME: "CPython 3.11 (macos)", EXPECT: "MacOS"} | |
env: | |
EXPECT: ${{ matrix.env.EXPECT }} | |
PYTHON: ${{ matrix.env.PYTHON }} | |
runs-on: ${{ matrix.env.OS }} | |
name: Install & test - ${{ matrix.env.NAME}} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Install Python version ${{ matrix.env.PYTHON }} | |
uses: actions/setup-python@v5 | |
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 python environment correctly | |
run: python -c "from zulipterminal.platform_code import detected_python_short; import os; e, d = os.environ['PYTHON'], detected_python_short(); assert d == e, f'{d} != {e}'" | |
- 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= |