Skip to content

Commit 19d807c

Browse files
authored
Development workflow updates (#575)
* development workflow updates * fixes
1 parent ac9c599 commit 19d807c

35 files changed

+821
-1054
lines changed

.devcontainer/devcontainer.json

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"containerEnv": {
3+
"POETRY_VIRTUALENVS_IN_PROJECT": "true"
4+
},
5+
"customizations": {
6+
"codespaces": {
7+
"openFiles": ["README.md", "src/rokuecp/rokuecp.py", "src/rokuecp/models.py"]
8+
},
9+
"vscode": {
10+
"extensions": [
11+
"ms-python.python",
12+
"redhat.vscode-yaml",
13+
"esbenp.prettier-vscode",
14+
"GitHub.vscode-pull-request-github",
15+
"charliermarsh.ruff",
16+
"GitHub.vscode-github-actions",
17+
"ryanluker.vscode-coverage-gutters"
18+
],
19+
"settings": {
20+
"[python]": {
21+
"editor.codeActionsOnSave": {
22+
"source.fixAll": true,
23+
"source.organizeImports": true
24+
}
25+
},
26+
"coverage-gutters.customizable.context-menu": true,
27+
"coverage-gutters.customizable.status-bar-toggler-watchCoverageAndVisibleEditors-enabled": true,
28+
"coverage-gutters.showGutterCoverage": false,
29+
"coverage-gutters.showLineCoverage": true,
30+
"coverage-gutters.xmlname": "coverage.xml",
31+
"python.analysis.extraPaths": ["${workspaceFolder}/src"],
32+
"python.defaultInterpreterPath": ".venv/bin/python",
33+
"python.formatting.provider": "black",
34+
"python.linting.enabled": true,
35+
"python.linting.mypyEnabled": true,
36+
"python.linting.pylintEnabled": true,
37+
"python.testing.cwd": "${workspaceFolder}",
38+
"python.testing.pytestArgs": ["--cov-report=xml"],
39+
"python.testing.pytestEnabled": true,
40+
"ruff.importStrategy": "fromEnvironment",
41+
"ruff.interpreter": [".venv/bin/python"],
42+
"terminal.integrated.defaultProfile.linux": "zsh"
43+
}
44+
}
45+
},
46+
"features": {
47+
"ghcr.io/devcontainers-contrib/features/poetry:2": {},
48+
"ghcr.io/devcontainers/features/github-cli:1": {},
49+
"ghcr.io/devcontainers/features/node:1": {},
50+
"ghcr.io/devcontainers/features/python:1": {
51+
"installTools": false
52+
}
53+
},
54+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
55+
"name": "Async Python client for Roku (ECP)",
56+
"updateContentCommand": ". ${NVM_DIR}/nvm.sh && nvm install && nvm use && npm install && poetry install",
57+
"postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder} && poetry run pre-commit install"
58+
}

.flake8

-4
This file was deleted.

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.github/workflows/linting.yaml

+177-100
Original file line numberDiff line numberDiff line change
@@ -9,123 +9,200 @@ on:
99
pull_request:
1010
workflow_dispatch:
1111

12+
env:
13+
DEFAULT_PYTHON: "3.10"
14+
1215
jobs:
13-
precommit:
14-
name: ${{ matrix.name }}
16+
codespell:
17+
name: codespell
1518
runs-on: ubuntu-latest
16-
strategy:
17-
matrix:
18-
include:
19-
- id: bandit
20-
name: Check with bandit
21-
- id: black
22-
name: Check code style
23-
- id: blacken-docs
24-
name: Check code style in documentation
25-
- id: check-ast
26-
name: Check Python AST
27-
- id: check-case-conflict
28-
name: Check for case conflicts
29-
- id: check-docstring-first
30-
name: Check docstring is first
31-
- id: check-executables-have-shebangs
32-
name: Check that executables have shebangs
33-
- id: check-json
34-
name: Check JSON files
35-
- id: check-merge-conflict
36-
name: Check for merge conflicts
37-
- id: check-symlinks
38-
name: Check for broken symlinks
39-
- id: check-toml
40-
name: Check TOML files
41-
- id: check-yaml
42-
name: Check YAML files
43-
- id: codespell
44-
name: Check code for common misspellings
45-
- id: debug-statements
46-
name: Debug Statements and imports (Python)
47-
- id: detect-private-key
48-
name: Detect Private Keys
49-
- id: end-of-file-fixer
50-
name: Check End of Files
51-
- id: fix-byte-order-marker
52-
name: Check UTF-8 byte order marker
53-
- id: flake8
54-
name: Enforcing style guide with flake8
55-
- id: isort
56-
name: Check imports are sorted
57-
- id: poetry
58-
name: Check pyproject file
59-
- id: prettier
60-
name: Check if code is prettier
61-
- id: pylint
62-
name: Check with pylint
63-
- id: pyupgrade
64-
name: Check for upgradable syntax
65-
- id: trailing-whitespace
66-
name: Trim Trailing Whitespace
67-
- id: vulture
68-
name: Check for unused Python code
69-
- id: yamllint
70-
name: Check YAML style
7119
steps:
7220
- name: Check out code from GitHub
73-
uses: actions/checkout@v3
74-
- name: Set up Python 3.9
21+
uses: actions/[email protected]
22+
- name: Set up Poetry
23+
run: pipx install poetry
24+
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
7525
id: python
76-
uses: actions/setup-python@v4
26+
uses: actions/setup-python@v4.6.1
7727
with:
78-
python-version: 3.9
79-
- name: Read .nvmrc
80-
if: ${{ matrix.id == 'prettier' }}
81-
id: nvm
82-
run: echo "##[set-output name=nvmrc;]$(cat .nvmrc)"
83-
- name: Set up Node.js ${{ steps.nvm.outputs.nvmrc }}
84-
if: ${{ matrix.id == 'prettier' }}
85-
uses: actions/setup-node@v3
28+
python-version: ${{ env.DEFAULT_PYTHON }}
29+
cache: "poetry"
30+
- name: Install workflow dependencies
31+
run: |
32+
poetry config virtualenvs.create true
33+
poetry config virtualenvs.in-project true
34+
- name: Install Python dependencies
35+
run: poetry install --no-interaction
36+
- name: Check code for common misspellings
37+
run: poetry run pre-commit run codespell --all-files
38+
39+
ruff:
40+
name: Ruff
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Check out code from GitHub
44+
uses: actions/[email protected]
45+
- name: Set up Poetry
46+
run: pipx install poetry
47+
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
48+
id: python
49+
uses: actions/[email protected]
50+
with:
51+
python-version: ${{ env.DEFAULT_PYTHON }}
52+
cache: "poetry"
53+
- name: Install workflow dependencies
54+
run: |
55+
poetry config virtualenvs.create true
56+
poetry config virtualenvs.in-project true
57+
- name: Install Python dependencies
58+
run: poetry install --no-interaction
59+
- name: Run Ruff
60+
run: poetry run ruff .
61+
62+
black:
63+
name: black
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Check out code from GitHub
67+
uses: actions/[email protected]
68+
- name: Set up Poetry
69+
run: pipx install poetry
70+
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
71+
id: python
72+
uses: actions/[email protected]
73+
with:
74+
python-version: ${{ env.DEFAULT_PYTHON }}
75+
cache: "poetry"
76+
- name: Install workflow dependencies
77+
run: |
78+
poetry config virtualenvs.create true
79+
poetry config virtualenvs.in-project true
80+
- name: Install Python dependencies
81+
run: poetry install --no-interaction
82+
- name: Run black on docs
83+
run: poetry run blacken-docs
84+
85+
pre-commit-hooks:
86+
name: pre-commit-hooks
87+
runs-on: ubuntu-latest
88+
steps:
89+
- name: Check out code from GitHub
90+
uses: actions/[email protected]
91+
- name: Set up Poetry
92+
run: pipx install poetry
93+
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
94+
id: python
95+
uses: actions/[email protected]
8696
with:
87-
node-version: "${{ steps.nvm.outputs.nvmrc }}"
88-
- name: Get pip cache dir
89-
id: pip-cache
97+
python-version: ${{ env.DEFAULT_PYTHON }}
98+
cache: "poetry"
99+
- name: Install workflow dependencies
90100
run: |
91-
echo "::set-output name=dir::$(pip cache dir)"
92-
- name: Restore cached Python PIP packages
93-
uses: actions/cache@v3
101+
poetry config virtualenvs.create true
102+
poetry config virtualenvs.in-project true
103+
- name: Install Python dependencies
104+
run: poetry install --no-interaction
105+
- name: Check Python AST
106+
run: poetry run pre-commit run check-ast --all-files
107+
- name: Check for case conflicts
108+
run: poetry run pre-commit run check-case-conflict --all-files
109+
- name: Check docstring is first
110+
run: poetry run pre-commit run check-docstring-first --all-files
111+
- name: Check that executables have shebangs
112+
run: poetry run pre-commit run check-executables-have-shebangs --all-files
113+
- name: Check JSON files
114+
run: poetry run pre-commit run check-json --all-files
115+
- name: Check for merge conflicts
116+
run: poetry run pre-commit run check-merge-conflict --all-files
117+
- name: Check for broken symlinks
118+
run: poetry run pre-commit run check-symlinks --all-files
119+
- name: Check TOML files
120+
run: poetry run pre-commit run check-toml --all-files
121+
- name: Check XML files
122+
run: poetry run pre-commit run check-xml --all-files
123+
- name: Check YAML files
124+
run: poetry run pre-commit run check-yaml --all-files
125+
- name: Check YAML files
126+
run: poetry run pre-commit run check-yaml --all-files
127+
- name: Detect Private Keys
128+
run: poetry run pre-commit run detect-private-key --all-files
129+
- name: Check End of Files
130+
run: poetry run pre-commit run end-of-file-fixer --all-files
131+
- name: Trim Trailing Whitespace
132+
run: poetry run pre-commit run trailing-whitespace --all-files
133+
134+
pylint:
135+
name: pylint
136+
runs-on: ubuntu-latest
137+
steps:
138+
- name: Check out code from GitHub
139+
uses: actions/[email protected]
140+
- name: Set up Poetry
141+
run: pipx install poetry
142+
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
143+
id: python
144+
uses: actions/[email protected]
94145
with:
95-
path: ${{ steps.pip-cache.outputs.dir }}
96-
key: pip-${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('.github/workflows/requirements.txt') }}
97-
restore-keys: |
98-
pip-${{ runner.os }}-${{ steps.python.outputs.python-version }}-
146+
python-version: ${{ env.DEFAULT_PYTHON }}
147+
cache: "poetry"
99148
- name: Install workflow dependencies
100149
run: |
101-
pip install -r .github/workflows/requirements.txt
102150
poetry config virtualenvs.create true
103151
poetry config virtualenvs.in-project true
104-
- name: Restore cached Python virtual environment
105-
id: cached-poetry-dependencies
106-
uses: actions/cache@v3
152+
- name: Install Python dependencies
153+
run: poetry install --no-interaction
154+
- name: Run pylint
155+
run: poetry run pre-commit run pylint --all-files
156+
157+
yamllint:
158+
name: yamllint
159+
runs-on: ubuntu-latest
160+
steps:
161+
- name: Check out code from GitHub
162+
uses: actions/[email protected]
163+
- name: Set up Poetry
164+
run: pipx install poetry
165+
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
166+
id: python
167+
uses: actions/[email protected]
107168
with:
108-
path: .venv
109-
key: >-
110-
venv-${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
111-
venv-${{ runner.os }}-${{ steps.python.outputs.python-version }}-
169+
python-version: ${{ env.DEFAULT_PYTHON }}
170+
cache: "poetry"
171+
- name: Install workflow dependencies
172+
run: |
173+
poetry config virtualenvs.create true
174+
poetry config virtualenvs.in-project true
112175
- name: Install Python dependencies
113176
run: poetry install --no-interaction
114-
- name: Get npm cache directory
115-
if: ${{ matrix.id == 'prettier' }}
116-
id: npm-cache
177+
- name: Run yamllint
178+
run: poetry run yamllint .
179+
180+
prettier:
181+
name: Prettier
182+
runs-on: ubuntu-latest
183+
steps:
184+
- name: Check out code from GitHub
185+
uses: actions/[email protected]
186+
- name: Set up Poetry
187+
run: pipx install poetry
188+
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
189+
id: python
190+
uses: actions/[email protected]
191+
with:
192+
python-version: ${{ env.DEFAULT_PYTHON }}
193+
cache: "poetry"
194+
- name: Install workflow dependencies
117195
run: |
118-
echo "::set-output name=dir::$(npm config get cache)"
119-
- name: Restore cached node modules
120-
if: ${{ matrix.id == 'prettier' }}
121-
uses: actions/cache@v3
196+
poetry config virtualenvs.create true
197+
poetry config virtualenvs.in-project true
198+
- name: Install Python dependencies
199+
run: poetry install --no-interaction
200+
- name: Set up Node.js
201+
uses: actions/setup-node@v3
122202
with:
123-
path: ${{ steps.npm-cache.outputs.dir }}
124-
key: node-${{ runner.os }}-${{ steps.nvm.outputs.nvmrc }}-${{ hashFiles('.github/workflows/requirements.txt') }}
125-
restore-keys: |
126-
node-${{ runner.os }}-${{ steps.nvm.outputs.nvmrc }}-
203+
node-version-file: ".nvmrc"
204+
cache: "npm"
127205
- name: Install NPM dependencies
128-
if: ${{ matrix.id == 'prettier' }}
129206
run: npm install
130-
- name: Run pre-commit for ${{ matrix.id }}
131-
run: poetry run pre-commit run ${{ matrix.id }} --all-files
207+
- name: Run prettier
208+
run: poetry run pre-commit run prettier --all-files
File renamed without changes.

0 commit comments

Comments
 (0)