Skip to content

Commit

Permalink
♿ Add template
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Mar 7, 2024
1 parent a68f08b commit 4e89247
Show file tree
Hide file tree
Showing 39 changed files with 2,453 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
exclude: (^templates/.*|.*\.json$)
exclude: ^template(s)?/

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -23,7 +23,7 @@ repos:
- id: check-toml
- id: check-json
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
rev: v1.5.5
hooks:
- id: remove-crlf
- repo: https://github.com/codespell-project/codespell
Expand Down
37 changes: 37 additions & 0 deletions copier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
_templates_suffix: ""
_answers_file: .copier-answers.yml
_subdirectory: template

language:
type: str
help: What is your language name?

patterns:
type: str
help: What is your file patterns? split by " "
default: "*.{{ language }}"

project:
type: str
help: What is your project name?
default: "{{ language }}-language-server"

module:
type: str
help: What is your Python module name?
default: "{{ project | replace('-', '_') }}"

class:
type: str
help: What is your Python class name?
default: "{{ module | replace('_', ' ') | title | replace(' ', '') }}"

parser:
type: str
help: What is your tree-sitter parser name?
default: "tree-sitter-{{ language }}"

user:
type: str
help: What is your user name?
109 changes: 109 additions & 0 deletions template/.github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
"on":
push:
paths-ignore:
- "**.md"
- docs/*
pull_request:
paths-ignore:
- "**.md"
- docs/*
workflow_dispatch:

# https://github.com/softprops/action-gh-release/issues/236
permissions:
contents: write

env:
PYTHONUTF8: "1"
python-version: 3.x
cache: pip

jobs:
test:
strategy:
fail-fast: false
matrix:
runs-on:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: $\{\{matrix.runs-on\}\}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: $\{\{env.python-version\}\}
cache: $\{\{env.cache\}\}
cache-dependency-path: |-
requirements.txt
requirements/dev.txt
- name: Install dependencies
run: |
pip install -e '.[dev]'
- name: Test
run: |
pytest --cov
- uses: codecov/codecov-action@v3
build:
needs: test
strategy:
fail-fast: false
matrix:
runs-on:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: $\{\{matrix.runs-on\}\}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: $\{\{env.python-version\}\}
cache: $\{\{env.cache\}\}
cache-dependency-path: |-
requirements.txt
requirements/dev.txt
- name: Install dependencies
run: |
pip install build
- name: Build
run: |
pyproject-build
- uses: pypa/gh-action-pypi-publish@release/v1
if: runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/')
with:
password: $\{\{secrets.PYPI_API_TOKEN\}\}
- uses: actions/upload-artifact@v3
if: runner.os == 'Linux' && ! startsWith(github.ref, 'refs/tags/')
with:
path: |
dist/*
- uses: softprops/action-gh-release@v1
if: runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/')
with:
# body_path: build/CHANGELOG.md
files: |
dist/*
deploy-aur:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: {{ user }}/[email protected]
with:
package_name: {{ project }}
ssh_private_key: $\{\{secrets.AUR_SSH_PRIVATE_KEY\}\}

deploy-nur:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Trigger Workflow
run: >
curl -X POST -d '{"ref": "main"}'
-H "Accept: application/vnd.github.v3+json"
-H "Authorization: Bearer $\{\{secrets.GH_TOKEN\}\}"
https://api.github.com/repos/{{ user }}/nur-packages/actions/workflows/version.yml/dispatches
134 changes: 134 additions & 0 deletions template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/result
_version.py
_metainfo.py

# create by https://github.com/iamcco/coc-gitignore (Sat Jun 17 2023 19:59:16 GMT+0800 (China Standard Time))
# pydev.gitignore:
.pydevproject

# create by https://github.com/iamcco/coc-gitignore (Sat Jun 17 2023 19:59:20 GMT+0800 (China Standard Time))
# Python.gitignore:
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
5 changes: 5 additions & 0 deletions template/.gitlint
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env -S gitlint -C
[ignore-by-title]
regex=.*
ignore=body-is-missing
# ex: filetype=dosini
89 changes: 89 additions & 0 deletions template/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
exclude: ^templates/.*|.*\.json$

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: fix-byte-order-marker
- id: check-case-conflict
- id: check-shebang-scripts-are-executable
- id: check-merge-conflict
- id: trailing-whitespace
- id: mixed-line-ending
- id: end-of-file-fixer
- id: detect-private-key
- id: check-symlinks
- id: check-ast
- id: debug-statements
- id: requirements-txt-fixer
- id: check-xml
- id: check-yaml
- id: check-toml
- id: check-json
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: remove-crlf
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/jorisroovers/gitlint
rev: v0.19.1
hooks:
- id: gitlint
args:
- --msg-filename
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 2.7.3
hooks:
- id: editorconfig-checker
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: check-mailmap
- repo: https://github.com/rhysd/actionlint
rev: v1.6.26
hooks:
- id: actionlint
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
additional_dependencies:
- mdformat-pyproject
- mdformat-gfm
- mdformat-myst
- mdformat-toc
- mdformat-deflist
- mdformat-beautysh
- mdformat-ruff
- mdformat-config
- mdformat-web
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.12.1
hooks:
- id: markdownlint-cli2
additional_dependencies:
- markdown-it-texmath
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/kumaraditya303/mirrors-pyright
rev: v1.1.350
hooks:
- id: pyright

ci:
skip:
- pyright
Loading

0 comments on commit 4e89247

Please sign in to comment.