-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
604 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[run] | ||
omit = src/forms/*,src/vendor/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
github: abdnh | ||
patreon: abdnh | ||
custom: ["https://www.buymeacoffee.com/abdnh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Run checks & tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- "master" | ||
- "main" | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
fetch-depth: 0 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install dependencies | ||
run: .github/workflows/install_deps.sh | ||
|
||
- name: Run checks | ||
run: SKIP=pip-compile pre-commit run --all-files | ||
|
||
- name: Run tests | ||
run: make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Create Release | ||
|
||
on: | ||
create: | ||
tags: | ||
- "*" | ||
permissions: | ||
contents: write | ||
jobs: | ||
create-release: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
fetch-depth: 0 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install dependencies | ||
run: .github/workflows/install_deps.sh | ||
|
||
- name: Create packages | ||
run: make | ||
|
||
- name: Extract changes | ||
shell: bash | ||
run: | | ||
python .github/workflows/extract_changes.py ${{ github.ref }} > build/RELEASE.md | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: build/*.ankiaddon | ||
body_path: build/RELEASE.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"Print relevant changes from CHANGELOG.md given a version" | ||
|
||
import re | ||
import sys | ||
from pathlib import Path | ||
|
||
changelog = Path("CHANGELOG.md").read_text(encoding="utf-8") | ||
|
||
version = sys.argv[1].replace("refs/tags/", "") | ||
m = re.search(r"\[%s\].*?\n(.*)" % re.escape(version), changelog, re.DOTALL) | ||
if not m: | ||
sys.exit(0) | ||
else: | ||
changes = m.group(1).split("\n## ")[0] | ||
print(changes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
pip install -r requirements/base.txt | ||
pip-sync requirements/dev.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
__pycache__/ | ||
venv/ | ||
*.pyc | ||
vendor/ | ||
.mypy_cache/ | ||
.pytest_cache/ | ||
htmlcov/ | ||
.coverage | ||
ankidata/ | ||
build/ | ||
src/manifest.json | ||
src/meta.json | ||
src/forms/ | ||
src/user_files/*/ | ||
src/user_files/config.json | ||
*.ankiaddon | ||
TODO.md | ||
vendor/ | ||
node_modules/ | ||
TODO.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[settings] | ||
profile=black | ||
skip=vendor,venv,ankidata | ||
skip=venv,ankidata,vendor,forms,user_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
exclude: "venv|vendor|build" | ||
default_stages: [commit] | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-json | ||
exclude: ".vscode(.dist)?/.*" | ||
- id: pretty-format-json | ||
args: ["--autofix", "--indent", "4", "--no-ensure-ascii"] | ||
exclude: ".vscode.dist/launch.json" | ||
- id: check-yaml | ||
- id: check-builtin-literals | ||
- id: check-case-conflict | ||
- id: check-docstring-first | ||
- id: check-shebang-scripts-are-executable | ||
- id: mixed-line-ending | ||
- id: detect-private-key | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 23.7.0 | ||
hooks: | ||
- id: black | ||
|
||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
|
||
- repo: local | ||
hooks: | ||
- id: pylint | ||
name: pylint | ||
entry: python -m pylint src tests | ||
language: system | ||
types: [python] | ||
- id: mypy | ||
name: mypy | ||
entry: python -m mypy | ||
language: system | ||
types: [python] | ||
- id: pip-compile | ||
name: pip-compile base | ||
entry: python -m ankiscripts.update_deps --type base | ||
language: system | ||
files: ^(requirements/base\.(in|txt))$ | ||
pass_filenames: false | ||
- id: pip-compile | ||
name: pip-compile bundle | ||
entry: python -m ankiscripts.update_deps --type bundle | ||
language: system | ||
files: ^(requirements/bundle\.(in|txt))$ | ||
pass_filenames: false | ||
- id: pip-compile | ||
name: pip-compile dev | ||
entry: python -m ankiscripts.update_deps --type dev | ||
language: system | ||
files: ^(requirements/dev\.(in|txt))$ | ||
pass_filenames: false | ||
|
||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: v3.0.1 | ||
hooks: | ||
- id: prettier | ||
args: ["--tab-width", "4", "--write"] | ||
exclude: "ankiweb_page.html" | ||
|
||
ci: | ||
autoupdate_schedule: weekly | ||
skip: [] | ||
submodules: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
[MASTER] | ||
extension-pkg-whitelist=PyQt6,PyQt5 | ||
ignore-paths=ankidata,venv | ||
ignore = venv,ankidata,vendor,forms,user_files | ||
|
||
[REPORTS] | ||
output-format=colorized | ||
|
||
[MESSAGES CONTROL] | ||
disable= | ||
line-too-long, | ||
too-many-lines, | ||
missing-function-docstring, | ||
missing-module-docstring, | ||
missing-class-docstring, | ||
missing-function-docstring, | ||
import-outside-toplevel, | ||
wrong-import-position, | ||
wrong-import-order, | ||
fixme, | ||
unused-wildcard-import, | ||
attribute-defined-outside-init, | ||
redefined-builtin, | ||
wildcard-import, | ||
broad-except, | ||
bare-except, | ||
unused-argument, | ||
|
||
[BASIC] | ||
good-names = | ||
mw | ||
unused-variable, | ||
redefined-outer-name, | ||
global-statement, | ||
protected-access, | ||
arguments-renamed, | ||
consider-using-f-string, | ||
invalid-name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"recommendations": [ | ||
"ms-python.python", | ||
"ms-python.pylint", | ||
"ms-python.black-formatter", | ||
"ms-python.isort", | ||
"matangover.mypy", | ||
"abdo.ankiwebify" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Run add-on", | ||
"type": "python", | ||
"request": "launch", | ||
"module": "ankiscripts.run", | ||
"console": "integratedTerminal", | ||
"justMyCode": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"[html]": { | ||
"editor.formatOnSave": false | ||
}, | ||
"[python]": { | ||
"editor.defaultFormatter": "ms-python.black-formatter" | ||
}, | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
}, | ||
"editor.formatOnSave": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
.PHONY: all zip clean mypy pylint fix vendor | ||
all: zip | ||
.PHONY: all zip ankiweb vendor fix mypy pylint test clean | ||
|
||
PACKAGE_NAME := create_sub2srs_cards_with_mpv | ||
all: zip ankiweb | ||
|
||
zip: $(PACKAGE_NAME).ankiaddon | ||
zip: | ||
python -m ankiscripts.build --type package --qt all --exclude user_files/*.json | ||
|
||
$(PACKAGE_NAME).ankiaddon: src/* | ||
rm -f $@ | ||
find -L src/ -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete | ||
( cd src/; zip -r ../$@ * -x user_files/config.json ) | ||
ankiweb: | ||
python -m ankiscripts.build --type ankiweb --qt all --exclude user_files/*.json | ||
|
||
vendor: | ||
pip install -r requirements.txt -t src/vendor | ||
python -m ankiscripts.vendor | ||
|
||
fix: | ||
python -m black src --exclude="vendor" | ||
python -m isort src | ||
python -m black src tests --exclude="forms|vendor" | ||
python -m isort src tests | ||
|
||
mypy: | ||
python -m mypy src | ||
python -m mypy src tests | ||
|
||
pylint: | ||
python -m pylint src | ||
python -m pylint src tests | ||
|
||
test: | ||
python -m pytest --cov=src --cov-config=.coveragerc | ||
|
||
clean: | ||
rm -f $(PACKAGE_NAME).ankiaddon | ||
rm -rf build/ |
Oops, something went wrong.