Добавить .github/workflows/tests.yaml

This commit is contained in:
2025-05-12 11:43:05 +00:00
parent f1c36e676e
commit 67a8f5c023

103
.github/workflows/tests.yaml vendored Normal file
View File

@@ -0,0 +1,103 @@
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 }}
GITEA_URL: ${{ secrets.GITEAURL }}
PRBOT_USERNAME: ${{ secrets.ACCOUNT_NAME }}
PRBOT_TOKEN: ${{ secrets.GITHUBTOKEN }}
GITHUB_REPOSITORY: ${{ secrets.REPOSITORY }}
PR_NUMBER: ${{ github.event.pull_request.number }}
steps:
- 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 . --output-format=github --preview | 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 "::notice::Starting Pytest for file: $test_file"
echo "::notice::(pytest файла \"$test_file\")" >> /tmp/test_output.txt
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