Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update readme and fix CI #15

Merged
merged 12 commits into from
Oct 9, 2024
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
2 changes: 1 addition & 1 deletion .github/test_conda_env.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test
name: dbscan1d
channels:
- conda-forge
- defaults
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Lint the code using the defined pre-commits
name: LintCode
on: [push]

jobs:
lint_code:
runs-on: ubuntu-latest

# only run if CI isn't turned off
if: github.event_name == 'push' || !contains(github.event.pull_request.labels.*.name, 'no_ci')

steps:
- uses: actions/checkout@v4

- name: "get tags"
run: |
git fetch --tags --force # Retrieve annotated tags.

- name: Install uv
uses: astral-sh/setup-uv@v3

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: install linting packages
run: uv tool install pre-commit

- name: run all precommits
run: uv run pre-commit run --all
41 changes: 0 additions & 41 deletions .github/workflows/on_master_commits.yml

This file was deleted.

28 changes: 13 additions & 15 deletions .github/workflows/release_published.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,25 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Setup conda
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: 'latest'
python-version: "3.11"
activate-environment: test
environment-file: .github/test_conda_env.yml
condarc-file: .github/test_condarc.yml

- name: install
shell: bash -l {0}
- name: "get tags"
run: |
pip install -e .[dev]
git fetch --tags --force # Retrieve annotated tags.

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python
run: uv python install 3.12

- name: Install the project
run: uv sync --all-extras --dev

- name: create dists
shell: bash -l {0}
run: |
python -m pip install build
python -m build
uv build

- name: publish package
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
103 changes: 62 additions & 41 deletions .github/workflows/runtests.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,79 @@
name: validate
on: [push]
# Run full test suite using conda env and all optional deps.
name: TestCode
on:
push:
branches:
- master
pull_request:
branches:
- master
paths:
- 'pyproject.toml'
- '**.py'
- '.github/workflows/*.yml'

jobs:
# Simply applies flake8 to code using pre-commit
lint_code:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- name: Setup conda
uses: s-weigand/setup-conda@v1
with:
python-version: "3.10"

- name: install linting packages
run: pip install pre-commit

- name: run all precommits
run: pre-commit run --all
# Cancel previous runs when this one starts.
concurrency:
group: TestCode-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true

jobs:
# Runs the tests on combinations of the supported python/os matrix.
test_code:

timeout-minutes: 25
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ['3.10', '3.11', "3.12"]

# only run if CI isn't turned off
if: github.event_name == 'push' || !contains(github.event.pull_request.labels.*.name, 'no_ci')

env:
# set conda environment file with dependencies
env_file: "test_conda_env.yml"

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4

- name: Setup conda
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: 'latest'
python-version: ${{ matrix.python-version }}
activate-environment: test
environment-file: .github/test_conda_env.yml
condarc-file: .github/test_condarc.yml

- name: install
shell: bash -l {0}
- name: "get tags"
run: |
pip install -e .
git fetch --tags --force # Retrieve annotated tags.

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install the project
run: uv sync --all-extras --dev

# Print out the package info for current environment
- name: print package info
shell: bash -l {0}
shell: bash -el {0}
run: |
conda info -a
conda list
uv pip list

# Runs test suite and calculates coverage
- name: run test suite
shell: bash -l {0}
run: |
pytest tests
- name: Run tests
# For example, using `pytest`
run: uv run pytest -s --cov dbscan1d --cov-append --cov-report=xml

# Upload coverage files
- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
files: ./coverage.xml
flags: unittests
name: PR_tests
token: ${{ secrets.CODECOV_TOKEN }}


# This is a very useful step for debugging, it allows you to ssh into the CI
# machine (https://github.com/marketplace/actions/debugging-with-tmate).
#
#- name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,6 @@ docs/quickref/stubs

# mypy
.mypy_cache

# uv
uv.lock
45 changes: 17 additions & 28 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@
exclude: scripts/
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-merge-conflict
- id: mixed-line-ending
args: ['--fix=lf']
- repo: https://github.com/psf/black
rev: 22.6.0

# Ruff is a replacement for flake8 and many other linters (much faster too)
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.1
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 3.8.3
- id: ruff
args: ["--fix"]
# Run the formatter.
- id: ruff-format

# ensures __future__ import annotations at top of files which require it
# for the typing features they are using.
- repo: https://github.com/frostming/fix-future-annotations
rev: 0.5.0
hooks:
- id: flake8
additional_dependencies:
- flake8-black
- flake8-breakpoint
- flake8-docstrings
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black"]
- id: isort
name: isort (cython)
types: [cython]
- id: isort
name: isort (pyi)
types: [pyi]
- repo: https://github.com/kynan/nbstripout
rev: 0.3.9
hooks:
- id: nbstripout
files: ".ipynb"
- id: fix-future-annotations
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ It only requires numpy.

## Quickstart
dbscan1d is designed to be interchangable with sklearn's implementation in almost
all cases. The exception is that the `weights` parameter is not yet supported.
all cases.

```python
from sklearn.datasets import make_blobs
Expand Down
Loading