-
Notifications
You must be signed in to change notification settings - Fork 0
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 #4 from dhruvbaldawa/code-quality
- Loading branch information
Showing
39 changed files
with
760 additions
and
933 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Quality Checks | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: 'google-github-actions/auth@v2' | ||
with: | ||
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' | ||
|
||
- name: Set up Cloud SDK | ||
uses: google-github-actions/setup-gcloud@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
cache: 'pip' | ||
|
||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: latest | ||
|
||
- name: Setup Poetry cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ./.venv | ||
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} | ||
|
||
- name: Install just | ||
uses: extractions/setup-just@v1 | ||
|
||
- name: Configure Poetry | ||
run: | | ||
poetry config virtualenvs.in-project true | ||
poetry config virtualenvs.create true | ||
- name: Install dependencies | ||
run: poetry install --no-interaction | ||
|
||
- name: Run checks | ||
run: poetry run just check | ||
|
||
- name: Run tests | ||
run: poetry run just test |
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,16 @@ | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: ruff-check | ||
name: Run ruff check | ||
entry: poetry run just check | ||
language: system | ||
pass_filenames: false | ||
stages: [pre-commit] | ||
|
||
- id: pytest | ||
name: Run pytest | ||
entry: poetry run just test | ||
language: system | ||
pass_filenames: false | ||
stages: [pre-commit] |
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,5 @@ | ||
pytest_plugins = [ | ||
"gyandex.podgen.storage.test_fixtures", | ||
"gyandex.podgen.feed.test_fixtures", | ||
"gyandex.podgen.engine.test_fixtures", | ||
] |
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,31 @@ | ||
from unittest.mock import Mock, patch | ||
|
||
import pytest | ||
|
||
from gyandex.cli.podgen import main | ||
|
||
|
||
def test_cli_help_command(): | ||
"""Tests that help command prints help message and exits""" | ||
# When | ||
with ( | ||
patch("argparse.ArgumentParser.parse_args", return_value=Mock(config_path="--help")), | ||
patch("argparse.ArgumentParser.print_help") as mock_help, | ||
): | ||
main() | ||
|
||
# Then | ||
mock_help.assert_called_once() | ||
|
||
|
||
def test_invalid_config_path(): | ||
"""Tests handling of invalid configuration file path""" | ||
# Given | ||
invalid_path = "nonexistent.yaml" | ||
|
||
# When/Then | ||
with ( | ||
pytest.raises(FileNotFoundError), | ||
patch("argparse.ArgumentParser.parse_args", return_value=Mock(config_path=invalid_path)), | ||
): | ||
main() |
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
Oops, something went wrong.