forked from NabuCasa/universal-silabs-flasher
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to zigpy CI and pre-commit hooks (NabuCasa#53)
* Migrate to zigpy CI * Migrate to zigpy pre-commit config * Fix existing formatting * Move workflows into the correct folder * Fix CI for 3.8
- Loading branch information
Showing
12 changed files
with
151 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,172 +1,16 @@ | ||
name: CI | ||
|
||
# yamllint disable-line rule:truthy | ||
on: | ||
push: | ||
pull_request: ~ | ||
|
||
env: | ||
CACHE_VERSION: 1 | ||
DEFAULT_PYTHON: 3.9.15 | ||
PRE_COMMIT_HOME: ~/.cache/pre-commit | ||
PYTHON_MODULE_NAME: universal_silabs_flasher | ||
|
||
jobs: | ||
prepare-base: | ||
name: Prepare base dependencies | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code from GitHub | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | ||
id: python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.DEFAULT_PYTHON }} | ||
|
||
- name: Restore base Python virtual environment | ||
id: cache-venv | ||
uses: actions/cache@v3 | ||
with: | ||
path: venv | ||
key: | | ||
base-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml') }} | ||
- name: Create Python virtual environment | ||
if: steps.cache-venv.outputs.cache-hit != 'true' | ||
run: | | ||
python -m venv venv | ||
. venv/bin/activate | ||
pip install -U pip wheel setuptools pre-commit | ||
pip install -e '.[testing]' | ||
pre-commit: | ||
name: Run pre-commit | ||
runs-on: ubuntu-latest | ||
needs: prepare-base | ||
steps: | ||
- name: Check out code from GitHub | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | ||
id: python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.DEFAULT_PYTHON }} | ||
|
||
- name: Restore base Python virtual environment | ||
id: cache-venv | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ env.PRE_COMMIT_HOME }} | ||
key: | | ||
base-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }} | ||
- name: Create Python virtual environment | ||
if: steps.cache-venv.outputs.cache-hit != 'true' | ||
run: | | ||
python -m venv venv | ||
. venv/bin/activate | ||
pip install -U pip wheel setuptools pre-commit | ||
pip install -e '.[testing]' | ||
- name: Install pre-commit dependencies | ||
if: steps.cache-precommit.outputs.cache-hit != 'true' | ||
run: | | ||
. venv/bin/activate | ||
pre-commit install-hooks | ||
- name: Run pre-commit | ||
run: | | ||
. venv/bin/activate | ||
pre-commit run --show-diff-on-failure --color=always | ||
pytest: | ||
runs-on: ubuntu-latest | ||
needs: prepare-base | ||
name: Run tests | ||
steps: | ||
- name: Check out code from GitHub | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | ||
id: python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.DEFAULT_PYTHON }} | ||
|
||
- name: Restore base Python virtual environment | ||
id: cache-venv | ||
uses: actions/cache@v3 | ||
with: | ||
path: venv | ||
key: | | ||
base-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml') }} | ||
- name: Fail job if Python cache restore failed | ||
if: steps.cache-venv.outputs.cache-hit != 'true' | ||
run: | | ||
echo "Failed to restore Python virtual environment from cache" | ||
exit 1 | ||
- name: Register Python problem matcher | ||
run: | | ||
echo "::add-matcher::.github/workflows/matchers/python.json" | ||
- name: Run pytest | ||
run: | | ||
. venv/bin/activate | ||
pytest \ | ||
-qq \ | ||
--durations=10 \ | ||
--cov ${{ env.PYTHON_MODULE_NAME }} \ | ||
-o console_output_style=count \ | ||
-p no:sugar \ | ||
tests | ||
- name: Upload coverage artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage-${{ env.DEFAULT_PYTHON }} | ||
path: .coverage | ||
|
||
coverage: | ||
name: Process test coverage | ||
runs-on: ubuntu-latest | ||
needs: pytest | ||
steps: | ||
- name: Check out code from GitHub | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python ${{ env.DEFAULT_PYTHON }} | ||
id: python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.DEFAULT_PYTHON }} | ||
|
||
- name: Restore base Python virtual environment | ||
id: cache-venv | ||
uses: actions/cache@v3 | ||
with: | ||
path: venv | ||
key: | | ||
base-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('pyproject.toml') }} | ||
- name: Fail job if Python cache restore failed | ||
if: steps.cache-venv.outputs.cache-hit != 'true' | ||
run: | | ||
echo "Failed to restore Python virtual environment from cache" | ||
exit 1 | ||
- name: Download all coverage artifacts | ||
uses: actions/download-artifact@v3 | ||
|
||
- name: Combine coverage results | ||
run: | | ||
. venv/bin/activate | ||
coverage combine coverage*/.coverage* | ||
coverage report | ||
coverage xml | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
shared-ci: | ||
uses: zigpy/workflows/.github/workflows/ci.yml@main | ||
with: | ||
CODE_FOLDER: universal_silabs_flasher | ||
CACHE_VERSION: 2 | ||
PYTHON_VERSION_DEFAULT: 3.8.14 | ||
PRE_COMMIT_CACHE_PATH: ~/.cache/pre-commit | ||
MINIMUM_COVERAGE_PERCENTAGE: 40 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"problemMatcher": [ | ||
{ | ||
"owner": "codespell", | ||
"severity": "warning", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(.+):(\\d+):\\s(.+)$", | ||
"file": 1, | ||
"line": 2, | ||
"message": 3 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"problemMatcher": [ | ||
{ | ||
"owner": "flake8-error", | ||
"severity": "error", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(.*):(\\d+):(\\d+):\\s([EF]\\d{3}\\s.*)$", | ||
"file": 1, | ||
"line": 2, | ||
"column": 3, | ||
"message": 4 | ||
} | ||
] | ||
}, | ||
{ | ||
"owner": "flake8-warning", | ||
"severity": "warning", | ||
"pattern": [ | ||
{ | ||
"regexp": "^(.*):(\\d+):(\\d+):\\s([CDNW]\\d{3}\\s.*)$", | ||
"file": 1, | ||
"line": 2, | ||
"column": 3, | ||
"message": 4 | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Publish distributions to PyPI | ||
|
||
on: | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
shared-build-and-publish: | ||
uses: zigpy/workflows/.github/workflows/publish-to-pypi.yml@main | ||
secrets: | ||
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,53 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v3.3.1 | ||
hooks: | ||
- id: debug-statements | ||
- id: pyupgrade | ||
args: [--py38-plus] | ||
|
||
- repo: https://github.com/charliermarsh/ruff-pre-commit | ||
rev: 'v0.0.272' | ||
- repo: https://github.com/PyCQA/autoflake | ||
rev: v2.0.2 | ||
hooks: | ||
- id: ruff | ||
args: ["--fix"] | ||
- id: autoflake | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 23.3.0 | ||
hooks: | ||
- id: black | ||
args: | ||
- --quiet | ||
|
||
- repo: https://github.com/pycqa/flake8 | ||
rev: 6.0.0 | ||
hooks: | ||
- id: flake8 | ||
additional_dependencies: | ||
- Flake8-pyproject==1.2.3 | ||
|
||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
|
||
- repo: https://github.com/codespell-project/codespell | ||
rev: v2.2.4 | ||
hooks: | ||
- id: codespell | ||
args: | ||
- --ignore-words-list=zigpy,hass | ||
- --skip="./.*" | ||
- --quiet-level=2 | ||
|
||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: v1.1.1 | ||
rev: v1.3.0 | ||
hooks: | ||
- id: mypy | ||
- id: mypy | ||
additional_dependencies: | ||
- zigpy | ||
|
||
- repo: https://github.com/charliermarsh/ruff-pre-commit | ||
rev: v0.0.261 | ||
hooks: | ||
- id: ruff | ||
args: | ||
- --fix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.