Skip to content

Commit

Permalink
ci(pre-commit): update pre-commit config to latest Espressif standard
Browse files Browse the repository at this point in the history
- ci(pre-commit): remove Hadolint hook, no Dockerfile  in the project now
- ci(dependabot): add dependabot configuration
- ci(changelog): update commitizen for czespressif plugin, new changelog
- ci(pre-commit): add config for yamlfix, fixes failed pre-commit ci
- ci(codeowners): add CODEOWNERS file, dependabot, clean GH workflows
- ci: clean pyproject.toml, Justfile, update ref action.yml
  • Loading branch information
tomassebestik committed Sep 13, 2024
1 parent 385fb14 commit 59b01fd
Show file tree
Hide file tree
Showing 12 changed files with 282 additions and 179 deletions.
26 changes: 26 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.

# More details are here: https://help.github.com/articles/about-codeowners/

# The '*' pattern is global owners.

# Order is important. The last matching pattern has the most precedence.
# The folders are ordered as follows:

# In each subsection folders are ordered first by depth, then alphabetically.
# This should make it easy to add new rules without breaking existing ones.

# TIP: syntax formatting in VS Code; extension "vscode-codeowners"

#------------------------------------------------------------------------------------------------------------------------

# Global rule:
# * @espressif

# Code owners for the entire repository
/.github @espressif/ci


.pre-commit-config.yaml @espressif/ci
CONTRIBUTING.md @espressif/ci
32 changes: 32 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
version: 2

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

- package-ecosystem: "npm"
versioning-strategy: increase-if-necessary
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
commit-message:
prefix: "ci(dependabot-npm): "
reviewers: ["espressif/ci"]

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
commit-message:
prefix: "ci(dependabot-actions): "
reviewers: ["espressif/ci"]
24 changes: 13 additions & 11 deletions .github/workflows/dangerjs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
name: DangerJS Pull Request linter

on:
pull_request_target:
types: [opened, edited, reopened, synchronize]
Expand All @@ -8,17 +10,17 @@ permissions:
contents: write

jobs:
pull-request-style-linter:
dangerjs:
runs-on: ubuntu-latest
steps:
- name: Check out PR head
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- 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'
- 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: 14 additions & 6 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
---
name: Check pre-commit

on:
pull_request:

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

- name: Set up Python
uses: actions/setup-python@v5
with:
fetch-depth: 0
- uses: actions/setup-python@v5
- uses: pre-commit/[email protected]
python-version: '3.9'

- name: Run pre-commit
uses: pre-commit/[email protected]
env:
SKIP: pip-compile
SKIP: pip-compile,update-changelog
31 changes: 17 additions & 14 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
name: Tests
---
name: Tests codebase

on:
pull_request:

jobs:
pytest:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov
pip install -r requirements.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov
pip install -r requirements.txt
- name: Run pytest with coverage
run: |
python -m pytest
- name: Run pytest with coverage
run: |-
python -m pytest
72 changes: 46 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,62 +1,82 @@
# Run `pre-commit autoupdate` to update to the latest pre-commit hooks version.
# When changing the version of tools that are also installed as development dependencies (e.g., black, mypy, ruff),
# please ensure the same versions are pinned in this file as in `pyproject.toml`.
---
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: [pre-commit]

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

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
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-executables-have-shebangs # Checks executables have a proper shebang
- 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
- id: double-quote-string-fixer # Converts single quotes to double quotes in strings

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.6.4
hooks:
- id: ruff # Runs ruff linter (replaces flake8)
- id: ruff # Linter
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/asottile/reorder_python_imports
rev: v3.12.0
hooks:
- id: reorder-python-imports # Reorders Python imports to a standard format (replaces isort)
- id: ruff-format # Formatter (replaces Black)

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.11.2
hooks:
- id: mypy # Runs mypy for Python type checking
additional_dependencies: ['types-all']

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

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

- repo: https://github.com/psf/black
rev: '24.1.1'
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: black # Formats Python code using black
- id: codespell # Code spell checker
args: ['--write-changes']
additional_dependencies: [tomli]

- repo: https://github.com/pylint-dev/pylint
rev: v3.0.3
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: pylint # Runs pylint on Python code
- 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/codespell-project/codespell
rev: v2.2.6
- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: codespell # Code spell checker
args: ["--write-changes"]
additional_dependencies: [tomli]
- 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

- repo: https://github.com/espressif/cz-plugin-espressif
rev: 'v1.0.1'
hooks:
- id: update-changelog

# Local hooks
- repo: local
Expand Down
29 changes: 17 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,25 @@

## v0.1.1 (2024-02-14)

### 📖 Documentation

- add CONTRIBUTING guide, update README *(Tomas Sebestik - b82419e)*

### 🔧 Code refactoring

- docs: add CONTRIBUTING guide, update README
- ci(project-structure): package and tools config by pyproject.toml
- - add commitizen support to pyproject.toml
- add Danger for GitHub
- add pre-commit hook for codespell
- add pre-commit hook prettier - formatting Markdown files
- add pre-commit workflow to CI
- refactor: refactor to Python 3.11, refactor Dockerfile (Bookworm, node20)
- - refactor(tests): add tests and GH workflow for pytest
- refactor: move source code to src directory
- refactor to Python 3.11, refactor Dockerfile (Bookworm, node20) *(Tomas Sebestik - c26938e)*

---

## v0.1.0 (2024-02-07)

### ✨ New features

- **init**: original code from github-actions repo *(Tomas Sebestik - 36ac8e0)*

---

**[Espressif Systems CO LTD. (2024)](https://www.espressif.com/)**

- feat(init): original code from github-actions repo
- Init
- [Commitizen tools plugin with Espressif code style](https://www.github.com/espressif/cz-plugin-espressif)
- [Espressif Coding Standards and Best Practices](https://www.github.com/espressif/standards)
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ We welcome contributions! To contribute to this repository, please read these in
```

- Install the project and development dependencies:

```sh
pip install -e '.[dev]'
```
Expand Down
27 changes: 27 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
set quiet := true

[private]
default:
just --choose --unsorted

clean:
rm -rf \
dist \
.pytest_cache \
.mypy_cache \
.coverage \
.coverage.* \
.ruff_cache \
*.egg-info \
:

pidev:
pip install -e '.[dev]'
pip install --upgrade pip

checkall:
pre-commit run --all-files

rebase:
git fetch --all
git rebase -i origin/v1
Loading

0 comments on commit 59b01fd

Please sign in to comment.