Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infra update #64

Merged
merged 2 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ RUN \
unzip allure-commandline-2.20.1.zip -d /allure && \
rm allure-commandline-2.20.1.zip

ENV PATH "/allure/allure-2.20.1/bin:${PATH}"
USER vscode
# Install uv (pip replacement)
RUN \
curl -LsSf https://astral.sh/uv/install.sh | sh

WORKDIR /workspaces
ENV PATH="/allure/allure-2.20.1/bin:/home/vscode/.cargo/bin:${PATH}"

# Install Python dependencies from requirements
COPY requirements*.txt ./
RUN pip install -r requirements-test.txt
WORKDIR /workspaces

# Set the default shell to bash instead of sh
ENV SHELL /bin/bash
ENV SHELL /bin/bash
75 changes: 43 additions & 32 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,48 @@
"context": "..",
"dockerFile": "Dockerfile",
"containerEnv": { "DEVCONTAINER": "1" },
"extensions": [
"ms-python.vscode-pylance",
"visualstudioexptteam.vscodeintellicode",
"redhat.vscode-yaml",
"esbenp.prettier-vscode",
"GitHub.vscode-pull-request-github"
],
// Please keep this file in sync with settings in home-assistant/.vscode/settings.default.json
"settings": {
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.blackPath": "/usr/local/bin/black",
"python.formatting.provider": "black",
"python.testing.pytestArgs": ["--no-cov"],
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true,
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "/usr/bin/zsh"
"customizations": {
"vscode": {
"extensions": [
"ms-python.vscode-pylance",
"visualstudioexptteam.vscodeintellicode",
"redhat.vscode-yaml",
"esbenp.prettier-vscode",
"GitHub.vscode-pull-request-github",
"github.vscode-github-actions",
"charliermarsh.ruff"
],
// Please keep this file in sync with settings in home-assistant/.vscode/settings.default.json
"settings": {
"[python]": {
"diffEditor.ignoreTrimWhitespace": false,
"editor.formatOnType": true,
"editor.formatOnSave": true,
"editor.wordBasedSuggestions": "off",
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
}
},
"python.pythonPath": "./venv/bin/python",
"python.testing.pytestArgs": ["--no-cov"],
"files.trimTrailingWhitespace": true,
"terminal.integrated.defaultProfile.linux": "bash",
"yaml.customTags": [
"!input scalar",
"!secret scalar",
"!include_dir_named scalar",
"!include_dir_list scalar",
"!include_dir_merge_list scalar",
"!include_dir_merge_named scalar"
]
}
},
"terminal.integrated.defaultProfile.linux": "zsh",
"yaml.customTags": [
"!input scalar",
"!secret scalar",
"!include_dir_named scalar",
"!include_dir_list scalar",
"!include_dir_merge_list scalar",
"!include_dir_merge_named scalar"
]
}
}
},
"remoteUser": "vscode",
"postCreateCommand": "uv venv && . .venv/bin/activate && uv pip install -r requirements-test.txt && git config commit.gpgsign true",
"mounts": [
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.gnupg,target=/home/vscode/.gnupg,type=bind,consistency=cached"
]
}
1 change: 0 additions & 1 deletion .github/workflows/ci-main-test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ jobs:
pip install -r requirements-test.txt
- name: Test with pytest
run: |
#pylint icloudpy/ tests/ && pytest
pytest && rm htmlcov/.gitignore
- name: Upload coverage artifacts
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
# uses: mxschmitt/action-tmate@v3
- name: Test with pytest
run: |
pytest
ruff check && pytest
- name: Generate Allure Report
uses: simple-elf/allure-report-action@master
if: always()
Expand Down
129 changes: 129 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]

# Same as Black.
line-length = 120
indent-width = 4

# Assume Python 3.8
# target-version = "py38"

[lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["F", "E", "W",
# "C90",
"I",
# "N",
# "D",
"UP", "YTT",
# "ANN",
"ASYNC",
# "S",
# "BLE",
# "FBT",
# "B",
# "A",
"COM", "C4",
# "DTZ",
# "T10",
"DJ",
#"EM",
"EXE",
#"FA",
# "ISC",
"ICN",
# "LOG",
# "G",
"INP", "PIE",
# "T20",
"PYI",
# "PT",
"Q", "RSE",
#"RET",
#"SLF",
"SLOT",
# "SIM",
"TID", "TCH", "INT",
# "ARG",
# "PTH",
"TD",
"FIX",
# "ERA",
"PD", "PGH",
# "PL",
# "TRY",
# "FLY",
"NPY", "AIR",
#"PERF",
# "FURB",
# "RUF"
]
ignore = ["E501"]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = ["B"]

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# 4. Ignore `E402` (import violations) in all `__init__.py` files, and in select subdirectories.
[lint.per-file-ignores]
"__init__.py" = ["E402"]
"**/{tests,docs,tools}/*" = ["E402"]


[format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

# Enable auto-formatting of code examples in docstrings. Markdown,
# reStructuredText code/literal blocks and doctests are all supported.
#
# This is currently disabled by default, but it is planned for this
# to be opt-out in the future.
# docstring-code-format = true
# docstring-code-line-length = 120

# Set the line length limit used when formatting code snippets in
# docstrings.
#
# This only has an effect when the `docstring-code-format` setting is
# enabled.
# docstring-code-line-length = "dynamic"
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Attach using Process Id",
"type": "debugpy",
"request": "attach",
"processId": "${command:pickProcess}"
},
{
"name": "Debug Tests",
"type": "python",
"request": "test",
"console": "integratedTerminal",
"justMyCode": false,
"env": {"PYTEST_ADDOPTS": "--no-cov"}
}
]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
4 changes: 2 additions & 2 deletions generate_badges.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@

url_data = "passing&color=brightgreen" if test_result else "failing&color=critical"
response = requests.get(
"https://img.shields.io/static/v1?label=Tests&message=" + url_data
"https://img.shields.io/static/v1?label=Tests&message=" + url_data,
)
with open(badges_directory + "/tests.svg", "w") as f:
f.write(response.text)
url_data = "brightgreen" if coverage_result == 100.0 else "critical"
response = requests.get(
f"https://img.shields.io/static/v1?label=Coverage&message={coverage_result}%&color={url_data}"
f"https://img.shields.io/static/v1?label=Coverage&message={coverage_result}%&color={url_data}",
)
with open(badges_directory + "/coverage.svg", "w") as f:
f.write(response.text)
3 changes: 2 additions & 1 deletion icloudpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""The iCloudPy library."""

import logging

from icloudpy.base import ICloudPyService # pylint: disable=unused-import
from icloudpy.base import ICloudPyService # # noqa: F401

logging.getLogger(__name__).addHandler(logging.NullHandler())
Loading
Loading