Skip to content

⬆️ Bump softprops/action-gh-release from 2.2.0 to 2.2.1 in the dependencies group #41

⬆️ Bump softprops/action-gh-release from 2.2.0 to 2.2.1 in the dependencies group

⬆️ Bump softprops/action-gh-release from 2.2.0 to 2.2.1 in the dependencies group #41

Workflow file for this run

name: Dependabot PR Check
# Workflow Processing Flow:
# 1. trigger condition:
# - On pull request to main branch
# - Execution by Dependabot
# - Commit message does not start with “Bump version”.
# 2. job condition check: check for PR by Dependabot
# 3. Set variables using 7rikazhexde/json2vars-setter action
# 4. Set up your time zone (Asia/Tokyo)
# 5. Repository Checkout
# 6. Installing Poetry
# 7. Dependency cache
# 8. Install Project Dependencies
# 9. Test execution and coverage calculation
# 10. Check that coverage is at least 90%.
# 11. Generate test results and coverage reports
# 12. Check test results and display warnings
# 13. Creating Job Summaries
# 14. Confirmation of all test results
# 15. Sending LINE notifications
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
shell: bash
id: pytest
# 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
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="'dependabot_prch' workflow completed with status: $status
Check URL:
https://github.com/7rikazhexde/python-project-sandbox/actions/workflows/dependabot_prch.yml"
curl -X POST https://notify-api.line.me/api/notify \
-H "Authorization: Bearer $LINE_NOTIFY_TOKEN" \
-F "message=${message}"