Skip to content

Commit

Permalink
Configure and format the project
Browse files Browse the repository at this point in the history
  • Loading branch information
haiiliin committed Sep 19, 2024
1 parent 200b278 commit dd5baca
Show file tree
Hide file tree
Showing 37 changed files with 267 additions and 173 deletions.
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
version: 2
updates:

# Dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
Expand Down
54 changes: 27 additions & 27 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
# .github/release-drafter.yml

name-template: 'v$RESOLVED_VERSION 🌈'
tag-template: 'v$RESOLVED_VERSION'
name-template: "v$RESOLVED_VERSION 🌈"
tag-template: "v$RESOLVED_VERSION"
filter-by-commitish: true
commitish: main
categories:
- title: '🚀 New Features'
- title: "🚀 New Features"
labels:
- 'feature'
- 'new feature'
- 'enhancement'
- 'customization'
- title: '🐛 Bug Fixes'
- "feature"
- "new feature"
- "enhancement"
- "customization"
- title: "🐛 Bug Fixes"
labels:
- 'fix'
- 'bugfix'
- 'bug'
- 'test'
- 'typo'
- 'refactor'
- title: '📝 Documentation'
- "fix"
- "bugfix"
- "bug"
- "test"
- "typo"
- "refactor"
- title: "📝 Documentation"
labels:
- 'documentation'
- 'docs'
- 'doc'
- title: '🤖 Automation'
- "documentation"
- "docs"
- "doc"
- title: "🤖 Automation"
labels:
- 'automation'
- 'release'
- 'workflow'
version-template: '$MAJOR.$MINOR.$PATCH'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
- "automation"
- "release"
- "workflow"
version-template: "$MAJOR.$MINOR.$PATCH"
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
- "major"
minor:
labels:
- 'minor'
- "minor"
patch:
labels:
- 'patch'
- "patch"
default: patch
template: |
## Changes
Expand Down
48 changes: 21 additions & 27 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,34 @@ name: docs-test
on:
push:
branches:
- main
- main
paths:
- 'SSI/**'
- 'docs/source/**'
- '.github/workflows/pages.yml'
- "svgdatagrabber/**"
- "docs/source/**"
- ".github/workflows/pages.yml"
pull_request:
branches:
- main
- main
paths:
- 'SSI/**'
- 'docs/source/**'
- '.github/workflows/pages.yml'
- "svgdatagrabber/**"
- "docs/source/**"
- ".github/workflows/pages.yml"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
concurrency: pages_staging_environment
strategy:
matrix:
python-version: ['3.10']
steps:
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Installing the library
shell: bash -l {0}
run: |
pip install -r docs/requirements.txt
pip install .
- name: Build and Commit
uses: sphinx-notes/pages@v2
with:
documentation_path: docs
- uses: actions/setup-python@v4
with:
python-version: "3.12"
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Installing the library
run: |
pip install -e .[docs]
- name: Build and Commit
uses: sphinx-notes/pages@v2
with:
documentation_path: docs
32 changes: 16 additions & 16 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
31 changes: 14 additions & 17 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ name: pytest
on:
push:
branches:
- main
- main
paths:
- 'svgdatagrabber/**'
- 'tests/**'
- '.github/workflows/pytest.yaml'
- "svgdatagrabber/**"
- "tests/**"
- ".github/workflows/pytest.yaml"
pull_request:
types: [opened, reopened, synchronize]
paths:
- 'svgdatagrabber/**'
- 'tests/**'
- '.github/workflows/pytest.yaml'
- "svgdatagrabber/**"
- "tests/**"
- ".github/workflows/pytest.yaml"
workflow_dispatch:

jobs:
Expand All @@ -22,7 +22,12 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
Expand All @@ -33,15 +38,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov
pip install -r requirements.txt
pip install -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
pip install -e .[dev]
- name: Test with pytest
run: |
pytest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Release Drafter
on:
push:
branches: [ "main" ]
branches: ["main"]
# pull_request event is required only for autolabeler
pull_request:
# Only following types are handled by the action, but one can default to all as well
Expand Down
49 changes: 49 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
repos:
- repo: https://github.com/psf/black
rev: "24.2.0"
hooks:
- id: black
args:
- --line-length=120
- --include='(micromechanical/.*\.pyi?|tests/.*\.py|docs/conf\.py)'

- repo: https://github.com/pycqa/isort
rev: "5.13.2"
hooks:
- id: isort
args:
- --profile=black
- id: isort
name: isort (pyi)
types: [pyi]
args:
- --profile=black
- --line-length=120

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.3.2"
hooks:
- id: ruff

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.5.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-yaml
args:
- --allow-multiple-documents
- id: debug-statements
- id: name-tests-test
args:
- --pytest-test-first
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
hooks:
- id: prettier
additional_dependencies:
- [email protected]
3 changes: 2 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ sphinx:
formats: []
python:
install:
- requirements: docs/requirements.txt
- method: pip
path: .
extra:
- docs
34 changes: 17 additions & 17 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,41 @@
import os
import sys

project = 'SvgDataGrabber'
copyright = '2022, WANG Hailin'
author = 'WANG Hailin'
project = "SvgDataGrabber"
copyright = "2022, WANG Hailin"
author = "WANG Hailin"

try:
import svgdatagrabber

release = version = svgdatagrabber.__version__.split('+')[0]
release = version = svgdatagrabber.__version__.split("+")[0]
except (ImportError, AttributeError):
import warnings

warnings.warn('svgdatagrabber is not installed, using 0.0.1')
release = version = '0.0.1'
sys.path.insert(0, os.path.abspath('..'))
warnings.warn("svgdatagrabber is not installed, using 0.0.1")
release = version = "0.0.1"
sys.path.insert(0, os.path.abspath(".."))

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
'autoapi.extension',
'myst_parser',
'nbsphinx',
'sphinx.ext.autodoc',
'sphinx_copybutton',
"autoapi.extension",
"myst_parser",
"nbsphinx",
"sphinx.ext.autodoc",
"sphinx_copybutton",
]

# AutoAPI configuration
autoapi_dirs = ['../svgdatagrabber']
autoapi_dirs = ["../svgdatagrabber"]

# Templates
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'furo'
html_static_path = ['_static']
html_theme = "furo"
html_static_path = ["_static"]
5 changes: 0 additions & 5 deletions docs/requirements.txt

This file was deleted.

Loading

0 comments on commit dd5baca

Please sign in to comment.