Skip to content

Commit d8bc020

Browse files
committed
Add initial implementation
1 parent c37b1e3 commit d8bc020

File tree

18 files changed

+2588
-0
lines changed

18 files changed

+2588
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*.py]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true

.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
max-line-length = 88
3+
ignore = E203, W503
4+
exclude = .git,__pycache__,env,.venv,venv

.github/workflows/cd.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: "CD"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release-type:
7+
description: "Type of release?"
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
15+
jobs:
16+
release:
17+
name: "Release"
18+
if: github.event.inputs.branch == 'main'
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- uses: actions/setup-python@v4
24+
with:
25+
python-version: "3.11"
26+
27+
- uses: Gr1N/setup-poetry@v8
28+
with:
29+
poetry-version: "1.2.2"
30+
31+
- name: "Bump `git_vector.__version__`"
32+
run: sed -i 's/^__version__ *=.*/__version__ = "${{ steps.bump.outputs.version }}"/' git_vector/__init__.py
33+
34+
- name: "Update the changelog"
35+
# Find the first line that starts with `###` or `## [<number>` from the CHANGELOG and insert the new version header before it.
36+
run: sed -i "0,/^\(###\|## *\[[0-9]\).*/{s//## [${{ steps.bump.outputs.version }}] - $(date -u '+%Y-%m-%d')\n\n&/}" CHANGELOG.md
37+
38+
- name: "Extract version's changelog for release notes"
39+
# 1. Find the lines between the first `## [<number>` and the second `## [<number>`.
40+
# 2. Remove all leading and trailing newlines from the output.
41+
run: sed '1,/^## *\[[0-9]/d;/^## *\[[0-9]/Q' CHANGELOG.md | sed -e :a -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba' > release_notes.txt
42+
43+
- name: "Commit and tag the changes"
44+
run: |
45+
git config user.name 'github-actions'
46+
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
47+
git add pyproject.toml git_vector/__init__.py CHANGELOG.md
48+
git commit --message='Release ${{ steps.bump.outputs.version }}'
49+
git tag --annotate --message='' v${{ steps.bump.outputs.version }}
50+
51+
- name: "Build the wheel"
52+
run: poetry build
53+
54+
- name: "Publish to PyPI"
55+
run: poetry publish
56+
env:
57+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
58+
59+
- name: "Push the changes"
60+
run: git push --follow-tags
61+
62+
- name: "Create a GitHub release"
63+
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v1
64+
with:
65+
tag_name: v${{ steps.bump.outputs.version }}
66+
name: v${{ steps.bump.outputs.version }}
67+
body_path: release_notes.txt

.github/workflows/ci.yaml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
linters:
11+
name: "Linters"
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: "Checkout code"
15+
uses: actions/checkout@v3
16+
17+
- name: "Set up Python"
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: "3.11"
21+
22+
- name: "Install Poetry"
23+
uses: Gr1N/setup-poetry@v8
24+
25+
- name: "Load cached venv"
26+
uses: actions/cache@v2
27+
with:
28+
path: ~/.cache/pypoetry/virtualenvs
29+
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
30+
31+
- name: "Install dependencies"
32+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
33+
run: poetry install --no-root
34+
35+
- name: "Set VENV variable"
36+
run: |
37+
if [ "${{ runner.os }}" == "Windows" ]; then
38+
echo "VENV=$(poetry env info -p)\\Scripts\\activate" >> $GITHUB_ENV
39+
else
40+
echo "VENV=$(poetry env info -p)/bin/activate" >> $GITHUB_ENV
41+
fi
42+
shell: bash
43+
44+
- name: "Run linters"
45+
run: |
46+
source "$VENV"
47+
isort --check-only --diff .
48+
flake8 .
49+
black --check --diff .
50+
51+
build:
52+
name: "Build"
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: "Checkout code"
56+
uses: actions/checkout@v3
57+
58+
- name: "Set up Python"
59+
uses: actions/setup-python@v4
60+
with:
61+
python-version: "3.11"
62+
63+
- name: "Install Poetry"
64+
uses: Gr1N/setup-poetry@v8
65+
66+
- name: "Build the wheel"
67+
run: poetry build
68+
69+
- name: "Install from the wheel"
70+
run: pip install dist/*.whl
71+
72+
tests:
73+
name: "Tests"
74+
needs: [linters, build]
75+
strategy:
76+
fail-fast: true
77+
matrix:
78+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
79+
os: [ubuntu-latest, macos-latest, windows-latest]
80+
defaults:
81+
run:
82+
shell: bash
83+
runs-on: ${{ matrix.os }}
84+
steps:
85+
- name: "Checkout code"
86+
uses: actions/checkout@v3
87+
88+
- name: "Set up Python"
89+
uses: actions/setup-python@v4
90+
with:
91+
python-version: "3.11"
92+
93+
- name: "Install Poetry"
94+
uses: Gr1N/setup-poetry@v8
95+
96+
- name: "Load cached venv"
97+
uses: actions/cache@v2
98+
with:
99+
path: ~/.cache/pypoetry/virtualenvs
100+
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
101+
102+
- name: "Install dependencies"
103+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
104+
run: poetry install --no-root
105+
106+
- name: "Install the package"
107+
run: poetry install
108+
109+
- name: "Set VENV variable"
110+
run: |
111+
if [ "${{ runner.os }}" == "Windows" ]; then
112+
echo "VENV=$(poetry env info -p)\\Scripts\\activate" >> $GITHUB_ENV
113+
else
114+
echo "VENV=$(poetry env info -p)/bin/activate" >> $GITHUB_ENV
115+
fi
116+
shell: bash
117+
118+
- name: "Run type-checking"
119+
run: |
120+
source "$VENV"
121+
mypy .
122+
123+
- name: "Run tests"
124+
run: |
125+
source "$VENV"
126+
pytest --verbose --cov=. --cov-report=xml .
127+
128+
- name: "Upload coverage"
129+
if: matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest'
130+
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
131+
with:
132+
files: coverage.xml

.gitignore

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110+
.pdm.toml
111+
.pdm-python
112+
.pdm-build/
113+
114+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115+
__pypackages__/
116+
117+
# Celery stuff
118+
celerybeat-schedule
119+
celerybeat.pid
120+
121+
# SageMath parsed files
122+
*.sage.py
123+
124+
# Environments
125+
.env
126+
.venv
127+
env/
128+
venv/
129+
ENV/
130+
env.bak/
131+
venv.bak/
132+
133+
# Spyder project settings
134+
.spyderproject
135+
.spyproject
136+
137+
# Rope project settings
138+
.ropeproject
139+
140+
# mkdocs documentation
141+
/site
142+
143+
# mypy
144+
.mypy_cache/
145+
.dmypy.json
146+
dmypy.json
147+
148+
# Pyre type checker
149+
.pyre/
150+
151+
# pytype static type analyzer
152+
.pytype/
153+
154+
# Cython debug symbols
155+
cython_debug/
156+
157+
# PyCharm
158+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160+
# and can be added to the global gitignore or merged into this file. For a more nuclear
161+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162+
#.idea/
163+
164+
embeddings_cache/

0 commit comments

Comments
 (0)