⬆️ Bump the dependencies group across 1 directory with 2 updates #214
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Dependabot PR Check | |
| # ワークフローの処理の流れ: | |
| # 1. トリガー条件: | |
| # - mainブランチへのプルリクエスト時 | |
| # - Dependabotによる実行であること | |
| # - コミットメッセージが"Bump version"で始まっていないこと | |
| # 2. ジョブの条件判定: Dependabot によるPRであることをチェック | |
| # 3. OS毎の環境設定 (macos-latest, ubuntu-latest, windows-latest) | |
| # 4. Python環境のセットアップ (3.11, 3.12) | |
| # 5. タイムゾーンの設定 (Asia/Tokyo) | |
| # 6. リポジトリのチェックアウト | |
| # 7. Poetry のインストール | |
| # 8. 依存関係のキャッシュ | |
| # 9. プロジェクト依存関係のインストール | |
| # 10. テストの実行とカバレッジの計算 | |
| # 11. カバレッジが90%以上であることのチェック | |
| # 12. テスト結果とカバレッジレポートの生成 | |
| # 13. テスト結果の確認と警告の表示 | |
| # 14. ジョブサマリーの作成 | |
| # 15. 全テストの結果確認 | |
| # 16. Discord Webhookの送信 | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| set_variables: | |
| if: github.actor == 'dependabot[bot]' && !startsWith(github.event.pull_request.title, 'Bump version') | |
| runs-on: ubuntu-latest | |
| outputs: | |
| os: ${{ steps.json2vars.outputs.os }} | |
| versions_python: ${{ steps.json2vars.outputs.versions_python }} | |
| ghpages_branch: ${{ steps.json2vars.outputs.ghpages_branch }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set variables from JSON | |
| id: json2vars | |
| uses: 7rikazhexde/json2vars-setter@main | |
| with: | |
| json-file: .github/json2vars-setter/matrix.json | |
| - name: Debug output values | |
| run: | | |
| echo "os: ${{ steps.json2vars.outputs.os }}" | |
| echo "versions_python: ${{ steps.json2vars.outputs.versions_python }}" | |
| echo "ghpages_branch: ${{ steps.json2vars.outputs.ghpages_branch }}" | |
| test: | |
| needs: set_variables | |
| strategy: | |
| matrix: | |
| os: ${{ fromJson(needs.set_variables.outputs.os) }} | |
| python-version: ${{ fromJson(needs.set_variables.outputs.versions_python) }} | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| TZ: 'Asia/Tokyo' | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{matrix.python-version}} | |
| - name: Set timezone | |
| uses: szenius/set-timezone@v2.0 | |
| with: | |
| timezoneLinux: "Asia/Tokyo" | |
| timezoneMacos: "Asia/Tokyo" | |
| timezoneWindows: "Tokyo Standard Time" | |
| - name: Check timezone | |
| shell: bash | |
| run: | | |
| echo "System date: $(date)" | |
| echo "TZ environment variable: ${TZ}" | |
| python -c "import datetime, platform; print(f'Python timezone: {datetime.datetime.now().astimezone().tzinfo}'); print(f'OS: {platform.system()}')" | |
| - name: Install poetry | |
| run: pip install poetry | |
| - name: Cache dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cache/pypoetry | |
| key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} | |
| - name: Install dependencies | |
| shell: bash | |
| run: | | |
| rm -f poetry.lock | |
| poetry lock | |
| poetry install | |
| - name: Run test | |
| shell: bash | |
| id: pytest | |
| run: | | |
| poetry run task testcixml | |
| coverage_percentage=$(poetry run coverage report | grep TOTAL | awk '{print $NF}' | sed 's/%//') | |
| echo "Current coverage: ${coverage_percentage}%" | |
| echo "COVERAGE=${coverage_percentage}" >> "$GITHUB_ENV" | |
| - name: Check coverage | |
| shell: bash | |
| run: | | |
| if [ "${COVERAGE}" -lt 90 ]; then | |
| echo "Test coverage is below 90%. Current coverage: ${COVERAGE}%" | |
| exit 1 | |
| else | |
| echo "Test coverage is above or equal to 90%. Current coverage: ${COVERAGE}%" | |
| fi | |
| - name: Pytest coverage comment | |
| id: coverageComment | |
| uses: MishaKav/pytest-coverage-comment@v1.7.1 | |
| with: | |
| pytest-coverage-path: ./pytest-coverage.txt | |
| pytest-xml-coverage-path: ./coverage.xml | |
| title: Coverage Report (${{ matrix.os }} / Python ${{ matrix.python-version }}) | |
| badge-title: coverage | |
| hide-badge: false | |
| hide-report: false | |
| create-new-comment: true | |
| hide-comment: false | |
| report-only-changed-files: false | |
| remove-link-from-badge: false | |
| junitxml-path: ./pytest.xml | |
| junitxml-title: "Pytest Result Summary (os: ${{ matrix.os }} / python-version: ${{ matrix.python-version }})" | |
| github-token: ${{ secrets.PAT_FOR_PUSHES }} | |
| - name: Check test results | |
| if: steps.pytest.outcome == 'failure' | |
| run: | | |
| echo "Tests failed. This will be reported in the workflow summary." | |
| echo "::warning::Tests failed on ${{ matrix.os }} with Python ${{ matrix.python-version }}" | |
| - name: Write job summary | |
| id: check_status | |
| shell: bash | |
| run: | | |
| echo -e ${{ steps.coverageComment.outputs.summaryReport }} >> "$GITHUB_STEP_SUMMARY" | |
| check_all_tests: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: github.actor == 'dependabot[bot]' && !startsWith(github.event.pull_request.title, 'Bump version') | |
| steps: | |
| - name: Check test results | |
| if: contains(needs.test.result, 'failure') | |
| run: | | |
| echo "Some tests failed. Please check the test results and fix any issues before merging." | |
| exit 1 | |
| send_notification: | |
| needs: [test, check_all_tests] | |
| runs-on: ubuntu-latest | |
| if: github.actor == 'dependabot[bot]' && !startsWith(github.event.pull_request.title, 'Bump version') | |
| steps: | |
| - name: Send Discord Notification | |
| env: | |
| DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| WORKFLOW_ACTOR: ${{ github.actor }} | |
| run: | | |
| workflow_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| status="${{ contains(needs.test.result, 'failure') && 'FAILED ❌' || 'SUCCESS ✅' }}" | |
| message="## Dependabot PR Check Completed | |
| ### Workflow Information | |
| • **Name:** ${{ github.workflow }} | |
| • **Status:** ${status} | |
| • **Run:** [View Details]($workflow_url) | |
| • **PR Title:** ${PR_TITLE} | |
| • **Actor:** ${WORKFLOW_ACTOR}" | |
| timestamp="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" | |
| json_payload=$(jq -n \ | |
| --arg title "${{ github.workflow }} - Dependabot Check Status" \ | |
| --arg description "$message" \ | |
| --argjson color "${{ contains(needs.test.result, 'failure') && '16711680' || '65280' }}" \ | |
| --arg timestamp "$timestamp" \ | |
| '{ | |
| "embeds": [ | |
| { | |
| "title": $title, | |
| "description": $description, | |
| "color": $color, | |
| "timestamp": $timestamp | |
| } | |
| ] | |
| }') | |
| curl -X POST -H "Content-Type: application/json" \ | |
| -d "$json_payload" \ | |
| "$DISCORD_WEBHOOK_URL" |