chore: small improvements

This commit is contained in:
ITQ
2025-11-20 07:34:26 +03:00
parent 52f3072729
commit 8e913479bc
5 changed files with 45 additions and 43 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
# Environment
./config.toml
config.toml
docker-compose.yml
.idea
+39 -35
View File
@@ -31,7 +31,7 @@ cache:
.trivy-fs-template: &trivy-fs-scan
stage: security
image:
image:
name: aquasec/trivy:latest
entrypoint: [""]
cache:
@@ -61,7 +61,7 @@ cache:
.trivy-image-template: &trivy-image-scan
stage: security
image:
image:
name: aquasec/trivy:latest
entrypoint: [""]
cache:
@@ -138,37 +138,6 @@ cache:
when: manual
allow_failure: true
.test-template: &test-config
<<: *docker-job
stage: test
script:
- apk add --no-cache docker-compose
- |
REGISTRY_PREFIX=$CI_REGISTRY_IMAGE \
docker compose -f compose.yaml -f compose.prod.yaml \
--profile migrations --profile tests up -d -y --quiet-pull --quiet-build
- |
TEST_CONTAINER_ID=$(docker compose --profile migrations --profile tests ps -q tests -a)
timeout 600 docker wait $TEST_CONTAINER_ID
TEST_EXIT_CODE=$(docker inspect --format "{{.State.ExitCode}}" $TEST_CONTAINER_ID)
if [ $TEST_EXIT_CODE -eq 0 ]; then
echo "Tests passed."
else
echo "Tests failed with exit code $TEST_EXIT_CODE."
exit 1
fi
- |
docker compose -f compose.yaml -f compose.prod.yaml down
artifacts:
paths:
- ./.cov
expire_in: 1 week
when: always
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
sast-filesystem:
<<: *trivy-fs-scan
@@ -217,8 +186,43 @@ build-migrations:
CONTAINERFILE: Containerfile
BUILDTARGET: migrations
run-tests:
<<: *test-config
test-e2e:
<<: *docker-job
stage: test
variables:
COMPOSE_PROFILES: |
--profile migrations
--profile tests
script:
- export PROFILES="$(printf '%s ' $COMPOSE_PROFILES)"
- apk add --no-cache docker-compose
- |
REGISTRY_PREFIX=$CI_REGISTRY_IMAGE \
docker compose -f compose.yaml -f compose.prod.yaml \
$PROFILES up -d -y --quiet-pull --quiet-build
- |
TEST_CONTAINER_ID=$(docker compose $PROFILES ps -q tests -a)
timeout 600 docker wait $TEST_CONTAINER_ID
TEST_EXIT_CODE=$(docker inspect --format "{{.State.ExitCode}}" $TEST_CONTAINER_ID)
if [ $TEST_EXIT_CODE -eq 0 ]; then
echo "Tests passed."
else
echo "Tests failed with exit code $TEST_EXIT_CODE."
exit 1
fi
- docker compose $PROFILES logs --no-color > compose.log
- |
docker compose -f compose.yaml -f compose.prod.yaml down
artifacts:
paths:
- ./.cov
- ./compose.log
expire_in: 1 week
when: always
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
dependencies:
- build-runtime
- build-tests
+3 -5
View File
@@ -74,12 +74,10 @@ lints-run:
[group("Migrations")]
[doc("Запуск миграции")]
migrations-run tag="head":
docker compose run --remove-orphans migrations alembic upgrade {{tag}}
docker compose down postgresql
CONFIGURATION_PATH=config.toml alembic upgrade {{tag}}
[no-cd]
[group("Migrations")]
[doc('Создание миграции')]
migrations-make message:
docker compose run migrations alembic revision --autogenerate -m "{{message}}"
docker compose down postgresql
migrations-make message="":
CONFIGURATION_PATH=config.toml alembic revision --autogenerate -m "{{message}}"
+1 -1
View File
@@ -71,7 +71,7 @@ RUN uv sync --group tests --frozen --no-cache
RUN mkdir -p /app/cov
CMD [ "sh", "-c", "coverage run --source=src -m pytest -v && coverage report && coverage xml -o /app/cov/coverage.xml" ]
CMD [ "sh", "-c", "coverage run --source=src -m pytest -v && coverage report > /app/cov/coverage.txt && coverage json -o /app/cov/coverage.xml && coverage html -o /app/cov/coverage.html" ]
# Stage 4: Migrations
+1 -1
View File
@@ -4,7 +4,7 @@ port = 8080
access_log = true
[database]
url = "postgresql+psycopg://username:password@host:post/database"
url = "postgresql+psycopg://username:password@host:port/database"
[access_token]
crypto_key = "..."