⬆️ Bump the dependencies group with 7 updates #41
Workflow file for this run
This file contains 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: PR Check (Except Dependabot) | |
# ワークフローの処理の流れ: | |
# 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. LINE通知の送信 | |
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/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: Set variables from JSON | |
id: json2vars | |
uses: 7rikazhexde/json2vars-setter@main | |
with: | |
json-file: .github/workflows/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 }}" | |
run_tests: | |
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/[email protected] | |
- name: Set up Python | |
uses: actions/[email protected] | |
with: | |
python-version: ${{matrix.python-version}} | |
- name: Set timezone | |
uses: szenius/[email protected] | |
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/[email protected] | |
with: | |
path: ~/.cache/pypoetry | |
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} | |
- name: Install dependencies | |
run: poetry install | |
- name: Run test | |
id: pytest | |
shell: bash | |
# Mac / Linux | |
# run: poetry run pytest --durations=0 --junitxml=pytest.xml --cov-report xml:coverage.xml --cov=project_a tests/ | tee pytest-coverage.txt | |
# Windowss | |
# run: poetry run pytest --durations=0 --junitxml=pytest.xml --cov-report xml:coverage.xml --cov=project_a tests/ | Tee-Object -FilePath pytest-coverage.txt | |
run: | | |
poetry run task test_ci_xml | |
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 | |
#if: ${{ env.COVERAGE < 90 }} | |
#run: | | |
# echo "Test coverage is below 90%. Current coverage: ${{ env.COVERAGE }}%" | |
# exit 1 | |
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/[email protected] | |
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.GITHUB_TOKEN }} | |
- 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: run_tests | |
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.run_tests.result, 'failure') | |
run: | | |
echo "Some tests failed. Please check the test results and fix any issues before merging." | |
exit 1 | |
send_notification: | |
needs: [run_tests, check_all_tests] | |
runs-on: ubuntu-latest | |
steps: | |
# https://docs.github.com/ja/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-an-environment | |
- name: Send LINE Notify | |
env: | |
LINE_NOTIFY_TOKEN: ${{ secrets.LINE_ACCESS_TOKEN }} | |
run: | | |
status="${{ contains(needs.run_tests.result, 'failure') && 'FAILED' || 'SUCCESS' }}" | |
message="'pullrequest_check.yml' workflow completed with status: $status | |
Check URL: | |
https://github.com/7rikazhexde/python-project-sandbox/actions/workflows/pullrequest_check.yml" | |
curl -X POST https://notify-api.line.me/api/notify \ | |
-H "Authorization: Bearer $LINE_NOTIFY_TOKEN" \ | |
-F "message=${message}" |