Compare commits
134 Commits
test6
...
new_notify
| Author | SHA1 | Date | |
|---|---|---|---|
| f0f354a8d4 | |||
| 8864f9585e | |||
| b7fb2ed335 | |||
| 760b6a8257 | |||
| d7bae2b72f | |||
| 2e4141834e | |||
| 4576ab5751 | |||
| 5114bcf9fe | |||
| a6877dda7e | |||
| 6d04254346 | |||
| 50c5bc458a | |||
| 31eccd5c09 | |||
| a0f83b72d1 | |||
| fc1da26055 | |||
| 8689d0d108 | |||
| 86934c05e8 | |||
| 52f6139528 | |||
| de7b8c7d7f | |||
| 1fdc459c07 | |||
| 57998e19a9 | |||
| 9c829b3543 | |||
| 6c1d7a9176 | |||
| 23c6930c11 | |||
| f1e3fc9bae | |||
| bac7e0abb3 | |||
| f816482983 | |||
| 2e1a74b96c | |||
| 2daf21ea55 | |||
| 2d6aa07554 | |||
| 9aeb793f01 | |||
| 30764b992f | |||
| e88e4ea301 | |||
| 1f046574b5 | |||
| a11bec63b9 | |||
| 7356e38489 | |||
| 68a19a3df7 | |||
| 67647fb4dd | |||
| dc07d5d072 | |||
| 3a09c44958 | |||
| abde7da623 | |||
| 5f90f6f544 | |||
| b09c683175 | |||
| 321d04ed3d | |||
| 630d1767b1 | |||
| b827427591 | |||
| 59d50a60ed | |||
| 5bf1f99e2e | |||
| 1aba1d5df0 | |||
| 56927923ad | |||
| 3ad43d0a1d | |||
| 433faca4b8 | |||
| 67b06db4ed | |||
| e1d609741a | |||
| 6df55bdba6 | |||
| ccdccf017d | |||
| 6f45d23dcf | |||
| c5f51b48ae | |||
| 3738ebbf5a | |||
| 15a1443b9a | |||
| 3d8578c9a2 | |||
| fa2c1e58e9 | |||
| dbabf774c0 | |||
| f50569e257 | |||
| acbcb78390 | |||
| 4e2494a6a1 | |||
| b85e4f9798 | |||
| 479433991c | |||
| 5a2fa01284 | |||
| 42891a309a | |||
| e76a3eb00c | |||
| aacefe062d | |||
| 40b367814b | |||
| 9c7d5abfa3 | |||
| 409baf7d02 | |||
| 7c01158b57 | |||
| 5442db2509 | |||
| 591cf8313a | |||
| aa879e978c | |||
| 4db88c6d1b | |||
| c244186429 | |||
| febd2373d3 | |||
| 648d048439 | |||
| a892574942 | |||
| 9bd73a8611 | |||
| 585585106a | |||
| b2ea6c295f | |||
| 76a1b3c739 | |||
| 3d653b0627 | |||
| 494d1826e2 | |||
| 0c92cb1c0f | |||
| 2c6048860e | |||
| 88b43a1bf3 | |||
| 7ec2c32072 | |||
| 688c0b02cb | |||
| 11c0e09b2b | |||
| 62e29edb81 | |||
| 045e0e1127 | |||
| a69a34ddec | |||
| e846abffba | |||
| 4ae633017a | |||
| 69b76b4b56 | |||
| 12cf195c0b | |||
| f988b0d49c | |||
| cb5d1652a3 | |||
| 2d988f683e | |||
| 3fd05f9744 | |||
| 4b4f23fe19 | |||
| d617b37876 | |||
| 59a26018af | |||
| ca81df01cc | |||
| 8b6a2591e5 | |||
| 247c259580 | |||
| 2e82af57de | |||
| 93a2c05c68 | |||
| 11e31a8d84 | |||
| 5e878c74c5 | |||
| 022140608a | |||
| cdc65c56c7 | |||
| ee21d2a83e | |||
| 3f7d7f3e7a | |||
| ef90927312 | |||
| 8c7b4b5b1b | |||
| ac8829e417 | |||
| 44a12848a4 | |||
| 314dc872cc | |||
| 91eac576a5 | |||
| eb3206bbfc | |||
| fff78aa6b2 | |||
| f5787b5a9f | |||
| 16231c1d55 | |||
| 98511aaa46 | |||
| 1bd7e2c7ab | |||
| 070fa3c928 | |||
| 71c68f7533 |
@@ -21,38 +21,38 @@ runs:
|
|||||||
- name: Argo Login
|
- name: Argo Login
|
||||||
uses: clowdhaus/argo-cd-action/@main
|
uses: clowdhaus/argo-cd-action/@main
|
||||||
with:
|
with:
|
||||||
version: 2.13.3
|
version: 3.1.3
|
||||||
command: login
|
command: login
|
||||||
options: ${{ vars.ARGO_HOST }} --username ${{ vars.ARGO_USER }} --password ${{ fromJSON(inputs.secrets).ARGO_PASSWORD }}
|
options: ${{ vars.ARGO_HOST }} --username ${{ vars.ARGO_USER }} --password ${{ fromJSON(inputs.secrets).ARGO_PASSWORD }}
|
||||||
- name: Change tag name
|
- name: Change tag name
|
||||||
uses: clowdhaus/argo-cd-action/@main
|
uses: clowdhaus/argo-cd-action/@main
|
||||||
with:
|
with:
|
||||||
version: 2.13.3
|
version: 3.1.3
|
||||||
command: app set ${{ inputs.environment }} --parameter images.${{github.event.repository.name}}=${{ inputs.tag }}
|
command: app set ${{ inputs.environment }} --parameter images.${{github.event.repository.name}}=${{ inputs.tag }}
|
||||||
- name: Sync changes
|
- name: Sync changes
|
||||||
if: ${{ inputs.migrate == 'true' }}
|
if: ${{ inputs.migrate == 'true' }}
|
||||||
uses: clowdhaus/argo-cd-action/@main
|
uses: clowdhaus/argo-cd-action/@main
|
||||||
with:
|
with:
|
||||||
version: 2.13.3
|
version: 3.1.3
|
||||||
command: app sync ${{ inputs.environment }} --resource apps:Deployment:${{github.event.repository.name}}
|
command: app sync ${{ inputs.environment }} --resource apps:Deployment:${{github.event.repository.name}}
|
||||||
- name: Migrate
|
- name: Migrate
|
||||||
if: ${{ inputs.migrate == 'true' }}
|
if: ${{ inputs.migrate == 'true' }}
|
||||||
uses: clowdhaus/argo-cd-action/@main
|
uses: clowdhaus/argo-cd-action/@main
|
||||||
with:
|
with:
|
||||||
version: 2.13.3
|
version: 3.1.3
|
||||||
command: app actions run ${{ inputs.environment }} migrate --kind Deployment --resource-name ${{github.event.repository.name}}
|
command: app actions run ${{ inputs.environment }} migrate --kind Deployment --resource-name ${{github.event.repository.name}}
|
||||||
- name: Sync changes
|
- name: Sync changes
|
||||||
uses: clowdhaus/argo-cd-action/@main
|
uses: clowdhaus/argo-cd-action/@main
|
||||||
with:
|
with:
|
||||||
version: 2.13.3
|
version: 3.1.3
|
||||||
command: app sync ${{ inputs.environment }} --resource 'apps:Deployment:*'
|
command: app sync ${{ inputs.environment }} --resource 'apps:Deployment:*'
|
||||||
- name: Refresh secret
|
- name: Refresh secret
|
||||||
uses: clowdhaus/argo-cd-action/@main
|
uses: clowdhaus/argo-cd-action/@main
|
||||||
with:
|
with:
|
||||||
version: 2.13.3
|
version: 3.1.3
|
||||||
command: app actions run ${{ inputs.environment }} refresh --kind ExternalSecret --resource-name vault-${{github.event.repository.name}}
|
command: app actions run ${{ inputs.environment }} refresh --kind ExternalSecret --resource-name vault-${{github.event.repository.name}}
|
||||||
- name: Restart service
|
- name: Restart service
|
||||||
uses: clowdhaus/argo-cd-action/@main
|
uses: clowdhaus/argo-cd-action/@main
|
||||||
with:
|
with:
|
||||||
version: 2.13.3
|
version: 3.1.3
|
||||||
command: app actions run ${{ inputs.environment }} restart --kind Deployment --resource-name ${{github.event.repository.name}}
|
command: app actions run ${{ inputs.environment }} restart --kind Deployment --resource-name ${{github.event.repository.name}}
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
name: 'notify'
|
|
||||||
description: 'notify'
|
|
||||||
|
|
||||||
inputs:
|
|
||||||
result:
|
|
||||||
required: false
|
|
||||||
default: "failure"
|
|
||||||
type: string
|
|
||||||
name:
|
|
||||||
required: false
|
|
||||||
type: string
|
|
||||||
default: build
|
|
||||||
secrets:
|
|
||||||
required: false
|
|
||||||
type: string
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: 'composite'
|
|
||||||
steps:
|
|
||||||
- uses: mattermost/action-mattermost-notify@master
|
|
||||||
env:
|
|
||||||
icons: '{"success" : ":white_check_mark:", "failure": ":x:", "canceled": ":facepalm:", "started": ":warning:"}'
|
|
||||||
with:
|
|
||||||
MATTERMOST_WEBHOOK_URL: ${{ fromJSON(inputs.secrets).MM_WEBHOOK_URL }}
|
|
||||||
PAYLOAD: |
|
|
||||||
{
|
|
||||||
"text": "${{ github.repository }} [${{inputs.name}}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_number }}) was ${{ inputs.result }} by ${{ github.event.sender.login}} ${{ fromJson(env.icons)[inputs.result]}}"
|
|
||||||
}
|
|
||||||
60
.gitea/actions/vk-notify/action.yaml
Normal file
60
.gitea/actions/vk-notify/action.yaml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
name: 'notify'
|
||||||
|
description: 'Send VK Teams notification'
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
result:
|
||||||
|
required: false
|
||||||
|
default: "failure"
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: build
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
steps:
|
||||||
|
- name: Resolve token/from env if missing
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ -z "${{ inputs.token }}" ] && [ -n "${VK_TEAMS_BOT_TOKEN}" ]; then
|
||||||
|
echo "token=${VK_TEAMS_BOT_TOKEN}" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
if [ -z "${{ inputs.to }}" ] && [ -n "${VK_TEAMS_CHAT_ID}" ]; then
|
||||||
|
echo "to=${VK_TEAMS_CHAT_ID}" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Set icon
|
||||||
|
id: icon
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
case "${{ inputs.result }}" in
|
||||||
|
success) echo "ICON=✅" >> $GITHUB_ENV ;;
|
||||||
|
failure) echo "ICON=❌" >> $GITHUB_ENV ;;
|
||||||
|
canceled) echo "ICON=🤦" >> $GITHUB_ENV ;;
|
||||||
|
started) echo "ICON=⚠️" >> $GITHUB_ENV ;;
|
||||||
|
*) echo "ICON=ℹ️" >> $GITHUB_ENV ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
- name: Notify VK Teams (native)
|
||||||
|
if: always()
|
||||||
|
shell: bash
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
echo "[DEBUG] Sending VK Teams notification..."
|
||||||
|
curl -G "https://myteam.mail.ru/bot/v1/messages/sendText" \
|
||||||
|
--data-urlencode "token=${{ env.token }}" \
|
||||||
|
--data-urlencode "chatId=${{ env.to }}" \
|
||||||
|
--data-urlencode "parseMode=MarkdownV2" \
|
||||||
|
--data-urlencode "text=*${{ github.repository }}* - [${{ inputs.name }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_number }}) was *${{ inputs.result }}* by ${{ github.event.sender.login }} ${{ env.ICON }}"
|
||||||
|
|
||||||
|
CODE=$?
|
||||||
|
if [ $CODE -ne 0 ]; then
|
||||||
|
echo "[WARN] VK Teams notification failed with exit code $CODE"
|
||||||
|
else
|
||||||
|
echo "[INFO] VK Teams notification sent successfully"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Делаем паузу, чтобы убедиться, что сообщение дошло
|
||||||
|
echo "[DEBUG] Sleeping 5s to ensure delivery..."
|
||||||
|
sleep 5
|
||||||
101
.github/workflows/all_test2.yaml
vendored
101
.github/workflows/all_test2.yaml
vendored
@@ -1,101 +0,0 @@
|
|||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
inputs:
|
|
||||||
tag:
|
|
||||||
description: 'Tag for registry'
|
|
||||||
type: string
|
|
||||||
default: latest
|
|
||||||
force_build:
|
|
||||||
type: boolean
|
|
||||||
description: force_build
|
|
||||||
default: false
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
tests:
|
|
||||||
runs-on: gpu
|
|
||||||
env:
|
|
||||||
effective_tag: ${{ inputs.tag || github.head_ref || github.ref_name }}
|
|
||||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@master
|
|
||||||
|
|
||||||
- name: Login to Yandex Cloud
|
|
||||||
uses: yc-actions/yc-cr-login@v2
|
|
||||||
with:
|
|
||||||
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
|
|
||||||
|
|
||||||
- name: Send PRBot feedback
|
|
||||||
uses: imgurbot12/prbot@v2
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.ACCOUNT_NAME }}
|
|
||||||
api_token: ${{ secrets.GITHUBTOKEN }}
|
|
||||||
|
|
||||||
- name: Prepare prbot_data directory
|
|
||||||
run: mkdir -p /home/runner/prbot_data && chmod -R 777 /home/runner/prbot_data
|
|
||||||
|
|
||||||
- name: Ruff format check (strict)
|
|
||||||
run: |
|
|
||||||
echo "Starting Ruff format check with tag: ${{ env.effective_tag }}"
|
|
||||||
|
|
||||||
docker run --rm \
|
|
||||||
-v /home/runner/prbot_data:/tmp \
|
|
||||||
cr.yandex/crp8vh46gd976oq8ipla/${{ github.event.repository.name }}:${{ env.effective_tag }} \
|
|
||||||
bash -c '
|
|
||||||
pip install ruff
|
|
||||||
cd /server
|
|
||||||
echo "=== Ruff format check ==="
|
|
||||||
ruff format . --check
|
|
||||||
' \
|
|
||||||
| tee /home/runner/prbot_data/full_output.txt | prbot
|
|
||||||
|
|
||||||
echo "=== Format Output ==="
|
|
||||||
cat /home/runner/prbot_data/full_output.txt
|
|
||||||
|
|
||||||
- name: Run Docker with output redirection
|
|
||||||
run: |
|
|
||||||
docker run --rm \
|
|
||||||
-v /home/runner/prbot_data:/tmp \
|
|
||||||
cr.yandex/crp8vh46gd976oq8ipla/${{ github.event.repository.name }}:${{ env.effective_tag }} \
|
|
||||||
bash -c '
|
|
||||||
pip install ruff pytest pytest-github-actions-annotate-failures
|
|
||||||
echo "=== Ruff ==="
|
|
||||||
cd /server && ruff check . | sed "s|/server/||g" || true
|
|
||||||
' \
|
|
||||||
| tee /home/runner/prbot_data/full_output.txt | prbot
|
|
||||||
|
|
||||||
echo "=== Full Output ==="
|
|
||||||
cat /home/runner/prbot_data/full_output.txt
|
|
||||||
|
|
||||||
- name: Pytest individual files + PRBot formatting
|
|
||||||
run: |
|
|
||||||
docker run --rm \
|
|
||||||
-v /home/runner/prbot_data:/tmp \
|
|
||||||
cr.yandex/crp8vh46gd976oq8ipla/${{ github.event.repository.name }}:${{ env.effective_tag }} \
|
|
||||||
bash -c '
|
|
||||||
pip install pytest pytest-github-actions-annotate-failures
|
|
||||||
|
|
||||||
cd /server
|
|
||||||
|
|
||||||
echo "=== Running Pytest Files Individually ==="
|
|
||||||
|
|
||||||
find . -name "test_*.py" | sort | while read -r test_file; do
|
|
||||||
echo "Starting Pytest for file: $test_file"
|
|
||||||
|
|
||||||
pytest -v -W always "$test_file" --capture=no --annotate-failures 2>&1 | tee -a /tmp/test_output.txt
|
|
||||||
|
|
||||||
echo "" >> /tmp/test_output.txt
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "=== Formatting Output for PRBot ==="
|
|
||||||
> /tmp/prbot_output.txt
|
|
||||||
' \
|
|
||||||
| tee /home/runner/prbot_data/full_output.txt | prbot
|
|
||||||
|
|
||||||
echo " === Pytest raw output ==="
|
|
||||||
cat /home/runner/prbot_data/full_output.txt || echo "::warning::full_output.txt not found!"
|
|
||||||
|
|
||||||
- name: Commit PRBot feedback
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
prbot commit
|
|
||||||
171
.github/workflows/all_test3.yaml
vendored
171
.github/workflows/all_test3.yaml
vendored
@@ -1,171 +0,0 @@
|
|||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
inputs:
|
|
||||||
tag:
|
|
||||||
description: 'Tag for registry'
|
|
||||||
type: string
|
|
||||||
default: latest
|
|
||||||
force_build:
|
|
||||||
type: boolean
|
|
||||||
description: force_build
|
|
||||||
default: false
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
tests:
|
|
||||||
runs-on: gpu
|
|
||||||
env:
|
|
||||||
effective_tag: ${{ inputs.tag || github.head_ref || github.ref_name }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@master
|
|
||||||
|
|
||||||
- name: Extract Postgres container env vars from Compose
|
|
||||||
run: |
|
|
||||||
POSTGRES_CONTAINER=$(awk '/postgres/{f=1} f && /container_name:/ {print $2; exit}' docker-compose-dev.yaml)
|
|
||||||
POSTGRES_USER=$(awk '/postgres/{f=1} f && /POSTGRES_USER:/ {print $2; exit}' docker-compose-dev.yaml)
|
|
||||||
POSTGRES_DB=$(awk '/postgres/{f=1} f && /POSTGRES_DB:/ {print $2; exit}' docker-compose-dev.yaml)
|
|
||||||
echo "Found container: $POSTGRES_CONTAINER"
|
|
||||||
echo "DB: $POSTGRES_DB, USER: $POSTGRES_USER"
|
|
||||||
echo "POSTGRES_CONTAINER=$POSTGRES_CONTAINER" >> $GITHUB_ENV
|
|
||||||
echo "POSTGRES_USER=$POSTGRES_USER" >> $GITHUB_ENV
|
|
||||||
echo "POSTGRES_DB=$POSTGRES_DB" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Login to Yandex Cloud
|
|
||||||
uses: yc-actions/yc-cr-login@v2
|
|
||||||
with:
|
|
||||||
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
|
|
||||||
|
|
||||||
- name: Send PRBot feedback
|
|
||||||
uses: imgurbot12/prbot@v2
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.ACCOUNT_NAME }}
|
|
||||||
api_token: ${{ secrets.GITHUBTOKEN }}
|
|
||||||
|
|
||||||
- name: Prepare prbot_data directory
|
|
||||||
run: mkdir -p /home/runner/prbot_data && chmod -R 777 /home/runner/prbot_data
|
|
||||||
|
|
||||||
- name: Pull Docker image explicitly
|
|
||||||
run: |
|
|
||||||
docker pull cr.yandex/crp8vh46gd976oq8ipla/${{ github.event.repository.name }}:${{ env.effective_tag }}
|
|
||||||
|
|
||||||
- name: Setup SSH access to Gitea
|
|
||||||
run: |
|
|
||||||
mkdir -p ~/.ssh
|
|
||||||
echo "${{ secrets.GITEASSH }}" | base64 -d > ~/.ssh/id_rsa
|
|
||||||
chmod 600 ~/.ssh/id_rsa
|
|
||||||
ssh-keyscan -H bb.hublab.ru >> ~/.ssh/known_hosts
|
|
||||||
eval "$(ssh-agent -s)"
|
|
||||||
ssh-add ~/.ssh/id_rsa
|
|
||||||
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
#На случай зависших сервисов
|
|
||||||
- name: Clean up existing Docker Compose services (if any)
|
|
||||||
run: |
|
|
||||||
docker compose -f docker-compose-dev.yaml down || true
|
|
||||||
|
|
||||||
- name: Start docker-compose services
|
|
||||||
env:
|
|
||||||
DOCKER_BUILDKIT: 1
|
|
||||||
SSH_AUTH_SOCK: ${{ env.SSH_AUTH_SOCK }}
|
|
||||||
run: |
|
|
||||||
docker compose -f docker-compose-dev.yaml up -d
|
|
||||||
|
|
||||||
- name: Ruff format check (strict)
|
|
||||||
run: |
|
|
||||||
echo "Starting Ruff format check with tag: ${{ env.effective_tag }}"
|
|
||||||
|
|
||||||
docker run --rm \
|
|
||||||
-v /home/runner/prbot_data:/tmp \
|
|
||||||
cr.yandex/crp8vh46gd976oq8ipla/${{ github.event.repository.name }}:${{ env.effective_tag }} \
|
|
||||||
bash -c '
|
|
||||||
pip install ruff
|
|
||||||
cd /server
|
|
||||||
echo "=== Ruff format check ==="
|
|
||||||
ruff format . --check
|
|
||||||
' \
|
|
||||||
| tee /home/runner/prbot_data/full_output.txt | prbot
|
|
||||||
|
|
||||||
echo "=== Format Output ==="
|
|
||||||
cat /home/runner/prbot_data/full_output.txt
|
|
||||||
|
|
||||||
- name: Run Docker with output redirection
|
|
||||||
run: |
|
|
||||||
docker run --rm \
|
|
||||||
-v /home/runner/prbot_data:/tmp \
|
|
||||||
cr.yandex/crp8vh46gd976oq8ipla/${{ github.event.repository.name }}:${{ env.effective_tag }} \
|
|
||||||
bash -c '
|
|
||||||
pip install ruff pytest pytest-github-actions-annotate-failures
|
|
||||||
echo "=== Ruff ==="
|
|
||||||
cd /server && ruff check . | sed "s|/server/||g" || true
|
|
||||||
' \
|
|
||||||
| tee /home/runner/prbot_data/full_output.txt | prbot
|
|
||||||
|
|
||||||
echo "=== Full Output ==="
|
|
||||||
cat /home/runner/prbot_data/full_output.txt
|
|
||||||
|
|
||||||
- name: Create database
|
|
||||||
run: |
|
|
||||||
docker exec "$POSTGRES_CONTAINER" bash -c 'psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "DROP DATABASE IF EXISTS test"'
|
|
||||||
docker exec "$POSTGRES_CONTAINER" bash -c 'psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE DATABASE test"'
|
|
||||||
|
|
||||||
- name: Pytest inside other container via docker exec from main test container
|
|
||||||
run: |
|
|
||||||
docker run --rm \
|
|
||||||
--network hub-network \
|
|
||||||
-v /home/runner/prbot_data:/tmp \
|
|
||||||
-e GITEASSH="$(echo "${{ secrets.GITEASSH }}" | tr -d '\n')" \
|
|
||||||
cr.yandex/crp8vh46gd976oq8ipla/${{ github.event.repository.name }}:${{ env.effective_tag }} \
|
|
||||||
bash -c '
|
|
||||||
echo "📁 Listing contents of /server:"
|
|
||||||
ls -lah /server || echo "❌ /server not found"
|
|
||||||
|
|
||||||
mkdir -p ~/.ssh
|
|
||||||
echo "$GITEASSH" | base64 -d > ~/.ssh/id_rsa
|
|
||||||
chmod 600 ~/.ssh/id_rsa
|
|
||||||
ssh-keyscan -H bb.hublab.ru >> ~/.ssh/known_hosts
|
|
||||||
eval "$(ssh-agent -s)"
|
|
||||||
ssh-add ~/.ssh/id_rsa
|
|
||||||
|
|
||||||
echo "📁 Listing contents of /server SECOND:"
|
|
||||||
ls -lah /server || echo "❌ /server not found"
|
|
||||||
|
|
||||||
echo "🔧 Copying test config"
|
|
||||||
cp config-tests-example.yaml config.yaml
|
|
||||||
cp config-tests-example.yaml config-tests.yaml
|
|
||||||
|
|
||||||
echo "🔧 Listing contents of test config"
|
|
||||||
ls -lah || echo "❌ /server not found"
|
|
||||||
|
|
||||||
echo "🚀 Creating virtual environment..."
|
|
||||||
python3 -m venv .venv && \
|
|
||||||
source .venv/bin/activate && \
|
|
||||||
echo "✅ Virtual environment activated."
|
|
||||||
|
|
||||||
echo "📦 Installing requirements from requirements-dev.txt"
|
|
||||||
pip install --upgrade pip && \
|
|
||||||
pip install -r /server/requirements-dev.txt && \
|
|
||||||
pip install pytest
|
|
||||||
pip install pytest-github-actions-annotate-failures
|
|
||||||
|
|
||||||
echo "🔍 Searching for test files and running them individually"
|
|
||||||
pytest -v -W always --capture=no \
|
|
||||||
2>&1 | tee /tmp/test_output.txt
|
|
||||||
|
|
||||||
echo "📄 Copying results to PRBot output"
|
|
||||||
cat /tmp/test_output.txt > /tmp/prbot_output.txt
|
|
||||||
'
|
|
||||||
|
|
||||||
- name: Commit PRBot feedback
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
prbot commit
|
|
||||||
|
|
||||||
- name: Stop docker-compose services
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
docker compose -f docker-compose-dev.yaml down
|
|
||||||
|
|
||||||
- name: Cleanup SSH key
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
rm -f ~/.ssh/id_rsa ~/.ssh/id_rsa.pub
|
|
||||||
137
.github/workflows/build.yaml
vendored
137
.github/workflows/build.yaml
vendored
@@ -11,7 +11,14 @@ on:
|
|||||||
force_build:
|
force_build:
|
||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
|
arch:
|
||||||
|
type: string
|
||||||
|
default: "linux/amd64,linux/arm64/v8"
|
||||||
|
secrets:
|
||||||
|
VK_TEAMS_BOT_TOKEN:
|
||||||
|
required: true
|
||||||
|
VK_TEAMS_CHAT_ID:
|
||||||
|
required: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -20,52 +27,102 @@ jobs:
|
|||||||
CR_REGISTRY: crp8vh46gd976oq8ipla
|
CR_REGISTRY: crp8vh46gd976oq8ipla
|
||||||
CR_REPO: ${{ github.event.repository.name }}
|
CR_REPO: ${{ github.event.repository.name }}
|
||||||
IMAGE_TAG: ${{ github.sha }}
|
IMAGE_TAG: ${{ github.sha }}
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@master
|
|
||||||
- name: Checkout LFS
|
|
||||||
if: ${{ inputs.lfs }}
|
|
||||||
run: |
|
|
||||||
UrlBase=$GITHUB_SERVER_URL; \
|
|
||||||
UrlLfsBase=$UrlBase/${{ github.repository }}.git/info/lfs/objects; \
|
|
||||||
Auth=`/usr/bin/git config --get --local http.$UrlBase/.extraheader`; \
|
|
||||||
/usr/bin/git config --local http.${UrlLfsBase}/batch.extraheader "$Auth"; \
|
|
||||||
/usr/bin/git config --local http.${UrlLfsBase}/.extraheader ''
|
|
||||||
|
|
||||||
git config --local lfs.transfer.maxretries 1
|
steps:
|
||||||
git ls-remote
|
- name: Notify (started)
|
||||||
git lfs checkout
|
uses: https://bb.hublab.ru/HUB/workflows/.gitea/actions/vk-notify@main
|
||||||
git lfs fetch
|
env:
|
||||||
git lfs pull
|
VK_TEAMS_BOT_TOKEN: ${{ secrets.VK_TEAMS_BOT_TOKEN }}
|
||||||
#git lfs fetch origin refs/heads/${{ github.head_ref || github.ref_name }}
|
VK_TEAMS_CHAT_ID: ${{ secrets.VK_TEAMS_CHAT_ID }}
|
||||||
|
with:
|
||||||
|
result: started
|
||||||
|
name: build tag ${{ inputs.tag }}
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
lfs: ${{ inputs.lfs }}
|
||||||
|
|
||||||
- name: Use ssh key
|
- name: Use ssh key
|
||||||
uses: webfactory/ssh-agent@v0.9.0
|
uses: webfactory/ssh-agent@v0.9.0
|
||||||
with:
|
with:
|
||||||
ssh-private-key: |
|
ssh-private-key: |
|
||||||
${{ secrets.LIB_SSH_KEY }}
|
${{ secrets.LIB_SSH_KEY }}
|
||||||
${{ secrets.LIB_NEW_SSH_KEY }}
|
${{ secrets.LIB_NEW_SSH_KEY }}
|
||||||
- name: Build Docker image
|
|
||||||
run: |
|
|
||||||
if [ "$NO_CACHE" == "true" ]; then
|
|
||||||
docker build -t cr.yandex/$CR_REGISTRY/$CR_REPO:${IMAGE_TAG::7} --no-cache --ssh default .
|
|
||||||
else
|
|
||||||
docker build -t cr.yandex/$CR_REGISTRY/$CR_REPO:${IMAGE_TAG::7} --ssh default .
|
|
||||||
fi
|
|
||||||
env:
|
|
||||||
NO_CACHE: ${{ inputs.force_build || 'false' }}
|
|
||||||
- name: Yandex Cloud Login
|
- name: Yandex Cloud Login
|
||||||
uses: yc-actions/yc-cr-login@v2
|
uses: yc-actions/yc-cr-login@v2
|
||||||
with:
|
with:
|
||||||
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
|
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
|
||||||
- name: Tag image
|
|
||||||
env:
|
- name: Set up Docker Buildx
|
||||||
INPUT_TAG: ${{ inputs.tag }}
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
install: true
|
||||||
|
|
||||||
|
- name: Shorten commit SHA
|
||||||
|
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Normalize tag
|
||||||
|
id: normalize
|
||||||
run: |
|
run: |
|
||||||
echo ${INPUT_TAG/\//-} ${IMAGE_TAG::7} $INPUT_TAG $IMAGE_TAG
|
SAFE_TAG=$(echo "${{ inputs.tag }}" | tr '/' '-')
|
||||||
docker tag cr.yandex/$CR_REGISTRY/$CR_REPO:${IMAGE_TAG::7} cr.yandex/$CR_REGISTRY/$CR_REPO:${INPUT_TAG/\//-}
|
echo "SAFE_TAG=$SAFE_TAG" >> $GITHUB_ENV
|
||||||
- name: Push image
|
|
||||||
env:
|
- name: Restore Docker layer cache
|
||||||
INPUT_TAG: ${{ inputs.tag }}
|
uses: actions/cache/restore@v4
|
||||||
|
with:
|
||||||
|
path: /cache/${{ github.repository }}/buildx-cache
|
||||||
|
key: ${{ runner.os }}-${{ github.repository }}-buildx-${{ hashFiles(format('{0}/Dockerfile', github.workspace), format('{0}/**/requirements.txt', github.workspace), format('{0}/**/*lock*', github.workspace), format('{0}/**/package-lock.json', github.workspace), format('{0}/**/poetry.lock', github.workspace)) }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-${{ github.repository }}-buildx-
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
|
|
||||||
|
- name: Build and push multi-arch image
|
||||||
|
id: build-step
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
context: .
|
||||||
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
|
tags: |
|
||||||
|
cr.yandex/${{ env.CR_REGISTRY }}/${{ env.CR_REPO }}:${{ env.SHORT_SHA }}
|
||||||
|
cr.yandex/${{ env.CR_REGISTRY }}/${{ env.CR_REPO }}:${{ env.SAFE_TAG }}
|
||||||
|
platforms: ${{ inputs.arch }}
|
||||||
|
ssh: default
|
||||||
|
no-cache: ${{ inputs.force_build }}
|
||||||
|
build-args: |
|
||||||
|
GIT_COMMIT=${{ github.sha }}
|
||||||
|
cache-from: |
|
||||||
|
type=local,src=/cache/${{ github.repository }}/buildx-cache
|
||||||
|
cache-to: |
|
||||||
|
type=local,dest=/cache/${{ github.repository }}/buildx-cache-new,mode=max
|
||||||
|
|
||||||
|
- name: Move new cache if it exists
|
||||||
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
docker push cr.yandex/$CR_REGISTRY/$CR_REPO:${IMAGE_TAG::7}
|
mkdir -p /cache/${{ github.repository }}
|
||||||
docker push cr.yandex/$CR_REGISTRY/$CR_REPO:${INPUT_TAG/\//-}
|
if [ -d /cache/${{ github.repository }}/buildx-cache-new ]; then
|
||||||
|
echo "Found new buildx cache, replacing old one..."
|
||||||
|
rm -rf /cache/${{ github.repository }}/buildx-cache
|
||||||
|
mv /cache/${{ github.repository }}/buildx-cache-new /cache/${{ github.repository }}/buildx-cache
|
||||||
|
else
|
||||||
|
echo "No new buildx cache found, keeping old one."
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Save Docker layer cache
|
||||||
|
if: always()
|
||||||
|
uses: actions/cache/save@v4
|
||||||
|
with:
|
||||||
|
path: /cache/${{ github.repository }}/buildx-cache
|
||||||
|
key: ${{ runner.os }}-${{ github.repository }}-buildx-${{ hashFiles(format('{0}/Dockerfile', github.workspace), format('{0}/**/requirements.txt', github.workspace), format('{0}/**/*lock*', github.workspace), format('{0}/**/package-lock.json', github.workspace), format('{0}/**/poetry.lock', github.workspace)) }}
|
||||||
|
|
||||||
|
- name: Notify (result)
|
||||||
|
if: always()
|
||||||
|
uses: https://bb.hublab.ru/HUB/workflows/.gitea/actions/vk-notify@main
|
||||||
|
env:
|
||||||
|
VK_TEAMS_BOT_TOKEN: ${{ secrets.VK_TEAMS_BOT_TOKEN }}
|
||||||
|
VK_TEAMS_CHAT_ID: ${{ secrets.VK_TEAMS_CHAT_ID }}
|
||||||
|
with:
|
||||||
|
result: ${{ steps.build-step.outcome }}
|
||||||
|
name: build tag ${{ inputs.tag }}
|
||||||
|
|||||||
10
.github/workflows/deploy.yaml
vendored
10
.github/workflows/deploy.yaml
vendored
@@ -30,17 +30,7 @@ jobs:
|
|||||||
CR_REPO: ${{ github.event.repository.name }}
|
CR_REPO: ${{ github.event.repository.name }}
|
||||||
TAG: ${{ inputs.tag }}
|
TAG: ${{ inputs.tag }}
|
||||||
steps:
|
steps:
|
||||||
- name: deploy
|
|
||||||
if: inputs.environment == 'prod' || inputs.environment == 'demo'
|
|
||||||
uses: https://bb.hublab.ru/HUB/workflows/.gitea/actions/deploy@HEAD
|
|
||||||
with:
|
|
||||||
secrets: ${{ toJSON(secrets) }}
|
|
||||||
environment: ${{ inputs.environment }}
|
|
||||||
tag: ${{ inputs.tag }}
|
|
||||||
migrate: ${{ inputs.migrate }}
|
|
||||||
host: ${{ inputs.host }}
|
|
||||||
- name: deploy k8s
|
- name: deploy k8s
|
||||||
if: inputs.environment == 'stage'
|
|
||||||
uses: https://bb.hublab.ru/HUB/workflows/.gitea/actions/k8s@HEAD
|
uses: https://bb.hublab.ru/HUB/workflows/.gitea/actions/k8s@HEAD
|
||||||
with:
|
with:
|
||||||
secrets: ${{ toJSON(secrets) }}
|
secrets: ${{ toJSON(secrets) }}
|
||||||
|
|||||||
27
.github/workflows/deployk8s.yaml
vendored
27
.github/workflows/deployk8s.yaml
vendored
@@ -24,7 +24,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
if: contains(format(',{0},', vars.ADMIN_USERS), format(',{0},', github.actor)) || inputs.environment=='stage'
|
if: ${{ contains(format(',{0},', vars.ADMIN_USERS), format(',{0},', github.actor)) || startsWith(inputs.environment, 'stage') }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
CR_REGISTRY: crp8vh46gd976oq8ipla
|
CR_REGISTRY: crp8vh46gd976oq8ipla
|
||||||
@@ -32,24 +32,27 @@ jobs:
|
|||||||
TAG: ${{ inputs.tag }}
|
TAG: ${{ inputs.tag }}
|
||||||
steps:
|
steps:
|
||||||
- name: notify
|
- name: notify
|
||||||
uses: https://bb.hublab.ru/HUB/workflows/.gitea/actions/notify@HEAD
|
uses: https://bb.hublab.ru/HUB/workflows/.gitea/actions/vk-notify@main
|
||||||
|
env:
|
||||||
|
VK_TEAMS_BOT_TOKEN: ${{ secrets.VK_TEAMS_BOT_TOKEN }}
|
||||||
|
VK_TEAMS_CHAT_ID: ${{ secrets.VK_TEAMS_CHAT_ID }}
|
||||||
with:
|
with:
|
||||||
result: 'started'
|
result: 'started'
|
||||||
secrets: ${{ toJSON(secrets) }}
|
|
||||||
name: deploy ${{ inputs.environment }} tag ${{ inputs.tag }}
|
name: deploy ${{ inputs.environment }} tag ${{ inputs.tag }}
|
||||||
- name: deploy
|
- name: deploy
|
||||||
|
id: k8s_deploy
|
||||||
uses: https://bb.hublab.ru/HUB/workflows/.gitea/actions/k8s@HEAD
|
uses: https://bb.hublab.ru/HUB/workflows/.gitea/actions/k8s@HEAD
|
||||||
with:
|
with:
|
||||||
secrets: ${{ toJSON(secrets) }}
|
secrets: ${{ toJSON(secrets) }}
|
||||||
environment: ${{ inputs.environment }}
|
environment: ${{ inputs.environment }}
|
||||||
tag: ${{ inputs.tag }}
|
tag: ${{ inputs.tag }}
|
||||||
migrate: ${{ inputs.migrate }}
|
migrate: ${{ inputs.migrate }}
|
||||||
|
- name: post-notify
|
||||||
notify:
|
if: always()
|
||||||
needs: [deploy]
|
uses: https://bb.hublab.ru/HUB/workflows/.gitea/actions/vk-notify@main
|
||||||
if: always()
|
env:
|
||||||
uses: HUB/workflows/.github/workflows/notify.yaml@main
|
VK_TEAMS_BOT_TOKEN: ${{ secrets.VK_TEAMS_BOT_TOKEN }}
|
||||||
with:
|
VK_TEAMS_CHAT_ID: ${{ secrets.VK_TEAMS_CHAT_ID }}
|
||||||
result: ${{ needs.deploy.result}}
|
with:
|
||||||
name: k8s deploy ${{ inputs.environment }} tag ${{ inputs.tag }}
|
result: ${{ steps.k8s_deploy.outcome }}
|
||||||
secrets: inherit
|
name: k8s deploy ${{ inputs.environment }} tag ${{ inputs.tag }}
|
||||||
|
|||||||
20
.github/workflows/notify.yaml
vendored
20
.github/workflows/notify.yaml
vendored
@@ -1,5 +1,3 @@
|
|||||||
env:
|
|
||||||
icons: '{"success" : ":white_check_mark:", "failure": ":x:", "canceled": ":facepalm:", "started": ":warning:", "": ":boxing_glove:"}'
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
@@ -15,11 +13,13 @@ jobs:
|
|||||||
notify:
|
notify:
|
||||||
runs-on: gpu
|
runs-on: gpu
|
||||||
steps:
|
steps:
|
||||||
- uses: mattermost/action-mattermost-notify@master
|
- uses: dosymep/vk-teams-action@v1.0.0
|
||||||
with:
|
env:
|
||||||
MATTERMOST_WEBHOOK_URL: ${{ secrets.MM_WEBHOOK_URL }}
|
ICONS: '{"success":"✅","failure":"❌","canceled":"🤦","started":"⚠️"}'
|
||||||
PAYLOAD: |
|
with:
|
||||||
{
|
token: ${{ secrets.VK_TEAMS_BOT_TOKEN }}
|
||||||
"text": "${{ github.repository }} [${{inputs.name}}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_number }}) was ${{ inputs.result }} by ${{ github.event.sender.login}} ${{ fromJson(env.icons)[inputs.result]}}"
|
to: ${{ secrets.VK_TEAMS_CHAT_ID }}
|
||||||
}
|
format: MarkdownV2
|
||||||
|
message: |
|
||||||
|
${{ github.repository }} \[${{inputs.name}}\]\(${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_number }}\) was ${{ inputs.result }} by ${{ github.event.sender.login }} ${{ fromJson(env.ICONS)[inputs.result] }}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user