You've already forked RekomenciBackend
Merge branch 'main' of https://gitlab.com/prod-hackathon-moscow/hackaton
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# Environment
|
# Environment
|
||||||
./config.toml
|
config.toml
|
||||||
docker-compose.yml
|
docker-compose.yml
|
||||||
.idea
|
.idea
|
||||||
|
|
||||||
|
|||||||
+46
-35
@@ -31,7 +31,7 @@ cache:
|
|||||||
|
|
||||||
.trivy-fs-template: &trivy-fs-scan
|
.trivy-fs-template: &trivy-fs-scan
|
||||||
stage: security
|
stage: security
|
||||||
image:
|
image:
|
||||||
name: aquasec/trivy:latest
|
name: aquasec/trivy:latest
|
||||||
entrypoint: [""]
|
entrypoint: [""]
|
||||||
cache:
|
cache:
|
||||||
@@ -61,7 +61,7 @@ cache:
|
|||||||
|
|
||||||
.trivy-image-template: &trivy-image-scan
|
.trivy-image-template: &trivy-image-scan
|
||||||
stage: security
|
stage: security
|
||||||
image:
|
image:
|
||||||
name: aquasec/trivy:latest
|
name: aquasec/trivy:latest
|
||||||
entrypoint: [""]
|
entrypoint: [""]
|
||||||
cache:
|
cache:
|
||||||
@@ -138,37 +138,6 @@ cache:
|
|||||||
when: manual
|
when: manual
|
||||||
allow_failure: true
|
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:
|
sast-filesystem:
|
||||||
<<: *trivy-fs-scan
|
<<: *trivy-fs-scan
|
||||||
|
|
||||||
@@ -217,8 +186,50 @@ build-migrations:
|
|||||||
CONTAINERFILE: Containerfile
|
CONTAINERFILE: Containerfile
|
||||||
BUILDTARGET: migrations
|
BUILDTARGET: migrations
|
||||||
|
|
||||||
run-tests:
|
test-e2e:
|
||||||
<<: *test-config
|
<<: *docker-job
|
||||||
|
stage: test
|
||||||
|
variables:
|
||||||
|
COMPOSE_PROFILES: |
|
||||||
|
--profile migrations
|
||||||
|
--profile tests
|
||||||
|
script:
|
||||||
|
- export PROFILES="$(printf '%s ' $COMPOSE_PROFILES)"
|
||||||
|
- apk add --no-cache docker-compose
|
||||||
|
- |
|
||||||
|
(
|
||||||
|
while true; do
|
||||||
|
docker compose -f compose.yaml $PROFILES logs -f 2>&1
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
) | tee -a compose.log &
|
||||||
|
- LOGS_PID=$!
|
||||||
|
- |
|
||||||
|
REGISTRY_PREFIX=$CI_REGISTRY_IMAGE \
|
||||||
|
docker compose -f compose.yaml -f compose.prod.yaml \
|
||||||
|
$PROFILES up -d --quiet-pull --quiet-build 2>&1 | tee compose.log
|
||||||
|
- |
|
||||||
|
TEST_CONTAINER_ID=$(docker compose -f compose.yaml $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 -f compose.yaml -f compose.prod.yaml $PROFILES 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:
|
dependencies:
|
||||||
- build-runtime
|
- build-runtime
|
||||||
- build-tests
|
- build-tests
|
||||||
|
|||||||
@@ -74,12 +74,10 @@ lints-run:
|
|||||||
[group("Migrations")]
|
[group("Migrations")]
|
||||||
[doc("Запуск миграции")]
|
[doc("Запуск миграции")]
|
||||||
migrations-run tag="head":
|
migrations-run tag="head":
|
||||||
docker compose run --remove-orphans migrations alembic upgrade {{tag}}
|
CONFIGURATION_PATH=config.toml alembic upgrade {{tag}}
|
||||||
docker compose down postgresql
|
|
||||||
|
|
||||||
[no-cd]
|
[no-cd]
|
||||||
[group("Migrations")]
|
[group("Migrations")]
|
||||||
[doc('Создание миграции')]
|
[doc('Создание миграции')]
|
||||||
migrations-make message:
|
migrations-make message="":
|
||||||
docker compose run migrations alembic revision --autogenerate -m "{{message}}"
|
CONFIGURATION_PATH=config.toml alembic revision --autogenerate -m "{{message}}"
|
||||||
docker compose down postgresql
|
|
||||||
|
|||||||
+1
-1
@@ -71,7 +71,7 @@ RUN uv sync --group tests --frozen --no-cache
|
|||||||
|
|
||||||
RUN mkdir -p /app/cov
|
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
|
# Stage 4: Migrations
|
||||||
|
|||||||
+5
-1
@@ -4,8 +4,12 @@ port = 8080
|
|||||||
access_log = true
|
access_log = true
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
url = "postgresql+psycopg://username:password@host:post/database"
|
url = "postgresql+psycopg://username:password@host:port/database"
|
||||||
|
|
||||||
[access_token]
|
[access_token]
|
||||||
crypto_key = "..."
|
crypto_key = "..."
|
||||||
expires_in = 86400
|
expires_in = 86400
|
||||||
|
|
||||||
|
[yandex_oauth]
|
||||||
|
client_id = "..."
|
||||||
|
client_secret = "..."
|
||||||
|
|||||||
@@ -9,3 +9,7 @@ url = "postgresql+psycopg://postgres:postgres@postgres:5432/postgres"
|
|||||||
[access_token]
|
[access_token]
|
||||||
crypto_key = "insecure_token"
|
crypto_key = "insecure_token"
|
||||||
expires_in = 86400
|
expires_in = 86400
|
||||||
|
|
||||||
|
[yandex_oauth]
|
||||||
|
client_id = "..."
|
||||||
|
client_secret = "..."
|
||||||
|
|||||||
Reference in New Issue
Block a user