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

Refactor tests #32

Merged
merged 9 commits into from
Jan 5, 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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bugs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Bug Report
about: Bug Report for this project
title: ''
labels: ''
labels: 'bug'
assignees: ''
---

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Documentation request
about: Suggest a documentation for this project
title: ''
labels: ''
labels: 'documentation'
assignees: ''
---

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
labels: 'enhancement'
assignees: ''
---

Expand Down
70 changes: 70 additions & 0 deletions .github/ISSUE_TEMPLATE/refactoring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
name: Code Refactoring Request
about: Propose improvements to the codebase through refactoring.
title: "[Refactor] "
labels: enhancement, refactor
assignees: ''
---

## 🎯 Reason for Refactoring

<!-- Describe why this refactoring is necessary. What problem are we trying to solve? -->
Example:
The current code works as expected but has issues such as maintainability challenges, tight coupling, or violations of best practices. Refactoring will ensure better quality, readability, and scalability for the future.

---

## 🔍 Current Code Description

<!-- Explain how the code is currently implemented and identify areas for improvement. -->
Example:
- The `processData()` function has multiple responsibilities.
- The `Module X` relies on several external classes, making reuse difficult.
- There is inappropriate use of global variables.

---

## ✅ Proposed Solution

<!-- Describe how the code can be refactored to address the identified issues. -->
Example:
1. Apply the Single Responsibility Principle (SRP) to split the function/module into smaller components.
2. Remove global variables and replace them with dependency injection.
3. Modularize the code to allow reuse in different contexts.

---

## 📈 Expected Impact

<!-- List the benefits this refactoring will bring. -->
Example:
- Improve code readability.
- Enhance test coverage and simplify the testing process.
- Reduce coupling and improve modularity.
- Make the system better prepared for future feature additions.

---

## 🛠️ Completion Checklist

- [ ] Identify all impacted areas of the existing code.
- [ ] Ensure the refactoring maintains current functionality.
- [ ] Update or create unit and integration tests as needed.
- [ ] Update documentation (if applicable).

---

## 📂 Related References

<!-- Include links to related issues, pull requests, or discussions. -->
- Documentation link:
- Related discussion link:
- Previous pull request link:

---

## 💡 Additional Notes

<!-- Include any other relevant information or suggestions for contributors working on this task. -->
Example:
This refactoring should be performed alongside issue #123 to ensure compatibility with the proposed new architecture.
21 changes: 21 additions & 0 deletions .github/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Configuration for welcome - https://github.com/behaviorbot/welcome

# Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome

# Comment to be posted to on first time issues
newIssueWelcomeComment: >
Thanks for opening your first issue here! Be sure to follow the issue template!

# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome

# Comment to be posted to on PRs from first time contributors in your repository
newPRWelcomeComment: >
Thanks for opening this pull request! Please check out our contributing guidelines.

# Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge

# Comment to be posted to on pull requests merged by a first time user
firstPRMergeComment: >
Congrats on merging your first pull request! We here at behaviorbot are proud of you!

# It is recommended to include as many gifs and emojis as possible!
14 changes: 13 additions & 1 deletion .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@ name: CMake Build and Test
on:
push:
branches: [ "main" ]
paths:
- 'CMakeLists.txt'
- '**/*.cpp'
- '**/*.hpp'
- '**/*.h'
- '**/*.c'
pull_request:
branches: [ "main" ]

paths:
- 'CMakeLists.txt'
- '**/*.cpp'
- '**/*.hpp'
- '**/*.h'
- '**/*.c'

permissions:
contents: read
actions: read
Expand Down
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ project(search_engine VERSION 1.0)

add_subdirectory(lib)

include(FetchContent)
add_subdirectory(tests/unit-tests)
option(BUILD_TESTS "Build and enable tests" ON)

if (BUILD_TESTS)
enable_testing()
include(FetchContent)
add_subdirectory(tests/unit-tests)
endif()
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

**Search Engine** is a simple, efficient engine that builds a reverse index for keyword searching and ranks results using the **PageRank** algorithm.

Aqui está o arquivo Markdown corrigido, com os emojis adicionados nos títulos para manter o padrão e com a seção "Requirements" ajustada para contribuições:

## ⚙️ Installation

Please create a virtual environment using `venv`, as the project is still in alpha testing and in its initial implementations.
Expand Down
3 changes: 2 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def build_lib_cpp(path: str):
old_path = os.getcwd()
os.makedirs(path)
os.chdir(path)
subprocess.run(["cmake", ".."])
subprocess.run(["cmake", "..", "-DBUILD_TESTS=OFF"])
subprocess.run(["make"])
os.chdir(old_path)

Expand All @@ -43,6 +43,7 @@ def build(setup_kwargs):

extensions = []


for lib in libs_names:
ext = Extension(
f"{lib}",
Expand Down
6 changes: 5 additions & 1 deletion tests/unit-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ add_executable(

target_include_directories(LibUnitTests PRIVATE ${CMAKE_SOURCE_DIR}/lib/include/)

target_link_libraries(LibUnitTests PRIVATE gtest_main search_engine)
target_link_libraries(LibUnitTests PRIVATE gtest_main search_engine)

# Add command cmake test
include(GoogleTest)
gtest_discover_tests(LibUnitTests)
Loading