Skip to content
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
12 changes: 9 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"build": {
"dockerfile": "Dockerfile"
},
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
Expand All @@ -23,7 +21,15 @@
]
}
},
// This is necessary to ensure that Docker Compose containers are available inside the devcontainer
"runArgs": [
"--network=host"
],
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
"version": "20.10",
"dockerDashComposeVersion": "v2"
}
}
}
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This is necessary so that environment variables from .env
# are visible when Makefile commands are executed
include .env
export

# Generate a new Alembic migration with autogenerate
create-migration: up-db
@cd ./src/data && \
alembic revision --autogenerate -m $(name)

# Apply all pending Alembic migrations
apply-migrations: up-db
@cd ./src/data && \
alembic upgrade head

# Build the project, apply migrations and start the application
run: apply-migrations
@conan build . --build=missig && \
./build/Debug/to-dos-api

# Run clang-tidy static analysis
run-tidy:
@run-clang-tidy -p build/Debug
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ When dependencies are built, use the command `conan build . -pr:h profiles/to-do
To launch the executable, click Launch in the CMake extension.
<p style="text-align: center;"><img src="docs/images/cmakeLaunch.png" alt="cmakeLaunch" width="400"/></p>

Alternatively, you can use make targets.
- To run the application, use the `make run` command. When the command is executed, the project's dependencies will be checked and, if necessary, installed and compiled.

## Linters

The project includes the `clang-tidy` code analyzer and the `clang-format` formatter. Configuration files are located in the project root: `.clang-tidy` and `.clang-format`, respectively.
Expand All @@ -56,7 +59,7 @@ To use linters you need to install:

Clang-format code formatting occurs automatically when saving a file using the CodeAnalysis C/C++ extension.

To start manually, you need to run the command `find ./src -name "*.cpp" -o -name "*.h" | xargs clang-format --dry-run`, while in the root of the project.
To start manually, you need to run the command `find ./src -name "*.cpp" -o -name "*.h" | xargs clang-format`, while in the root of the project.

To automatically fix errors, run `find ./src -name "*.cpp" -o -name "*.h" | xargs clang-format -i` from the project root.

Expand All @@ -66,6 +69,9 @@ Clang-tidy code checking occurs in the background using the CodeAnalysis C/C++ e

To start manually, you need to run the command `find ./src -name "*.cpp" -o -name "*.h" | xargs clang-tidy -p ./build/Debug | grep "error:"`, while in the root of the project.

Alternatively, you can use make targets.
- To run the code analyzer, use the `make run-tidy` command.

## Tests run

The project presents an example of test implementation using GTest tools. Test files are located in the `test` directory at the root of the project. Inside the `test` directory there is a `CMakeLists.txt` file created specifically for building a separate executable file for tests.
Expand Down Expand Up @@ -93,4 +99,8 @@ The alembic tool is used to work with migrations. To work with it, you need to m
- Create/change python model according declared cpp model.
- Change terminal workspace to `src/data`.
- Use the alembic command `alembic revision --autogenerate -m '<name of migration>'` for create new migration to database.
- If its needed upgrade local database with latest migration with commnd `alembic upgrade head`.
- If its needed upgrade local database with latest migration with commnd `alembic upgrade head`.

Alternatively, you can use make targets.
- To create a migration, run the command `make create-migration name=<name-of-migration>`, where `name` is the name of the migration. You can also use `make create-migration`, in which case the migration will be named after the current date and time.
- To apply the migrations, run the `make apply-migrations` command.
Loading