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
15 changes: 15 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
**리뷰어가 작업내용을 이해하기 쉽도록 아래내용을 상세히 작성해주세요.**

## Changes

-

## Test

> **💡** _진행한 테스트에 대해서 구체적으로 작성해주세요._

-

## Task Link

> **💡** _관련 페이지 링크를 작성해주세요._
15 changes: 15 additions & 0 deletions .github/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
template: |
## Changes
$CHANGES

**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION

sort-by: 'title'
version-resolver:
minor:
labels:
- 'feature'
default: patch
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
4 changes: 4 additions & 0 deletions .github/pr-version-labeler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: 1
labels:
- label: 'feature'
title: '^feat:.*'
10 changes: 10 additions & 0 deletions .github/workflows/auto-release-on-pyproject-version-update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Auto Release on Pyproject Version Update

on:
pull_request:
types: [closed]

jobs:
draft-release:
uses: alphaprime-dev/alpha-actions/.github/workflows/auto-release-on-uv-pyproject-version-update.yaml@main
secrets: inherit
10 changes: 10 additions & 0 deletions .github/workflows/pr-version-labeler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: PR Version Labeler

on:
pull_request:
types: [opened, edited]

jobs:
version-labeler:
uses: alphaprime-dev/alpha-actions/.github/workflows/pr-version-labeler.yaml@main
secrets: inherit
35 changes: 35 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test

on:
pull_request:
types: [review_requested, ready_for_review]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

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

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: install dependencies
run: uv sync --locked --no-group dev

- name: test
run: uv run pytest

- name: Prune uv cache
run: uv cache prune --ci
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
Expand Down
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.2
hooks:
# run the linter
- id: ruff
args: [--fix]
# run the formatter
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.15.0
hooks:
- id: "mypy"
additional_dependencies: ["pytest", "polars"]
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"charliermarsh.ruff",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.mypy-type-checker"
]
}
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"python.languageServer": "Pylance",
"python.analysis.typeCheckingMode": "off",
"[python]": {
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "charliermarsh.ruff"
},
"ruff.importStrategy": "fromEnvironment",
"mypy-type-checker.importStrategy": "fromEnvironment",
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
Empty file added alphastats/__init__.py
Empty file.
68 changes: 68 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[project]
name = "alphastats"
version = "0.1.0"
description = "Blazing-fast portfolio analytics powered by Polars, with a QuantStats-style API."
readme = "README.md"
requires-python = ">=3.11"
dependencies = ["polars>=1.0.0,<2"]

[dependency-groups]
dev = [
"mypy==1.15.0",
"pre-commit>=4.2.0",
"pytest>=8.3.5",
"pytest-asyncio>=1.0.0",
"ruff==0.11.2",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.mypy]
python_version = "3.10"
ignore_missing_imports = true
disallow_any_generics = true
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
disallow_untyped_decorators = true
check_untyped_defs = true
strict_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
allow_redefinition = false
show_column_numbers = true
pretty = true

[tool.ruff]
line-length = 100
fix = true
exclude = [
'*.pyi',
"site-packages",
"node_modules",
".mypy_cache",
".ruff_cache",
]
target-version = "py310"

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"UP", # pyupgrade
]
unfixable = ["B"] # Avoid trying to fix flake8-bugbear (`B`) violations.
preview = true

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["E402", "F401"]
"constants.py" = ["E501"]

[tool.pytest.ini_options]
asyncio_mode = "auto"
53 changes: 53 additions & 0 deletions scripts/commit-msg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/python3

import re
import sys

COMMIT_MESSAGE_REGEX = (
r'^((revert: ")?(feat|fix|docs|style|refactor|perf|test|ci|build|chore)'
r"(\(.*\))?!?:\s.{1,50})"
)


def valid_commit_message(message: str) -> bool:
"""

Function to validate the commit message
Args:
message (str): The message to validate
Returns:
bool: True for valid messages, False otherwise

"""
if not re.match(COMMIT_MESSAGE_REGEX, message):
print(
"Proper commit message format is required for automated changelog"
"generation. Examples:\n\n"
)
print("feat(compiler): add 'comments' option")
print("fix(v-model): handle events on blur (close #28)\n\n")
print("See COMMIT_CONVENTION from Notion for more details.\n")
print("You can also use cz commit to interactively generate a commit message.\n")
return False

print("Commit message is valid.")
return True


def main() -> None:
"""Main function."""
message_file = sys.argv[1]
try:
txt_file = open(message_file)
commit_message = txt_file.read()
finally:
txt_file.close()

if not valid_commit_message(commit_message):
sys.exit(1)

sys.exit(0)


if __name__ == "__main__":
main()
12 changes: 12 additions & 0 deletions scripts/git-hooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -ex

# pre-commit hook install from pip
pre-commit install

# symlink
ln -sf ../../scripts/commit-msg.py ./.git/hooks/commit-msg

# implement permission
chmod +x .git/hooks/commit-msg
Empty file added tests/__init__.py
Empty file.
Loading