add poetry check ... well, check (#18357)

* add poetry check ...  well, check

* add poetry check to pre-commit

* touchup

* Update activated.sh

* Update activated.ps1
This commit is contained in:
Kyle Altendorf
2024-07-29 12:30:05 -07:00
committed by GitHub
parent 2c2b0f4e1a
commit 740282a636
5 changed files with 33 additions and 6 deletions
+3
View File
@@ -136,6 +136,9 @@ jobs:
command: |
python3 -m chia._tests.util.build_network_protocol_files
git diff --exit-code
- name: poetry
command: |
.penv/bin/poetry check
steps:
- uses: chia-network/actions/clean-workspace@main
+7
View File
@@ -28,6 +28,13 @@ repos:
language: system
require_serial: true
types_or: [python, pyi]
- repo: local
hooks:
- id: poetry
name: poetry
entry: ./activated.py --poetry poetry check
language: system
pass_filenames: false
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
+4 -2
View File
@@ -2,11 +2,13 @@ $ErrorActionPreference = "Stop"
$script_directory = Split-Path $MyInvocation.MyCommand.Path -Parent
$command = $args[0]
$env_directory = $args[0]
$command = $args[1]
$parameters = [System.Collections.ArrayList]$args
$parameters.RemoveAt(0)
$parameters.RemoveAt(0)
& $script_directory/.venv/Scripts/Activate.ps1
& $script_directory/$env_directory/Scripts/Activate.ps1
& $command @parameters
exit $LASTEXITCODE
+13 -2
View File
@@ -2,6 +2,7 @@
from __future__ import annotations
import enum
import os
import pathlib
import subprocess
@@ -10,17 +11,27 @@ import sys
here = pathlib.Path(__file__).parent.absolute()
class Env(enum.Enum):
chia = ".venv"
poetry = ".penv"
def main(*args: str) -> int:
if len(args) == 0:
print("Parameters required")
return 1
env = Env.chia
if args[0].startswith("--"):
env = Env[args[0][2:]]
args = args[1:]
if sys.platform == "win32":
script = "activated.ps1"
command = ["powershell", os.fspath(here.joinpath(script)), *args]
command = ["powershell", os.fspath(here.joinpath(script)), env.value, *args]
else:
script = "activated.sh"
command = ["sh", os.fspath(here.joinpath(script)), *args]
command = ["sh", os.fspath(here.joinpath(script)), env.value, *args]
completed_process = subprocess.run(command)
+6 -2
View File
@@ -6,7 +6,11 @@ SCRIPT_DIRECTORY=$(
cd -- "$(dirname -- "$0")"
pwd
)
# shellcheck disable=SC1091
. "${SCRIPT_DIRECTORY}/.venv/bin/activate"
ENV_DIRECTORY="$1"
shift
# shellcheck disable=SC1090,SC1091
. "${SCRIPT_DIRECTORY}/${ENV_DIRECTORY}/bin/activate"
"$@"