-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from historysciencelab/implement-ruff-check-ev…
…erywhere Implement ruff check and format in CI
- Loading branch information
Showing
11 changed files
with
115 additions
and
43 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
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 @@ | ||
name: Code formatting | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install ruff | ||
- name: Format the code | ||
run: | | ||
ruff format . |
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 @@ | ||
name: Code linting | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install ruff | ||
- name: Lint the code | ||
run: | | ||
ruff check . |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
import os, sys; sys.path.append(os.path.dirname(os.path.realpath(__file__))) | ||
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
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
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,24 +1,29 @@ | ||
import pytest | ||
import subprocess | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def run_cli_command(): | ||
# This fixture runs the CLI command and captures its output | ||
def run_command(): | ||
# Run the CLI command and capture its output | ||
result = subprocess.run(["python", "-m", "src.interviewkit.cli", "version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) | ||
result = subprocess.run( | ||
["python", "-m", "src.interviewkit.cli", "version"], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
universal_newlines=True, | ||
) | ||
return result | ||
|
||
return run_command | ||
|
||
|
||
class TestCLIVersion(): | ||
|
||
class TestCLIVersion: | ||
def test_version_option(self, run_cli_command): | ||
result = run_cli_command() | ||
|
||
assert result.returncode == 0 | ||
|
||
# Check if the version number is correct | ||
assert f"HistoryAIToolKit: 0.0.1" in result.stdout | ||
assert "HistoryAIToolKit: 0.0.1" in result.stdout |
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,30 +1,29 @@ | ||
import shutil | ||
import subprocess | ||
import sys | ||
|
||
import pytest | ||
import shutil | ||
|
||
|
||
@pytest.fixture | ||
def create_venv(tmp_path): | ||
venv_dir = tmp_path / ".venv" | ||
subprocess.run([sys.executable, "-m", "venv", str(venv_dir)], check=True) | ||
yield venv_dir | ||
shutil.rmtree(venv_dir) | ||
yield venv_dir | ||
shutil.rmtree(venv_dir) | ||
|
||
|
||
def test_install_in_editable_mode(create_venv): | ||
activate_script = create_venv / "bin" / "activate" if sys.platform != "win32" else create_venv / "Scripts" / "activate" | ||
activate_script = ( | ||
create_venv / "bin" / "activate" | ||
if sys.platform != "win32" | ||
else create_venv / "Scripts" / "activate" | ||
) | ||
shell = False if sys.platform != "win32" else True | ||
|
||
|
||
commands = [ | ||
f"source {activate_script}", | ||
"pip install -e '.[test]'" | ||
] | ||
|
||
|
||
|
||
commands = [f"source {activate_script}", "pip install -e '.[test]'"] | ||
|
||
process = subprocess.Popen(["/bin/bash", "-c", " && ".join(commands)], shell=shell) | ||
process.communicate() | ||
|
||
|
||
assert process.returncode == 0, "Installation in editable mode failed" | ||
|
||
assert process.returncode == 0, "Installation in editable mode failed" |