Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add basic linting using ruff #122

Merged
merged 5 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 36 additions & 20 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,47 @@
name: Unit tests

env:
# This should match the default python_version build arg
PYTHON_VERSION: 3.8
TOX_ENV: py38

on:
push:
branches:
- "*"
- "chameleoncloud/*"
pull_request:
types: [opened, reopened]

jobs:
test:
runs-on: ubuntu-latest

jobs:
run_linting:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3

- name: Set up Python 3.x
uses: actions/setup-python@v1
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install tox
run: pip install tox

- name: Run tests
run: tox -e ${{ env.TOX_ENV }}
run_tests:
strategy:
matrix:
include:
- python_version: "3.9"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: install uv for speedup
run: pip install uv
- name: install test tools
run: |
uv pip install \
--system \
-r requirements.txt \
-r test-requirements.txt \
.
- name: init stestr repo
run: stestr init
- name: run stestr tests
run: |
stestr run \
--exclude-list stestr_known_failing.txt
- name: list failing tests
run: stestr failing --list
if: always() #run even if tests fail
27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[build-system]
requires = ["pbr>=6.0.0", "setuptools>=64.0.0"]
build-backend = "pbr.build"

[tool.ruff]
line-length = 79

[tool.ruff.lint]
select = [
"E", # pycodestyle (error)
"F", # pyflakes
"G", # flake8-logging-format
"LOG", # flake8-logging
]


ignore = [
"E402", # many files monkeypatch eventlet, so imports not at top of file
"E501", # line too long
"E741", # Ambiguous variable name
"F401", # imported but unused
"F841", # Local variable is assigned to but never used
"G001", # logging statement uses str.format
"G002", # Logging statement uses `%`
"G004", # logging statement uses f-string
"G010", # Logging statement uses `warn` instead of `warning`
]
158 changes: 158 additions & 0 deletions stestr_known_failing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
blazar.tests.api.test_context.ContextTestCaseV1.test_ctx_from_headers
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_create_duplicate_reservation
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_create_duplicated_host_extra_capability
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_delete_host
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_event_get_first_sorted_by_event_type_filter
blazar.tests.manager.test_service.ServiceTestCase.test_basic_action_raise_exception
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_before_end_param_is_before_lease_start
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_start_date_in_past
blazar.tests.manager.test_service.ServiceTestCase.test_exec_event_retry
blazar.tests.manager.test_service.ServiceTestCase.test_get_bad_config_plugins
blazar.tests.manager.test_service.ServiceTestCase.test_start_lease
blazar.tests.manager.test_service.ServiceTestCase.test_update_fatal_extra_capability_too_long_exception
blazar.tests.manager.test_service.ServiceTestCase.test_update_lease_completed_modify_dates
blazar.tests.manager.test_service.ServiceTestCase.test_update_lease_started_modify_end_date_and_before_end
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_create_phys_lease
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_delete_correct_lease
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_destroy_for_event_not_found
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_get_hosts_per_filter
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_host_allocation_destroy_for_host
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_lease_list
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_search_for_hosts_by_extra_capability
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_update_host_extra_capability
blazar.tests.db.sqlalchemy.test_utils.SQLAlchemyDBUtilsTestCase.test_get_reservations_by_host_id_with_multi_reservation
blazar.tests.manager.test_service.ServiceTestCase.test_basic_action_with_res_status
blazar.tests.manager.test_service.ServiceTestCase.test_before_end_lease
blazar.tests.manager.test_service.ServiceTestCase.test_delete_lease_after_start
blazar.tests.manager.test_service.ServiceTestCase.test_exec_event_success
blazar.tests.manager.test_service.ServiceTestCase.test_update_lease_not_started_start_date_before_current_time
blazar.tests.manager.test_service.ServiceTestCase.test_update_lease_started_modify_before_end_with_invalid_date
blazar.tests.manager.test_service.ServiceTestCase.test_update_lease_started_modify_before_end_with_param
blazar.tests.manager.test_service.ServiceTestCase.test_update_modify_reservations_without_reservation_id
blazar.tests.manager.test_service.ServiceTestCase.test_update_reservations_with_invalid_reservation_id_3_1234
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_create_duplicate_host_reservation
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_create_duplicated_instance_reservation
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_create_host
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_create_leases_with_duplicated_reservation
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_event_get_first_sorted_by_status_filter
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_event_get_sorted_desc_by_lease_id_filter
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_event_get_sorted_desc_by_time_filter
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_lease_update
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_list_hosts
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_before_end_param_is_past_lease_ending
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_no_before_end_event
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_some_time
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_with_before_end_date_param
blazar.tests.manager.test_service.ServiceTestCase.test_event_spawn_fail
blazar.tests.manager.test_service.ServiceTestCase.test_exec_event_handle_exception
blazar.tests.manager.test_service.ServiceTestCase.test_update_lease_end_date_event_not_found
blazar.tests.manager.test_service.ServiceTestCase.test_update_lease_start_date_event_not_found
blazar.tests.manager.test_service.ServiceTestCase.test_update_lease_started_before_end_lower_date_than_start
blazar.tests.manager.test_service.ServiceTestCase.test_update_lease_started_modify_before_end_with_wrong_format
blazar.tests.manager.test_service.ServiceTestCase.test_update_lease_started_modify_start_date
blazar.tests.manager.test_service.ServiceTestCase.test_update_reservations_with_invalid_reservation_id_1_
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_delete_wrong_lease
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_host_reservation_get_all
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_instance_reservation_destroy
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_reservation_update
blazar.tests.db.sqlalchemy.test_utils.SQLAlchemyDBUtilsTestCase.test_get_reservation_allocations_by_host_ids_with_lease_id
blazar.tests.db.sqlalchemy.test_utils.SQLAlchemyDBUtilsTestCase.test_get_reservation_allocations_by_host_ids_with_reservation_id
blazar.tests.manager.test_service.ServiceTestCase.test_concurrent_events
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_unsupported_resource_type
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_validate_created_events
blazar.tests.manager.test_service.ServiceTestCase.test_event_pass
blazar.tests.manager.test_service.ServiceTestCase.test_event_success
blazar.tests.manager.test_service.ServiceTestCase.test_update_non_fatal_max_lease_duration_exception
blazar.tests.manager.test_service.ServiceTestCase.test_update_reservations_with_invalid_reservation_id_2_None
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_event_get_sorted_asc_by_event_type_filter
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_host_allocation_get_all_by_values
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_instance_reservation_create
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_instance_reservation_get
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_reservation_get_all_by_values
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_resource_properties_list
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_update_host
blazar.tests.db.sqlalchemy.test_utils.SQLAlchemyDBUtilsTestCase.test_get_reservations_by_host_ids
blazar.tests.db.sqlalchemy.test_utils.SQLAlchemyDBUtilsTestCase.test_get_reserved_periods
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_end_before_start
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_without_required_params
blazar.tests.manager.test_service.ServiceTestCase.test_delete_lease_after_ending
blazar.tests.manager.test_service.ServiceTestCase.test_exec_event_no_more_retry
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_create_duplicated_host
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_create_leases_with_duplicated_event
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_delete_host_extra_capability
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_destroy_non_existing_instance_reservation
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_event_get_sorted_asc_by_lease_id_filter
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_event_get_sorted_asc_by_time_filter
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_event_get_sorted_desc_by_status_filter
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_host_allocation_destroy_for_host_not_found
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_lease_get_all
blazar.tests.db.sqlalchemy.test_utils.SQLAlchemyDBUtilsTestCase.test_get_free_periods
blazar.tests.manager.test_service.ServiceTestCase.test_basic_action_no_res_status
blazar.tests.manager.test_service.ServiceTestCase.test_no_events
blazar.tests.manager.test_service.ServiceTestCase.test_setup_actions
blazar.tests.manager.test_service.ServiceTestCase.test_update_lease_is_not_values
blazar.tests.manager.test_service.ServiceTestCase.test_update_lease_not_started_modify_dates
blazar.tests.manager.test_service.ServiceTestCase.test_update_modify_reservations_with_invalid_param
blazar.tests.manager.test_service.ServiceTestCase.test_update_reservations_with_invalid_reservation_id_4_7085381b_45e0_4e5d_b24a_f965f5e6e5d7
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_create_lease_with_event
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_search_for_hosts_by_cpu_info
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_search_for_hosts_by_ram
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_update_host_reservation
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_update_non_existing_instance_reservation
blazar.tests.db.sqlalchemy.test_utils.SQLAlchemyDBUtilsTestCase.test_get_plugin_reservation_with_instance
blazar.tests.db.sqlalchemy.test_utils.SQLAlchemyDBUtilsTestCase.test_get_reservations_by_host_id
blazar.tests.manager.test_service.ServiceTestCase.test_basic_action_raise_exception_no_reservation_status
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_without_trust_id
blazar.tests.manager.test_service.ServiceTestCase.test_update_lease_end_date_before_current_time
blazar.tests.manager.test_service.ServiceTestCase.test_update_lease_with_filter_exception
blazar.tests.manager.test_service.ServiceTestCase.test_update_non_fatal_external_service_filter_exception
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_event_destroy
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_event_get_first_sorted_by_lease_id_filter
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_event_update
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_get_host_extra_capability_per_id
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_host_allocation_update_for_host
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_host_extra_capability_get_all_per_host
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_reservation_destroy_for_reservation_not_found
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_before_end_event_is_before_lease_start
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_duplicated_name
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_now
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_with_filter_exception
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_wrong_date
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_wrong_format_before_end_date
blazar.tests.manager.test_service.ServiceTestCase.test_process_events_concurrently
blazar.tests.manager.test_service.ServiceTestCase.test_rpc_server
blazar.tests.manager.test_service.ServiceTestCase.test_update_lease_completed_lease_rename
blazar.tests.manager.test_service.ServiceTestCase.test_update_lease_started_modify_end_date_without_before_end
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_create_reservation
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_host_allocation_create_for_duplicated_hosts
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_host_allocation_get_all
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_host_reservation_get_by_reservation_id
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_model_query
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_search_for_hosts_by_composed_queries
blazar.tests.db.sqlalchemy.test_utils.SQLAlchemyDBUtilsTestCase.test_get_plugin_reservation_with_invalid
blazar.tests.manager.test_service.ServiceTestCase.test_delete_lease_after_start_with_error_status
blazar.tests.manager.test_service.ServiceTestCase.test_end_lease
blazar.tests.manager.test_service.ServiceTestCase.test_exec_event_invalid_event_type
blazar.tests.manager.test_service.ServiceTestCase.test_get_lease
blazar.tests.manager.test_service.ServiceTestCase.test_plugins_that_fail_to_init
blazar.tests.manager.test_service.ServiceTestCase.test_start
blazar.tests.manager.test_service.ServiceTestCase.test_update_modify_reservations
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_create_duplicate_leases
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_create_duplicated_event
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_create_host_extra_capability
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_create_host_reservation
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_delete_host_reservation
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_event_create
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_event_get_sorted_asc_by_status_filter
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_event_get_sorted_desc_by_event_type_filter
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_get_physical_lease
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_host_extra_capability_get_all_per_name
blazar.tests.db.sqlalchemy.test_sqlalchemy_api.SQLAlchemyDBApiTestCase.test_instance_reservation_update
blazar.tests.db.sqlalchemy.test_utils.SQLAlchemyDBUtilsTestCase.test_get_reservation_allocations_by_host_ids
blazar.tests.manager.test_service.ServiceTestCase.test_create_lease_before_end_event_before_start_without_lease_id
blazar.tests.manager.test_service.ServiceTestCase.test_delete_lease_before_start
blazar.tests.manager.test_service.ServiceTestCase.test_delete_lease_with_filter_exception
blazar.tests.manager.test_service.ServiceTestCase.test_multiple_plugins_same_resource_type
blazar.tests.manager.test_service.ServiceTestCase.test_update_non_fatal_external_service_unsupported_http_response
blazar.tests.manager.test_service.ServiceTestCase.test_update_non_fatal_max_lease_update_window_exception
blazar.tests.utils.test_trusts.TestTrusts.test_create_ctx_from_trust
Loading