From b1fd17dc756a8abd5de80f79882317cc14e78f38 Mon Sep 17 00:00:00 2001 From: Maxim Harder Date: Fri, 25 Jul 2025 19:51:40 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20UPDATE=20=D0=9E=D0=B1?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20GitHub=20Act?= =?UTF-8?q?ions=20=D0=B8=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D1=83?= =?UTF-8?q?=D1=80=D0=B0=D1=86=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Локализация названий и описаний шагов в workflow на русский язык - Улучшение логики определения версии для деплоя документации - Обновление версии actions и инструментов (upload-artifact@v4, setup-python@v4) - Добавление владельцев кода в CODEOWNERS для автоматического ревью - Настройка mkdocs с дополнительными параметрами для git-authors плагина - Корректировка dependabot.yml: смена assignees и удаление reviewers - Локализация сообщений и выводов в security workflow --- .github/CODEOWNERS | 14 ++++++ .github/dependabot.yml | 10 +--- .github/workflows/changelog.yml | 62 +++++++++++------------ .github/workflows/create-labels.yml | 76 +++++++++++++++++++++++++++++ .github/workflows/deploy.yml | 47 +++++++++++++----- .github/workflows/security.yml | 42 ++++++++-------- .github/workflows/update-deps.yml | 48 +++++++++--------- mkdocs.yml | 7 ++- 8 files changed, 209 insertions(+), 97 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/workflows/create-labels.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..a1dd0d4 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,14 @@ +# Владельцы кода глобально +* @Gokujo + +# Документация +docs/ @Gokujo + +# GitHub workflows +.github/ @Gokujo + +# Конфигурационные файлы +*.yml @Gokujo +*.yaml @Gokujo +requirements.txt @Gokujo +mkdocs.yml @Gokujo \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 16f77b8..6092bfc 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,15 +8,12 @@ updates: day: "sunday" time: "02:00" open-pull-requests-limit: 5 - reviewers: - - "DevCraftClub" assignees: - - "DevCraftClub" + - "Gokujo" commit-message: prefix: "chore" include: "scope" labels: - - "dependencies" - "python" ignore: # Игнорируем major версии для критических зависимостей @@ -33,13 +30,10 @@ updates: day: "monday" time: "03:00" open-pull-requests-limit: 3 - reviewers: - - "DevCraftClub" assignees: - - "DevCraftClub" + - "Gokujo" commit-message: prefix: "ci" include: "scope" labels: - - "dependencies" - "github-actions" diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 118e908..66a2f6b 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -1,4 +1,4 @@ -name: Generate Changelog +name: Генерация изменений on: push: @@ -10,12 +10,12 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code + - name: Клонирование кода uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Generate changelog + - name: Генерация изменений id: changelog uses: actions/github-script@v6 with: @@ -27,22 +27,22 @@ jobs: head: context.sha }); - let changelog = '# 📋 Changelog\n\n'; - changelog += `## Version ${context.ref.replace('refs/tags/', '')}\n\n`; - changelog += `**Release Date:** ${new Date().toISOString().split('T')[0]}\n\n`; + let changelog = '# 📋 Журнал изменений\n\n'; + changelog += `## Версия ${context.ref.replace('refs/tags/', '')}\n\n`; + changelog += `**Дата выпуска:** ${new Date().toISOString().split('T')[0]}\n\n`; const categories = { - 'feat': '🚀 Features', - 'fix': '🐛 Bug Fixes', - 'docs': '📚 Documentation', - 'style': '💄 Style', - 'refactor': '♻️ Refactoring', - 'test': '🧪 Tests', - 'chore': '🔧 Chores', + 'feat': '🚀 Функции', + 'fix': '🐛 Исправления багов', + 'docs': '📚 Документация', + 'style': '💄 Стиль', + 'refactor': '♻️ Рефакторинг', + 'test': '🧪 Тесты', + 'chore': '🔧 Обслуживание', 'ci': '⚙️ CI/CD', - 'perf': '⚡ Performance', - 'build': '📦 Build', - 'revert': '⏪ Reverts' + 'perf': '⚡ Производительность', + 'build': '📦 Сборка', + 'revert': '⏪ Откаты' }; const categorizedCommits = {}; @@ -86,36 +86,36 @@ jobs: } // Добавляем статистику - changelog += '## 📊 Statistics\n\n'; - changelog += `- **Total commits:** ${commits.commits.length}\n`; - changelog += `- **Files changed:** ${commits.files ? commits.files.length : 'N/A'}\n`; - changelog += `- **Additions:** ${commits.stats ? commits.stats.additions : 'N/A'}\n`; - changelog += `- **Deletions:** ${commits.stats ? commits.stats.deletions : 'N/A'}\n\n`; + changelog += '## 📊 Статистика\n\n'; + changelog += `- **Всего коммитов:** ${commits.commits.length}\n`; + changelog += `- **Изменено файлов:** ${commits.files ? commits.files.length : 'N/A'}\n`; + changelog += `- **Добавлено строк:** ${commits.stats ? commits.stats.additions : 'N/A'}\n`; + changelog += `- **Удалено строк:** ${commits.stats ? commits.stats.deletions : 'N/A'}\n\n`; // Добавляем ссылки - changelog += '## 🔗 Links\n\n'; - changelog += `- [Full diff](https://github.com/${context.repo.owner}/${context.repo.repo}/compare/main...${context.ref})\n`; - changelog += `- [Documentation](https://devcraftclub.github.io/mhdocs/)\n`; + changelog += '## 🔗 Ссылки\n\n'; + changelog += `- [Полная разница](https://github.com/${context.repo.owner}/${context.repo.repo}/compare/main...${context.ref})\n`; + changelog += `- [Документация](https://devcraftclub.github.io/mhdocs/)\n`; changelog += `- [Readme DevCraft](https://readme.devcraft.club)\n`; core.setOutput('changelog', changelog); - console.log('Generated changelog:', changelog); + console.log('Сгенерирован журнал изменений:', changelog); - - name: Create changelog file + - name: Создание файла изменений run: | echo "${{ steps.changelog.outputs.changelog }}" > CHANGELOG.md - - name: Commit changelog + - name: Коммит изменений run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" git add CHANGELOG.md - git commit -m "docs: update changelog for ${{ github.ref_name }}" || echo "No changes to commit" + git commit -m "docs: обновление журнала изменений для ${{ github.ref_name }}" || echo "Нет изменений для коммита" git push - - name: Upload changelog as artifact - uses: actions/upload-artifact@v3 + - name: Загрузка журнала изменений как артефакт + uses: actions/upload-artifact@v4 with: - name: changelog-${{ github.ref_name }} + name: журнал-изменений-${{ github.ref_name }} path: CHANGELOG.md retention-days: 90 diff --git a/.github/workflows/create-labels.yml b/.github/workflows/create-labels.yml new file mode 100644 index 0000000..3dc63a2 --- /dev/null +++ b/.github/workflows/create-labels.yml @@ -0,0 +1,76 @@ +name: Создание меток репозитория + +on: + workflow_dispatch: # Ручной запуск + push: + branches: [main] + paths: + - ".github/labels.yml" + +jobs: + create-labels: + runs-on: ubuntu-latest + steps: + - name: Клонирование кода + uses: actions/checkout@v4 + + - name: Создание меток + uses: actions/github-script@v6 + with: + script: | + const labels = [ + { + name: 'python', + color: '3776ab', + description: 'Изменения связанные с Python' + }, + { + name: 'github-actions', + color: '2088ff', + description: 'Изменения связанные с GitHub Actions' + }, + { + name: 'documentation', + color: '0075ca', + description: 'Обновления документации' + }, + { + name: 'enhancement', + color: 'a2eeef', + description: 'Новые функции или улучшения' + }, + { + name: 'bug', + color: 'd73a4a', + description: 'Что-то не работает' + }, + { + name: 'help wanted', + color: '008672', + description: 'Требуется дополнительное внимание' + }, + { + name: 'good first issue', + color: '7057ff', + description: 'Подходит для новичков' + } + ]; + + for (const label of labels) { + try { + await github.rest.issues.createLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + name: label.name, + color: label.color, + description: label.description + }); + console.log(`✅ Создана метка: ${label.name}`); + } catch (error) { + if (error.status === 422) { + console.log(`ℹ️ Метка уже существует: ${label.name}`); + } else { + console.log(`❌ Ошибка создания метки ${label.name}:`, error.message); + } + } + } diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d105719..747c6c2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: Deploy Documentation +name: Деплой документации on: push: @@ -11,31 +11,54 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code + - name: Клонирование кода uses: actions/checkout@v4 with: fetch-depth: 0 # Получаем полную историю для git-revision-date плагина - - name: Set up Python + - name: Настройка Python uses: actions/setup-python@v4 with: python-version: "3.13" cache: "pip" - - name: Install dependencies + - name: Установка зависимостей run: | python -m pip install --upgrade pip pip install -r requirements.txt - - name: Build documentation + - name: Определение версии + id: version + run: | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + # Для PR проверяем название на наличие версии + if [[ "${{ github.event.pull_request.title }}" =~ v[0-9]+\.[0-9]+\.[0-9]+ ]]; then + # Извлекаем версию из названия PR + VERSION=$(echo "${{ github.event.pull_request.title }}" | grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+' | head -1) + echo "version=$VERSION" >> $GITHUB_OUTPUT + else + # Если версия не указана, используем dev + echo "version=dev" >> $GITHUB_OUTPUT + fi + else + # Для push в main используем dev + echo "version=dev" >> $GITHUB_OUTPUT + fi + echo "Используется версия: ${{ steps.version.outputs.version }}" + + - name: Сборка документации run: | mkdocs build -c - mkdocs gh-deploy --force - - name: Deploy to GitHub Pages + - name: Деплой с mike if: github.ref == 'refs/heads/main' - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./site - force_orphan: true + run: | + # Настраиваем git для mike + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + # Деплоим с mike + mike deploy --push --update-aliases "${{ steps.version.outputs.version }}" latest + + # Устанавливаем версию по умолчанию + mike set-default --push latest diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index f1aae59..b8fbd2e 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -1,4 +1,4 @@ -name: Security Check +name: Проверка безопасности on: push: @@ -14,50 +14,50 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code + - name: Клонирование кода uses: actions/checkout@v4 - - name: Set up Python + - name: Настройка Python uses: actions/setup-python@v4 with: python-version: "3.11" cache: "pip" - - name: Install dependencies + - name: Установка зависимостей run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install bandit safety - - name: Run Bandit security check + - name: Запуск проверки безопасности Bandit run: | - echo "Running Bandit security check..." + echo "Запуск проверки безопасности Bandit..." bandit -r . -f json -o bandit-report.json || true bandit -r . -f txt -o bandit-report.txt || true # Показываем результаты if [ -f bandit-report.txt ]; then - echo "=== Bandit Security Report ===" + echo "=== Отчет о безопасности Bandit ===" cat bandit-report.txt fi - - name: Check for known vulnerabilities + - name: Проверка известных уязвимостей run: | - echo "Checking for known vulnerabilities..." + echo "Проверка известных уязвимостей..." safety check --json --output safety-report.json || true safety check --output safety-report.txt || true # Показываем результаты if [ -f safety-report.txt ]; then - echo "=== Safety Vulnerability Report ===" + echo "=== Отчет об уязвимостях Safety ===" cat safety-report.txt fi - - name: Upload security reports + - name: Загрузка отчетов безопасности uses: actions/upload-artifact@v4 if: always() with: - name: security-reports + name: отчеты-безопасности path: | bandit-report.json bandit-report.txt @@ -65,38 +65,38 @@ jobs: safety-report.txt retention-days: 30 - - name: Comment PR with security findings + - name: Комментирование PR с результатами безопасности if: github.event_name == 'pull_request' uses: actions/github-script@v6 with: script: | const fs = require('fs'); - let comment = '## 🔒 Security Check Results\n\n'; + let comment = '## 🔒 Результаты проверки безопасности\n\n'; - // Bandit results + // Результаты Bandit if (fs.existsSync('bandit-report.txt')) { const banditContent = fs.readFileSync('bandit-report.txt', 'utf8'); if (banditContent.trim()) { - comment += '### 🚨 Bandit Security Issues\n\n'; + comment += '### 🚨 Проблемы безопасности Bandit\n\n'; comment += '```\n' + banditContent + '\n```\n\n'; } else { - comment += '✅ No Bandit security issues found\n\n'; + comment += '✅ Проблем безопасности Bandit не найдено\n\n'; } } - // Safety results + // Результаты Safety if (fs.existsSync('safety-report.txt')) { const safetyContent = fs.readFileSync('safety-report.txt', 'utf8'); if (safetyContent.trim()) { - comment += '### ⚠️ Known Vulnerabilities\n\n'; + comment += '### ⚠️ Известные уязвимости\n\n'; comment += '```\n' + safetyContent + '\n```\n\n'; } else { - comment += '✅ No known vulnerabilities found\n\n'; + comment += '✅ Известных уязвимостей не найдено\n\n'; } } - comment += '---\n*This report was generated automatically by GitHub Actions*'; + comment += '---\n*Этот отчет был сгенерирован автоматически GitHub Actions*'; github.rest.issues.createComment({ issue_number: context.issue.number, diff --git a/.github/workflows/update-deps.yml b/.github/workflows/update-deps.yml index 3eec41c..4ee39ab 100644 --- a/.github/workflows/update-deps.yml +++ b/.github/workflows/update-deps.yml @@ -1,4 +1,4 @@ -name: Update Dependencies +name: Обновление зависимостей on: schedule: @@ -11,66 +11,66 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code + - name: Клонирование кода uses: actions/checkout@v4 with: token: ${{ secrets.GITHUB_TOKEN }} - - name: Set up Python + - name: Настройка Python uses: actions/setup-python@v4 with: python-version: "3.11" cache: "pip" - - name: Install dependencies + - name: Установка зависимостей run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install pip-chill - - name: Update dependencies + - name: Обновление зависимостей run: | - echo "Updating dependencies..." + echo "Обновление зависимостей..." pip install --upgrade $(pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1) - - name: Update requirements.txt + - name: Обновление requirements.txt run: | - echo "Updating requirements.txt..." + echo "Обновление requirements.txt..." pip-chill --no-version > requirements.txt.new if ! cmp -s requirements.txt requirements.txt.new; then mv requirements.txt.new requirements.txt - echo "Requirements updated" + echo "Зависимости обновлены" else - echo "No updates needed" + echo "Обновления не требуются" rm requirements.txt.new fi - - name: Test build + - name: Тестирование сборки run: | - echo "Testing build with updated dependencies..." + echo "Тестирование сборки с обновленными зависимостями..." mkdocs build --strict - - name: Create Pull Request + - name: Создание Pull Request if: success() uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "chore: update dependencies" - title: "🤖 Automated dependency update" + title: "🤖 Автоматическое обновление зависимостей" body: | - ## 🔄 Automated Dependency Update + ## 🔄 Автоматическое обновление зависимостей - This PR was automatically created to update project dependencies. + Этот PR был автоматически создан для обновления зависимостей проекта. - ### 📋 Changes - - Updated Python package dependencies - - Tested build with new dependencies + ### 📋 Изменения + - Обновлены зависимости Python пакетов + - Протестирована сборка с новыми зависимостями - ### ✅ Checks - - [x] Dependencies updated - - [x] Build tested successfully + ### ✅ Проверки + - [x] Зависимости обновлены + - [x] Сборка протестирована успешно - ### 🚀 Ready to merge - This PR is safe to merge as all tests pass. + ### 🚀 Готово к слиянию + Этот PR безопасен для слияния, так как все тесты пройдены. branch: update-dependencies delete-branch: true diff --git a/mkdocs.yml b/mkdocs.yml index 3e7b70f..19c42bc 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -80,7 +80,12 @@ plugins: loop: true - import-statement - meta-manager - - git-authors + - git-authors: + show_email_address: false + show_contribution: true + add_co_authors: true + ignore_authors: + - m.harder@bsg.de - htmlproofer - link-marker - neoteroi.mkdocsoad: