Fast lint CI job: Rustfmt, Prettier, Ruff (#2406)

Add a single job for for fast lint tools. Rustfmt for rust, ruff for
python formatting and linting, prettier avoids inconsistent formatter
changes between pycharm and vscode.
This commit is contained in:
konsti 2024-03-20 01:16:46 +01:00 committed by GitHub
parent ab99a18cbc
commit 79fbac7af5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 31 additions and 22 deletions

View file

@ -23,11 +23,22 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: "Install Rust toolchain"
- name: "Install Rustfmt"
run: rustup component add rustfmt run: rustup component add rustfmt
- name: "rustfmt" - name: "rustfmt"
run: cargo fmt --all --check run: cargo fmt --all --check
- name: "Prettier"
run: npx prettier --check "**/*.{yaml,yml}"
- name: "Ruff format"
run: pipx run ruff format --diff .
- name: "Ruff check"
run: pipx run ruff check .
cargo-clippy: cargo-clippy:
name: "cargo clippy" name: "cargo clippy"
strategy: strategy:

View file

@ -36,4 +36,4 @@ repos:
hooks: hooks:
- id: ruff-format - id: ruff-format
- id: ruff - id: ruff
args: [--fix, --exit-non-zero-on-fix] args: [--fix, --exit-non-zero-on-fix]

View file

@ -1,6 +1,7 @@
""" """
This is implementation has some very rudimentary python bindings This is implementation has some very rudimentary python bindings
""" """
from pep440_rs import Version, VersionSpecifier, Operator, VersionSpecifiers from pep440_rs import Version, VersionSpecifier, Operator, VersionSpecifiers

View file

@ -22,6 +22,7 @@ def _detect_virtualenv() -> str:
return "" return ""
def _run() -> None: def _run() -> None:
uv = os.fsdecode(find_uv_bin()) uv = os.fsdecode(find_uv_bin())
@ -39,6 +40,5 @@ def _run() -> None:
os.execvpe(uv, [uv, *sys.argv[1:]], env=env) os.execvpe(uv, [uv, *sys.argv[1:]], env=env)
if __name__ == "__main__": if __name__ == "__main__":
_run() _run()

View file

@ -25,6 +25,7 @@ each build, as in:
--uv-path ./target/release/baseline \ --uv-path ./target/release/baseline \
requirements.in requirements.in
""" """
import abc import abc
import argparse import argparse
import enum import enum
@ -271,11 +272,9 @@ class PipCompile(Suite):
], ],
) )
def install_cold(self, requirements_file: str, *, cwd: str) -> Command | None: def install_cold(self, requirements_file: str, *, cwd: str) -> Command | None: ...
...
def install_warm(self, requirements_file: str, *, cwd: str) -> Command | None: def install_warm(self, requirements_file: str, *, cwd: str) -> Command | None: ...
...
class PipSync(Suite): class PipSync(Suite):
@ -283,16 +282,13 @@ class PipSync(Suite):
self.name = path or "pip-sync" self.name = path or "pip-sync"
self.path = path or "pip-sync" self.path = path or "pip-sync"
def resolve_cold(self, requirements_file: str, *, cwd: str) -> Command | None: def resolve_cold(self, requirements_file: str, *, cwd: str) -> Command | None: ...
...
def resolve_warm(self, requirements_file: str, *, cwd: str) -> Command | None: def resolve_warm(self, requirements_file: str, *, cwd: str) -> Command | None: ...
...
def resolve_incremental( def resolve_incremental(
self, requirements_file: str, *, cwd: str self, requirements_file: str, *, cwd: str
) -> Command | None: ) -> Command | None: ...
...
def install_cold(self, requirements_file: str, *, cwd: str) -> Command | None: def install_cold(self, requirements_file: str, *, cwd: str) -> Command | None:
cache_dir = os.path.join(cwd, ".cache") cache_dir = os.path.join(cwd, ".cache")

View file

@ -17,6 +17,7 @@ Acknowledgements:
Derived from https://github.com/mitsuhiko/rye/tree/f9822267a7f00332d15be8551f89a212e7bc9017 Derived from https://github.com/mitsuhiko/rye/tree/f9822267a7f00332d15be8551f89a212e7bc9017
Originally authored by Armin Ronacher under the MIT license Originally authored by Armin Ronacher under the MIT license
""" """
import argparse import argparse
import hashlib import hashlib
import json import json

View file

@ -144,9 +144,9 @@ def main(scenarios: list[Path], snapshot_update: bool = True):
"local-used-without-sdist", "local-used-without-sdist",
): ):
expected["satisfiable"] = False expected["satisfiable"] = False
expected[ expected["explanation"] = (
"explanation" "We do not have correct behavior for local version identifiers yet"
] = "We do not have correct behavior for local version identifiers yet" )
# Split scenarios into `install` and `compile` cases # Split scenarios into `install` and `compile` cases
install_scenarios = [] install_scenarios = []
@ -167,13 +167,13 @@ def main(scenarios: list[Path], snapshot_update: bool = True):
ref = "HEAD" if packse_version == "0.0.0" else packse_version ref = "HEAD" if packse_version == "0.0.0" else packse_version
# Add generated metadata # Add generated metadata
data[ data["generated_from"] = (
"generated_from" f"https://github.com/zanieb/packse/tree/{ref}/scenarios"
] = f"https://github.com/zanieb/packse/tree/{ref}/scenarios" )
data["generated_with"] = "./scripts/scenarios/sync.sh" data["generated_with"] = "./scripts/scenarios/sync.sh"
data[ data["vendor_links"] = (
"vendor_links" f"https://raw.githubusercontent.com/zanieb/packse/{ref}/vendor/links.html"
] = f"https://raw.githubusercontent.com/zanieb/packse/{ref}/vendor/links.html" )
data["index_url"] = f"https://astral-sh.github.io/packse/{ref}/simple-html/" data["index_url"] = f"https://astral-sh.github.io/packse/{ref}/simple-html/"