Initial commit
This commit is contained in:
commit
b1a1a6866d
13
.coveragerc
Normal file
13
.coveragerc
Normal file
@ -0,0 +1,13 @@
|
||||
[run]
|
||||
branch = True
|
||||
source =
|
||||
|
||||
[report]
|
||||
exclude_lines =
|
||||
if self.debug:
|
||||
pragma: no cover
|
||||
raise NotImplementedError
|
||||
if __name__ == .__main__.:
|
||||
ignore_errors = True
|
||||
omit =
|
||||
tests/*
|
34
.flake8
Normal file
34
.flake8
Normal file
@ -0,0 +1,34 @@
|
||||
[flake8]
|
||||
ignore = BLK100
|
||||
|
||||
# flake8-quotes:
|
||||
# Use double quotes as our default to comply with black, we like it and
|
||||
# don't want to use single quotes anymore.
|
||||
# We would love to configure this via our pyproject.toml but flake8-3.8 does
|
||||
# not support it yet.
|
||||
inline-quotes = double
|
||||
multiline-quotes = double
|
||||
docstring-quotes = double
|
||||
avoid-escape = True
|
||||
|
||||
# flake8-docstrings
|
||||
# Use the Google Python Styleguide Docstring format.
|
||||
docstring-convention=google
|
||||
|
||||
exclude =
|
||||
# No need to traverse our git directory
|
||||
.git,
|
||||
# There's no value in checking cache directories
|
||||
__pycache__,
|
||||
# The conf file is mostly autogenerated, ignore it
|
||||
docs/source/conf.py,
|
||||
# The old directory contains Flake8 2.0
|
||||
old,
|
||||
# This contains our built documentation
|
||||
build,
|
||||
# This contains builds of flake8 that we don't want to check
|
||||
dist,
|
||||
venv,
|
||||
docs
|
||||
|
||||
max-line-length = 120
|
60
.github/workflows/build-exe.yml
vendored
Normal file
60
.github/workflows/build-exe.yml
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
name: Build Executable
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Python Package"]
|
||||
types:
|
||||
- completed
|
||||
branches:
|
||||
- "main"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# Only run if the python-publish workflow succeeded
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target:
|
||||
- os: windows-2022
|
||||
triple: x86_64-pc-windows-msvc
|
||||
- os: ubuntu-22.04
|
||||
triple: x86_64-unknown-linux-gnu
|
||||
- os: macos-12
|
||||
triple: x86_64-apple-darwin
|
||||
runs-on: ${{ matrix.target.os }}
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: olegtarasov/get-tag@v2.1.4
|
||||
id: get_tag_name
|
||||
with:
|
||||
tagRegex: "v(?<version>.*)"
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.10"
|
||||
cache: pip
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install nox
|
||||
|
||||
- name: Build exe
|
||||
run: |
|
||||
nox -s build-exe -- --release --version ${{ steps.get_tag_name.outputs.version }}
|
||||
|
||||
- uses: ncipollo/release-action@v1
|
||||
with:
|
||||
allowUpdates: true
|
||||
updateOnlyUnreleased: false
|
||||
omitBody: true
|
||||
artifacts: ".zip/*.zip"
|
||||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
|
23
.github/workflows/bumpversion.yml
vendored
Normal file
23
.github/workflows/bumpversion.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
name: Bump version
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
bump-version:
|
||||
if: "!startsWith(github.event.head_commit.message, 'bump:')"
|
||||
runs-on: ubuntu-latest
|
||||
name: "Bump version and create changelog with commitizen"
|
||||
steps:
|
||||
- name: Check out
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}'
|
||||
- name: Create bump and changelog
|
||||
uses: commitizen-tools/commitizen-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
|
||||
branch: main
|
34
.github/workflows/codecov.yml
vendored
Normal file
34
.github/workflows/codecov.yml
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
name: Codecov
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
run:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Get repository name
|
||||
id: repo-name
|
||||
uses: MariachiBear/get-repo-name-action@v1.3.0
|
||||
with:
|
||||
with-owner: 'true'
|
||||
string-case: 'uppercase'
|
||||
- name: Set up Python 3.10
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install -r requirements-dev.txt
|
||||
poetry --version
|
||||
- name: Run tests and collect coverage
|
||||
run: |
|
||||
nox -s pytest
|
||||
- name: Upload coverage reports to Codecov
|
||||
uses: codecov/codecov-action@v5
|
||||
with:
|
||||
slug: loonghao/${{ steps.repo-name.outputs.repository-name }}
|
||||
files: 'coverage.xml'
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
18
.github/workflows/issue-translator.yml
vendored
Normal file
18
.github/workflows/issue-translator.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: 'issue-translator'
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
issues:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: usthe/issues-translate-action@v2.7
|
||||
with:
|
||||
IS_MODIFY_TITLE: false
|
||||
# not require, default false, . Decide whether to modify the issue title
|
||||
# if true, the robot account @Issues-translate-bot must have modification permissions, invite @Issues-translate-bot to your project or use your custom bot.
|
||||
CUSTOM_BOT_NOTE: Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
|
||||
# not require. Customize the translation robot prefix message.
|
35
.github/workflows/mr-test.yml
vendored
Normal file
35
.github/workflows/mr-test.yml
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
name: MR Checks
|
||||
on: [ pull_request ]
|
||||
|
||||
jobs:
|
||||
python-check:
|
||||
strategy:
|
||||
max-parallel: 3
|
||||
matrix:
|
||||
target:
|
||||
- os: 'ubuntu-22.04'
|
||||
triple: 'x86_64-unknown-linux-gnu'
|
||||
- os: 'macos-12'
|
||||
triple: 'x86_64-apple-darwin'
|
||||
- os: 'windows-2022'
|
||||
triple: 'x86_64-pc-windows-msvc'
|
||||
python-version: ["3.10"]
|
||||
fail-fast: false
|
||||
runs-on: ${{ matrix.target.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install -r requirements-dev.txt
|
||||
poetry --version
|
||||
- name: lint
|
||||
run: |
|
||||
nox -s lint
|
||||
- name: test build
|
||||
run: |
|
||||
nox -s build-exe -- --test
|
66
.github/workflows/python-publish.yml
vendored
Normal file
66
.github/workflows/python-publish.yml
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
name: Upload Python Package
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# IMPORTANT: this permission is mandatory for trusted publishing
|
||||
id-token: write
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||
with:
|
||||
token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
fetch-depth: 0
|
||||
ref: main
|
||||
- uses: olegtarasov/get-tag@v2.1.4
|
||||
id: get_tag_name
|
||||
with:
|
||||
tagRegex: "v(?<version>.*)"
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install -r requirements-dev.txt
|
||||
poetry --version
|
||||
poetry build
|
||||
# Note that we don't need credentials.
|
||||
# We rely on https://docs.pypi.org/trusted-publishers/.
|
||||
- name: Upload to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
with:
|
||||
packages-dir: dist
|
||||
- name: Generate changelog
|
||||
id: changelog
|
||||
uses: jaywcjlove/changelog-generator@main
|
||||
with:
|
||||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
|
||||
filter-author: (|dependabot|renovate\\[bot\\]|dependabot\\[bot\\]|Renovate Bot)
|
||||
filter: '[R|r]elease[d]\s+[v|V]\d(\.\d+){0,2}'
|
||||
template: |
|
||||
## Bugs
|
||||
{{fix}}
|
||||
## Feature
|
||||
{{feat}}
|
||||
## Improve
|
||||
{{refactor,perf,clean}}
|
||||
## Misc
|
||||
{{chore,style,ci||🔶 Nothing change}}
|
||||
## Unknown
|
||||
{{__unknown__}}
|
||||
- uses: ncipollo/release-action@v1
|
||||
with:
|
||||
artifacts: "dist/*"
|
||||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
|
||||
body: |
|
||||
Comparing Changes: ${{ steps.changelog.outputs.compareurl }}
|
||||
|
||||
${{ steps.changelog.outputs.changelog }}
|
22
.gitignore
vendored
Normal file
22
.gitignore
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
*.py[cod]
|
||||
|
||||
# PyCharm project files
|
||||
.idea/
|
||||
|
||||
# Vim / Notepad++ temp files
|
||||
*~
|
||||
|
||||
# Coverage output
|
||||
.coverage
|
||||
|
||||
# Documentation build folders.
|
||||
docs/_*
|
||||
docs/src/*
|
||||
target/*
|
||||
/venv/
|
||||
/run_pycharm.bat
|
||||
/.nox/
|
||||
/build/
|
||||
/coverage.xml
|
||||
/.zip/
|
8
.hound.yml
Normal file
8
.hound.yml
Normal file
@ -0,0 +1,8 @@
|
||||
python:
|
||||
enabled: true
|
||||
|
||||
flake8:
|
||||
enabled: true
|
||||
config_file: .flake8
|
||||
|
||||
fail_on_violations: true
|
12
.pre-commit-config.yaml
Normal file
12
.pre-commit-config.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
default_language_version:
|
||||
python: python3.10
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.3.0
|
||||
hooks:
|
||||
- id: no-commit-to-branch # prevent direct commits to main branch
|
||||
- id: check-yaml
|
||||
args: ["--unsafe"]
|
||||
- id: check-toml
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
7
.pylintrc
Normal file
7
.pylintrc
Normal file
@ -0,0 +1,7 @@
|
||||
# Generated Pylint configuration file that disables default output tables.
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
disable=RP0001,RP0002,RP0003,RP0101,RP0401,RP0402,RP0701,RP0801,C0103,R0903
|
||||
|
||||
[REPORTS]
|
||||
output-format=text
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Hal
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
2
README.md
Normal file
2
README.md
Normal file
@ -0,0 +1,2 @@
|
||||
# repo-template
|
||||
This is a boilerplate git repository for creating new project
|
9
codecov.yml
Normal file
9
codecov.yml
Normal file
@ -0,0 +1,9 @@
|
||||
coverage:
|
||||
status:
|
||||
project: off
|
||||
|
||||
github_checks:
|
||||
annotations: false
|
||||
|
||||
ignore:
|
||||
- "noxfile.py"
|
0
nox_actions/__init__.py
Normal file
0
nox_actions/__init__.py
Normal file
17
nox_actions/codetest.py
Normal file
17
nox_actions/codetest.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Import built-in modules
|
||||
import os
|
||||
|
||||
# Import third-party modules
|
||||
import nox
|
||||
from nox_actions.utils import PACKAGE_NAME
|
||||
from nox_actions.utils import THIS_ROOT
|
||||
|
||||
|
||||
def pytest(session: nox.Session) -> None:
|
||||
session.install(".")
|
||||
session.install("pytest", "pytest_cov", "pytest_mock")
|
||||
test_root = os.path.join(THIS_ROOT, "tests")
|
||||
session.run("pytest", f"--cov={PACKAGE_NAME}",
|
||||
"--cov-report=xml:coverage.xml",
|
||||
f"--rootdir={test_root}",
|
||||
env={"PYTHONPATH": THIS_ROOT.as_posix()})
|
17
nox_actions/lint.py
Normal file
17
nox_actions/lint.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Import third-party modules
|
||||
import nox
|
||||
from nox_actions.utils import PACKAGE_NAME
|
||||
|
||||
|
||||
def lint(session: nox.Session) -> None:
|
||||
session.install("isort", "ruff")
|
||||
session.run("isort", "--check-only", PACKAGE_NAME)
|
||||
session.run("ruff", "check")
|
||||
|
||||
|
||||
def lint_fix(session: nox.Session) -> None:
|
||||
session.install("isort", "ruff", "pre-commit", "autoflake")
|
||||
session.run("ruff", "check", "--fix")
|
||||
session.run("isort", ".")
|
||||
session.run("pre-commit", "run", "--all-files")
|
||||
session.run("autoflake", "--in-place", "--remove-all-unused-imports", "--remove-unused-variables")
|
45
nox_actions/release.py
Normal file
45
nox_actions/release.py
Normal file
@ -0,0 +1,45 @@
|
||||
# Import built-in modules
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import zipfile
|
||||
|
||||
# Import third-party modules
|
||||
import nox
|
||||
from nox_actions.utils import PACKAGE_NAME
|
||||
from nox_actions.utils import THIS_ROOT
|
||||
|
||||
|
||||
@nox.session(name="build-exe", reuse_venv=True)
|
||||
def build_exe(session: nox.Session) -> None:
|
||||
parser = argparse.ArgumentParser(prog="nox -s build-exe --release")
|
||||
parser.add_argument("--release", action="store_true")
|
||||
parser.add_argument("--version", default="0.5.0", help="Version to use for the zip file")
|
||||
parser.add_argument("--test", action="store_true")
|
||||
args = parser.parse_args(session.posargs)
|
||||
build_root = THIS_ROOT / "build"
|
||||
session.install("pyoxidizer")
|
||||
session.run("pyoxidizer", "build", "install", "--path", THIS_ROOT, "--release")
|
||||
for platform_name in os.listdir(build_root):
|
||||
platform_dir = build_root / platform_name / "release" / "install"
|
||||
print(os.listdir(platform_dir))
|
||||
print(f"build {platform_name} -> {platform_dir}")
|
||||
|
||||
if args.test:
|
||||
print("run tests")
|
||||
vexcle_exe = shutil.which("vexcle", path=platform_dir)
|
||||
assert os.path.exists(vexcle_exe)
|
||||
|
||||
if args.release:
|
||||
temp_dir = os.path.join(THIS_ROOT, ".zip")
|
||||
version = str(args.version)
|
||||
print(f"make zip to current version: {version}")
|
||||
os.makedirs(temp_dir, exist_ok=True)
|
||||
zip_file = os.path.join(temp_dir, f"{PACKAGE_NAME}-{version}-{platform_name}.zip")
|
||||
with zipfile.ZipFile(zip_file, "w") as zip_obj:
|
||||
for root, _, files in os.walk(platform_dir):
|
||||
for file in files:
|
||||
zip_obj.write(os.path.join(root, file),
|
||||
os.path.relpath(os.path.join(root, file),
|
||||
os.path.join(platform_dir, ".")))
|
||||
print("Saving to {zipfile}".format(zipfile=zip_file))
|
19
nox_actions/utils.py
Normal file
19
nox_actions/utils.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Import built-in modules
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
PACKAGE_NAME = ""
|
||||
THIS_ROOT = Path(__file__).parent.parent
|
||||
PROJECT_ROOT = THIS_ROOT.parent
|
||||
|
||||
|
||||
def _assemble_env_paths(*paths):
|
||||
"""Assemble environment paths separated by a semicolon.
|
||||
|
||||
Args:
|
||||
*paths: Paths to be assembled.
|
||||
|
||||
Returns:
|
||||
str: Assembled paths separated by a semicolon.
|
||||
"""
|
||||
return ";".join(paths)
|
24
noxfile.py
Normal file
24
noxfile.py
Normal file
@ -0,0 +1,24 @@
|
||||
# Import built-in modules
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Import third-party modules
|
||||
import nox
|
||||
|
||||
|
||||
ROOT = os.path.dirname(__file__)
|
||||
|
||||
# Ensure maya_umbrella is importable.
|
||||
if ROOT not in sys.path:
|
||||
sys.path.append(ROOT)
|
||||
|
||||
# Import third-party modules
|
||||
from nox_actions import codetest # noqa: E402
|
||||
from nox_actions import lint # noqa: E402
|
||||
from nox_actions import release # noqa: E402
|
||||
|
||||
|
||||
nox.session(lint.lint, name="lint")
|
||||
nox.session(lint.lint_fix, name="lint-fix")
|
||||
nox.session(codetest.pytest, name="pytest")
|
||||
nox.session(release.build_exe, name="build-exe")
|
6
renovate.json
Normal file
6
renovate.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:recommended"
|
||||
]
|
||||
}
|
3
requirements-dev.txt
Normal file
3
requirements-dev.txt
Normal file
@ -0,0 +1,3 @@
|
||||
poetry
|
||||
nox
|
||||
pytest
|
Loading…
x
Reference in New Issue
Block a user