Skip to content

Commit

Permalink
feat: init commit, project basic structure (from template commitizen)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomassebestik committed Sep 7, 2024
0 parents commit 61c03ec
Show file tree
Hide file tree
Showing 19 changed files with 844 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Code owners for the entire repository
* @tomassebestik @kumekay

# Code owners for individual files
Justfile @tomassebestik

# Code owners for an entire directory and its subdirectories
.github/ISSUE_TEMPLATE/ @tomassebestik
.github/PULL_REQUEST_TEMPLATE @tomassebestik
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
version: 2

updates:
- package-ecosystem: "pip"
versioning-strategy: increase-if-necessary
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
commit-message:
prefix: "ci(dependabot-pip): "
assignees: ["tomassebestik"]

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
prefix: "ci(dependabot-actions): "
assignees: ["tomassebestik"]
25 changes: 25 additions & 0 deletions .github/workflows/dangerjs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: DangerJS Pull Request linter

on:
pull_request_target:
types: [opened, edited, reopened, synchronize]

jobs:
pull-request-style-linter:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Check out PR head
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: DangerJS pull request linter
uses: espressif/shared-github-dangerjs@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
instructions-contributions-file: 'CONTRIBUTING.md'
20 changes: 20 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Check pre-commit

on:
pull_request:

jobs:
check-pre-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5

- name: Run pre-commit
uses: pre-commit/[email protected]
env:
SKIP: pip-compile
41 changes: 41 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
# This workflow will upload a Python Package using Twine when a release is created.
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: PyPI release

on:
release:
types: [created]
workflow_dispatch:

jobs:
pypi-build-publish:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |-
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: |-
python -m build
- name: Upload package to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PROJECT_TOKEN }}
run: |-
twine upload dist/*
41 changes: 41 additions & 0 deletions .github/workflows/sync-jira.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
# This GitHub Actions workflow synchronizes GitHub issues, comments, and pull requests with Jira.
# It triggers on new issues, issue comments, and on a scheduled basis.
# The workflow uses a custom action to perform the synchronization with Jira (espressif/sync-jira-actions).

name: Sync to Espressif Jira
run-name: >
Sync to Jira -
${{ github.event_name == 'issue_comment' && 'Issue Comments' ||
github.event_name == 'schedule' && 'New Pull Requests' ||
github.event_name == 'issues' && 'New Issues' }}
on:
issues: {types: [opened]}
issue_comment: {types: [created, edited, deleted]}
schedule: [cron: '0 * * * *']

jobs:
sync-to-jira:
name: >
Sync to Jira -
${{ github.event_name == 'issue_comment' && 'Issue Comments' ||
github.event_name == 'schedule' && 'New Pull Requests' ||
github.event_name == 'issues' && 'New Issues' }}
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Run synchronization to Jira
uses: espressif/sync-jira-actions@change/composite-action
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JIRA_PASS: ${{ secrets.JIRA_PASS }}
JIRA_URL: ${{ secrets.JIRA_URL }}
JIRA_USER: ${{ secrets.JIRA_USER }}
JIRA_PROJECT: RDT
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.mypy_cache/
/.coverage
/.coverage.*
/.nox/
/.python-version
/.pytype/
/dist/
/docs/_build/
*.egg-info/
__pycache__/
83 changes: 83 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
# Run `pre-commit autoupdate` to update to the latest pre-commit hooks version.
minimum_pre_commit_version: 3.3.0 # Specifies the minimum version of pre-commit required for this configuration
default_install_hook_types: [pre-commit, commit-msg] # Default hook types to install if not specified in individual hooks
default_stages: [commit]

repos:
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace # Removes trailing whitespaces from lines
- id: end-of-file-fixer # Ensures files end with a newline
- id: check-shebang-scripts-are-executable # Checks that scripts with shebangs are executable.
- id: check-case-conflict # Check conflict on a case-insensitive filesystem (MacOS HFS+/Windows FAT).
- id: mixed-line-ending # Detects mixed line endings (CRLF/LF)
args: ["-f=lf"] # Forces files to use LF line endings

- repo: https://github.com/pylint-dev/pylint
rev: v3.2.6
hooks:
- id: pylint # Runs pylint on Python code

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.3
hooks:
- id: ruff # Linter
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format # Formatter (replaces Black)

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
hooks:
- id: mypy # Runs mypy for Python type checking

- repo: https://github.com/espressif/conventional-precommit-linter
rev: v1.10.0
hooks:
- id: conventional-precommit-linter # Lints commit messages for conventional format

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell # Code spell checker
args: ["--write-changes"]
additional_dependencies: [tomli]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
args: [--number] # Keep numbering for ordered lists
additional_dependencies:
- mdformat-gfm # Support for GitHub Flavored Markdown (GFM), including tables, task lists, strikethroughs, and autolinks.
- mdformat-ruff # Formats Python code blocks in Markdown files according to the `ruff` linter's style.
- mdformat-simple-breaks # Ensures that single line breaks in Markdown are converted to `<br>` t

- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
args:
- --base64-limit=4 # Level of entropy for base64 type strings
- --hex-limit=3 # Level of entropy for hex strings

- repo: https://github.com/lyz-code/yamlfix/
rev: 1.17.0
hooks:
- id: yamlfix

# Local hooks
- repo: local
hooks:
- id: pip-compile # Generate locked requirements.txt for production (Dockerfile)
name: compile requirements.txt
entry: bash -c 'pip-compile --strip-extras --output-file=requirements.txt pyproject.toml > /dev/null'
language: system
pass_filenames: false
files: requirements.txt|pyproject.toml
67 changes: 67 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Contributing and Development

We welcome contributions! To contribute to this repository, please follow these steps:

## Code and Testing

- **Code Style and Structure:**

- **Pre-Commit Hooks:** Install pre-commit hooks in this repository using the `pre-commit install` command.

- **Readable Code Structure:** Structure your code in a readable manner. The main logic should be in the default rule function, with implementation details in helper functions. Avoid nested `if` statements and unnecessary `else` statements to maintain code clarity and simplicity.

- **Remove Debug Statements:** Remove any development debug statements from your files.

- **Automated Tests:** We aim for full test coverage, so **partial tests will not be accepted**. The tests should cover all typical usage scenarios as well as edge cases to ensure robustness.

- **Testing Tool:** It is recommended to run `pytest` frequently during development to ensure that all aspects of your code are functioning as expected.

## Documentation and Maintenance

- **Changelog:** `CHANGELOG.md` is generated automatically by `commitizen` from commit messages. Not need to update `CHANGELOG.md` manually. Focus on informative and clear commit messages which end in the release notes.

- **Documentation:** Regularly check and update the documentation to keep it current.

- **PR/MR Descriptions and Documentation:** When making contributions, clearly describe any changes or new features in both the PR (Pull Request on GitHub) or MR (Merge Request on GitLab) description and the project documentation. If you're modifying the output style, please include a thumbnail of the new style.

## Development and Local Testing

1. **Clone the Project**

- Clone the repository to your local machine using:

```sh
git clone <project_clone_url>
```

2. **Set Up Development Environment:**

- Create and activate a virtual environment:

```sh
python -m venv venv && source ./venv/bin/activate
```

or:

```sh
virtualenv venv && source ./venv/bin/activate
```

- Install the project and development dependencies:

```sh
pip install -e '.[dev]'
```

3. **Testing Your Changes:**

- Before submitting a pull request, ensure your changes pass all the tests. You can run the test suite with the following command:

```sh
pytest
```

---

👏**Thank you for your contributions.**
59 changes: 59 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
set quiet := true
set shell := ["bash", "-c"]
set positional-arguments := true

# Private default task
[private]
default:
just --choose --unsorted

# Gracefully exit just chooser
exit:
exit 0

# Activate virtual environment
activate-venv:
if [ -d "venv" ]; then source venv/bin/activate; else echo "Virtual environment not found. Please create it first."; fi

# Reinstall development dependencies in virtual environment
reinstall-venv:
just activate-venv && pip install -e '.[dev]'

# Clean temporary and cache files
clean-temps:
rm -rf .mypy_cache/ .ruff_cache/ cz_plugin_espressif/cz_plugin_espressif.egg-info

# Set up the environment: activate and reinstall
setup-env:
just activate-venv && just reinstall-venv

# List outdated Python packages
pip-list-outdated:
just activate-venv && pip list --outdated

# List Python packages excluding editable
pip-list-exlude-editable:
just activate-venv && pip list --exclude-editable

pip-list-search-installed PACKAGE:
just activate-venv && pip list --format=columns | grep '{{PACKAGE}}'

# Run pre-commit checks
pre-commit-all-files:
just activate-venv && pre-commit run --all-files

# Run pre-commit checks on staged files
pre-commit-staged:
just activate-venv && pre-commit run

# Run pre-commit checks and specify files
pre-commit-files FILES:
just activate-venv && pre-commit run --files {{FILES}}

# Autoupdate pre-commit hooks
pre-commit-autoupdate:
just activate-venv && pre-commit autoupdate

# Reuse the last commit message, opening it in the editor for modification
git-fix-message:
git commit --edit --file=$(git rev-parse --git-dir)/COMMIT_EDITMSG
Loading

0 comments on commit 61c03ec

Please sign in to comment.