Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,15 @@ If you're contributing code, please check out [How to contribute](https://www.md

MDAnalysis devs are most easily reached through the [development list](https://groups.google.com/forum/#!forum/mdnalysis-devel).

#### Local quality checks

Before opening a pull request, please run the same style checks locally using pre-commit:

```bash
python -m pip install pre-commit
pre-commit install
pre-commit run --all-files
```

Running these checks before pushing helps keep pull requests focused and reduces CI turnaround time.

48 changes: 48 additions & 0 deletions .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,54 @@ defaults:
shell: bash -l {0}

jobs:
precommit:
if: "github.repository == 'MDAnalysis/mdanalysis'"
runs-on: ubuntu-latest
timeout-minutes: 10
env:
PRE_COMMIT_HOME: ~/.cache/pre-commit
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: cache pre-commit
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}

- name: install pre-commit
run: |
python -m pip install --upgrade pip pre-commit

- name: run pre-commit
run: |
pre-commit run --all-files

ruff_check:
if: "github.repository == 'MDAnalysis/mdanalysis'"
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: install ruff
run: |
python -m pip install --upgrade pip ruff

- name: run ruff
run: |
ruff check package testsuite

Comment on lines +19 to +66
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new precommit job runs the Ruff and Black hooks (per .pre-commit-config.yaml), but this workflow also runs Ruff again (ruff_check) and still has a dedicated black job. This triples the same checks and increases CI time; consider either (1) using pre-commit as the single quality gate and dropping the redundant Ruff/Black jobs, or (2) configuring pre-commit here to run only the non-duplicated hooks.

Copilot uses AI. Check for mistakes.
black:
if: "github.repository == 'MDAnalysis/mdanalysis'"
runs-on: ubuntu-latest
Expand Down
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-ast
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.10
hooks:
- id: ruff
files: ^(package|testsuite)/

- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
files: ^(package|testsuite)/
args: [--line-length=88]
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pre-commit Black hook is configured with --line-length=88, but the repository’s canonical Black configuration in package/pyproject.toml and testsuite/pyproject.toml sets line-length = 79. This will cause inconsistent formatting (and likely CI failures against the existing GitHub Actions Black job). Align the pre-commit Black hook with the existing tool.black settings (or remove the explicit --line-length so Black reads from the pyproject config).

Suggested change
args: [--line-length=88]

Copilot uses AI. Check for mistakes.
5 changes: 5 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
line-length = 88
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.ruff.toml sets line-length = 88, but Black is configured for line-length = 79 in both package/pyproject.toml and testsuite/pyproject.toml. Even though the current Ruff rule selection is limited, keeping Ruff’s line-length consistent with Black avoids future drift when additional rules (or formatting) are enabled.

Suggested change
line-length = 88
line-length = 79

Copilot uses AI. Check for mistakes.
target-version = "py311"

[lint]
select = ["E9", "F63", "F7", "F82"]
77 changes: 77 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,84 @@ pr:


jobs:
- job: Precommit_Lint
displayName: 'Pre-commit checks'
pool:
vmImage: 'ubuntu-latest'
variables:
PRE_COMMIT_HOME: '$(Pipeline.Workspace)/.pre-commit-cache'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.11'
addToPath: true
architecture: 'x64'
- task: Cache@2
inputs:
key: 'pre-commit | "$(Agent.OS)" | .pre-commit-config.yaml'
path: '$(PRE_COMMIT_HOME)'
restoreKeys: |
pre-commit | "$(Agent.OS)"
- script: python -m pip install --upgrade pip pre-commit
displayName: 'Install pre-commit'
- script: PRE_COMMIT_HOME=$(PRE_COMMIT_HOME) pre-commit run --all-files
displayName: 'Run pre-commit hooks'

- job: Ruff_Lint
displayName: 'Ruff lint checks'
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.11'
addToPath: true
architecture: 'x64'
- script: python -m pip install --upgrade pip ruff
displayName: 'Install ruff'
- script: ruff check package testsuite
displayName: 'Run ruff checks'

Comment on lines +41 to +55
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Precommit_Lint already runs the Ruff hook from .pre-commit-config.yaml, but this pipeline adds a separate Ruff_Lint job that runs ruff check again. This duplicates work and makes it easier for the two jobs to drift in configuration over time; consider relying on pre-commit as the single source of truth (or remove Ruff from pre-commit and keep it standalone), but avoid running both.

Suggested change
- job: Ruff_Lint
displayName: 'Ruff lint checks'
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.11'
addToPath: true
architecture: 'x64'
- script: python -m pip install --upgrade pip ruff
displayName: 'Install ruff'
- script: ruff check package testsuite
displayName: 'Run ruff checks'

Copilot uses AI. Check for mistakes.
- job: Smoke_Tests
displayName: 'Smoke tests'
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.11'
addToPath: true
architecture: 'x64'
- script: python -m pip install --upgrade pip setuptools wheel
displayName: 'Install tools'
- script: >-
python -m pip install --only-binary=scipy,h5py
cython
h5py>=2.10
matplotlib
numpy
packaging
pytest
tqdm
threadpoolctl
filelock
Comment on lines +70 to +78
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The smoke job installs a large set of unpinned runtime/test dependencies (e.g., numpy/matplotlib/pytest) directly from PyPI. Because this job is now a required quality gate for the full matrix, upstream releases can introduce flaky CI failures unrelated to the PR. Consider pinning these to a known-good constraints file (or to the same minimum/compatible versions used elsewhere in CI) to keep the smoke gate stable.

Suggested change
cython
h5py>=2.10
matplotlib
numpy
packaging
pytest
tqdm
threadpoolctl
filelock
cython==3.0.8
h5py==3.10.0
matplotlib==3.8.2
numpy==1.26.4
packaging==23.2
pytest==7.4.4
tqdm==4.66.1
threadpoolctl==3.2.0
filelock==3.13.1

Copilot uses AI. Check for mistakes.
displayName: 'Install smoke dependencies'
- script: >-
python -m pip install
./package
./testsuite
displayName: 'Install package and testsuite'
- script: >-
pytest testsuite/MDAnalysisTests/test_api.py
--disable-pytest-warnings
-q
displayName: 'Run smoke tests'

- job: Azure_Tests
dependsOn:
- Precommit_Lint
- Ruff_Lint
- Smoke_Tests
condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/develop')) # skip for PR merges
variables:
MPLBACKEND: agg
Expand Down
Loading