From 67a8f5c023ac8eb468d5480940f76ba5b647311f Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 12 May 2025 11:43:05 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20.github/workflows/tests.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yaml | 103 +++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 .github/workflows/tests.yaml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..0b5f8a0 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -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 \ No newline at end of file