Skip to content
Merged
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
131 changes: 131 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# GitHub Copilot Instructions for AIMBAT

## Code Style and Standards

### PEP 8 Compliance

- Follow [PEP 8](https://peps.python.org/pep-0008/) style guide for all Python code
- Use 4 spaces for indentation (no tabs)
- Maximum line length: 88 characters (Black default)
- Use blank lines to separate functions and classes
- Imports should be grouped: standard library, third-party, local

### Code Formatting

- All code must pass **Black** formatting
- Target Python versions: 3.12, 3.13, 3.14
- Line length: 88 characters
- Run `black .` before committing

- All code must pass **Ruff** linting
- Configuration in `pyproject.toml`
- Run `ruff check .` before committing
- Fix issues with `ruff check --fix .`

### Language

- Use **British English** spelling in all:
- Comments
- Docstrings
- Variable names
- Documentation
- Error messages
- Examples:
- `colour` not `color`
- `normalise` not `normalize`
- `initialise` not `initialize`
- `behaviour` not `behavior`
- `centre` not `center`

### Documentation Style

#### Docstrings

- Use **Google Style** docstrings for all public functions, classes, and methods
- Format:

```python
def function_name(param1: type1, param2: type2) -> return_type:
"""Brief one-line description.

Longer description if needed, explaining the purpose and behaviour
of the function in more detail.

Args:
param1: Description of param1.
param2: Description of param2.
Multi-line descriptions should be indented.

Returns:
Description of the return value.

Raises:
ErrorType: Description of when this error is raised.

Examples:
>>> function_name(value1, value2)
expected_output
"""
```

#### Type Hints

- Use type hints for all function parameters and return values
- Use modern Python type syntax (Python 3.12+):
- `list[str]` not `List[str]`
- `dict[str, int]` not `Dict[str, int]`
- `type1 | type2` not `Union[type1, type2]`
- `type | None` not `Optional[type]`

### Testing

- Write tests for all new functionality
- Use pytest framework
- Tests should be in the `tests/` directory
- Use descriptive test names: `test_function_does_expected_behaviour`
- Try to mirror the directory structure of `src/aimbat/` in `tests/`

### Commit Messages

- Use clear, descriptive commit messages
- Follow conventional commits format when appropriate
- Use British English spelling

## Review Priorities

- Take the above Code Style and Standards into account when reviewing pull requests
- Suggest improvements to code style, efficiency, documentation, and testing
- Suggest improvements to variable names, function names, and overall code readability
- Suggest newer syntax features where appropriate
- Check spelling
- Check if docstrings in existing code follow Google style and suggest improvements if needed

## Project-Specific Guidelines

### Seismology Domain

- Follow seismological conventions for variable names
- Use proper units and document them
- Maintain scientific accuracy in all calculations

### Dependencies

- Minimum Python version: 3.12
- Core dependencies: pysmo, sqlmodel, numpy, scipy, matplotlib
- Keep dependencies up to date

### File Organisation

- Source code in `src/aimbat/`
- Tests in `tests/`
- Documentation in `docs/`
- Use appropriate module structure

## Before Committing

1. Run `black .` to format code
2. Run `ruff check --fix .` to check and fix linting issues
3. Run tests with `pytest`
4. Verify type hints with `mypy`
5. Check British English spelling
6. Ensure docstrings follow Google style
32 changes: 1 addition & 31 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ on:
- master
types:
- completed
push:
tags:
- "v?[0-9]+.[0-9]+.[0-9]+-?*"

jobs:
build:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -35,31 +33,3 @@ jobs:
- name: Build sdist and wheel
run: |
uv build
- name: Upload build artifacts
if: ${{ matrix.python-version == '3.14' && github.event.workflow_run.conclusion == 'success'}}
uses: actions/upload-artifact@v4
with:
name: packages
path: dist

publish:
needs: build
runs-on: ubuntu-latest

steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: packages
path: dist
- name: Publish distribution 📦 to Test PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
127 changes: 127 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: release

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+.dev[0-9]+"

jobs:
build:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
python-version: "3.14"
- name: Build sdist and wheel
run: uv build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: packages
path: dist

publish-testpypi:
needs: build
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: testpypi
url: https://test.pypi.org/p/aimbat
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: packages
path: dist
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

publish-pypi:
needs: publish-testpypi
# Only publish to PyPI if it's NOT a dev release
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '.dev')
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: pypi
url: https://pypi.org/p/aimbat
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: packages
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_TOKEN }}
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Determine pre-release status
id: prerelease
run: |
VERSION=$(uvx --with hatch-vcs hatch version)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
if [[ "$VERSION" =~ (a|b|rc|dev) ]]; then
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
fi
- name: Generate release notes
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --latest --strip header
env:
OUTPUT: RELEASE_NOTES.md
- name: Update CHANGELOG.md
if: steps.prerelease.outputs.is_prerelease == 'false'
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --tag ${{ github.ref_name }}
env:
OUTPUT: CHANGELOG.md
- name: Commit CHANGELOG.md
if: steps.prerelease.outputs.is_prerelease == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add CHANGELOG.md
git commit -m "docs: update CHANGELOG.md for ${{ github.ref_name }}"
git push origin HEAD:master
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: packages
path: dist
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
body_path: RELEASE_NOTES.md
prerelease: ${{ steps.prerelease.outputs.is_prerelease }}
files: dist/*
Loading
Loading