Skip to content

Commit

Permalink
💚Update GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
7rikazhexde committed Sep 13, 2024
1 parent 732d5b2 commit 0fcc80c
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 41 deletions.
119 changes: 79 additions & 40 deletions .github/workflows/test_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
name: test branch

on:
workflow_dispatch:
push:
branches-ignore:
- "coverage"
branches:
- 'main'
pull_request:
branches:
- 'main'

jobs:
test:
Expand All @@ -16,23 +19,14 @@ jobs:
python-version: ['3.10', '3.11', '3.12']
runs-on: ${{ matrix.os }}
env:
# タイムゾーンを東京時間に設定
TZ: 'Asia/Tokyo'
permissions:
contents: write
steps:
- name: Check is main
id: is_main
shell: bash
run: |
if [ "${{ github.ref }}" = "refs/heads/main" ] && [ "${{ matrix.os }}" = "ubuntu-latest" ] && [ "${{ matrix.python-version }}" = "3.12" ];then
echo "flag=1" >> $GITHUB_OUTPUT
else
echo "flag=0" >> $GITHUB_OUTPUT
fi
# リポジトリをチェックアウト
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
# Python環境のセットアップ
- uses: actions/setup-python@v5
with:
python-version: ${{matrix.python-version}}
Expand All @@ -43,21 +37,24 @@ jobs:
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y ffmpeg
- name: Install poetry
# poetryのインストール
run: pip install poetry
- name: Poetry setup
# Poetryで依存関係をインストール
run: poetry install
- name: Run test
id: pytest
# エラーが発生しても続行する
continue-on-error: true
run: poetry run pytest --durations=0 --junitxml=pytest.xml --cov-report "xml:coverage.xml" --cov=video_grid_merge | tee pytest-coverage.txt
- name: Pytest coverage comment
if: ${{ steps.is_main.outputs.flag == '1' }}
# カバレッジレポートをコメントとして生成
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
pytest-xml-coverage-path: ./coverage.xml
title: Coverage Report
title: Coverage Report (${{ matrix.os }} / Python ${{ matrix.python-version }})
badge-title: coverage
hide-badge: false
hide-report: false
Expand All @@ -66,37 +63,79 @@ jobs:
report-only-changed-files: false
remove-link-from-badge: false
junitxml-path: ./pytest.xml
junitxml-title: "Pytest Result Summary (os: ubuntu-latest / python-version: 3.12)"
- name: Update Readme in coverage branch
if: ${{ steps.is_main.outputs.flag == '1' }}
junitxml-title: "Pytest Result Summary (os: ${{ matrix.os }} / python-version: ${{ matrix.python-version }})"
- name: Save summary report
run: |
# カバレッジのサマリーレポートをMarkdownファイルとして保存
echo '${{ steps.coverageComment.outputs.summaryReport }}' > summary-report.md
- name: Upload coverage data
# カバレッジデータをアップロード
uses: actions/upload-artifact@v4
with:
name: coverage-data-${{ matrix.os }}-${{ matrix.python-version }}
path: |
# pytestの出力テキスト(テストの実行結果とカバレッジデータ)
pytest-coverage.txt
# カバレッジデータのXML形式ファイル(詳細なカバレッジ情報)
coverage.xml
# テスト結果のJUnit XMLレポート(テストの成功/失敗や詳細なタイムスタンプ情報を含む)
pytest.xml
# カバレッジとテスト結果のサマリー(Markdown形式で出力したレポート)
summary-report.md
update_readme:
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Update README in coverage branch
run: |
coverage=$(git branch -a|grep "remotes/origin/coverage$") || :
if [ -z "$coverage" ];then
# "coverage" ブランチが存在する場合はチェックアウト、存在しない場合は新規作成する
if git ls-remote --heads origin coverage | grep coverage; then
git checkout coverage
else
git checkout --orphan coverage
git rm -rf .
else
git checkout coverage
fi
# README.mdのヘッダーとバッジを追加
echo "# Coverage Reports" > README.md
echo "[![](https://github.com/$GITHUB_REPOSITORY/actions/workflows/test_branch.yml/badge.svg)](https://github.com/$GITHUB_REPOSITORY/actions/workflows/test_branch.yml)" >> README.md
echo "" >> README.md
# 最新のコミット情報をREADMEに追加
commit_hash=${GITHUB_SHA::8}
commit_link="[$commit_hash](https://github.com/$GITHUB_REPOSITORY/tree/$commit_hash)"
echo "[![](https://github.com/$GITHUB_REPOSITORY/actions/workflows/test_branch.yml/badge.svg)](https://github.com/$GITHUB_REPOSITORY/actions/workflows/test_branch.yml)" > ./README.md
echo -e ${{ steps.coverageComment.outputs.summaryReport }} >> ./README.md
echo -e "> [!Note]" >> ./README.md
echo -e "> " >> ./README.md
echo -e "> Commit: $commit_link" >> ./README.md
echo -e "> " >> ./README.md
echo "> Click on the `test summary` badge above to see the results of running pytest on multiple hosts." >> ./README.md
- name: Commit
if: ${{ steps.is_main.outputs.flag == '1' }}
echo -e "> [!Note]" >> README.md
echo -e "> " >> README.md
echo -e "> Commit: $commit_link" >> README.md
echo -e "> " >> README.md
# macOS、Ubuntu、Windowsの各OSとPythonバージョンごとにカバレッジレポートを追加
for os in macos-12 ubuntu-latest windows-latest; do
for version in 3.11 3.12; do
echo "## Coverage Report (os: $os / python-version: $version)" >> README.md
if [ -f "coverage-data-$os-$version/summary-report.md" ]; then
sed -e 's/^"//' -e 's/"$//' -e 's/\\"/"/g' -e 's/\\\\/\\/g' -e 's/\\n/\n/g' -e 's/\r$//' "coverage-data-$os-$version/summary-report.md" |
sed -e 's/&lt;/</g' -e 's/&gt;/>/g' -e 's/&amp;/\&/g' |
sed '/^$/N;/^\n$/D' |
sed -e 's/^"//' -e 's/"$//' >> README.md
else
echo "No summary report found for $os - $version" >> README.md
fi
echo "" >> README.md
done
done
# ファイルパスを修正する
sed -i 's|/blob/\([a-f0-9]*\)/\([^"]*\)|/blob/\1/video_grid_merge/\2|g' README.md
- name: Commit and push
run: |
# Gitのユーザー設定とコミット、ブランチへのプッシュ
git config --local user.email "33836132+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add README.md
git commit -m "Update coverage"
- name: Push
if: ${{ steps.is_main.outputs.flag == '1' }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: coverage
git commit -m "Update coverage for all environments"
git push origin coverage
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "video-grid-merge"
version = "0.2.25"
version = "0.2.26"
description = "This project allows you to use FFmpeg to arrange video files stored in a specified folder in an NxN grid layout and generate the output."
authors = ["7rikaz"]
readme = "README.md"
Expand Down

6 comments on commit 0fcc80c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coverage

Coverage Report (ubuntu-latest / Python 3.11)
FileStmtsMissCoverMissing
__init__.py00100% 
__main__.py1800100% 
delete_files.py130100% 
rename_files.py100100% 
TOTAL2030100% 

Pytest Result Summary (os: ubuntu-latest / python-version: 3.11)

Tests Skipped Failures Errors Time
89 4 💤 0 ❌ 0 🔥 1.601s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coverage

Coverage Report (ubuntu-latest / Python 3.12)
FileStmtsMissCoverMissing
__init__.py00100% 
__main__.py1800100% 
delete_files.py130100% 
rename_files.py100100% 
TOTAL2030100% 

Pytest Result Summary (os: ubuntu-latest / python-version: 3.12)

Tests Skipped Failures Errors Time
89 4 💤 0 ❌ 0 🔥 1.583s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coverage

Coverage Report (ubuntu-latest / Python 3.10)
FileStmtsMissCoverMissing
__init__.py00100% 
__main__.py1800100% 
delete_files.py130100% 
rename_files.py100100% 
TOTAL2030100% 

Pytest Result Summary (os: ubuntu-latest / python-version: 3.10)

Tests Skipped Failures Errors Time
89 4 💤 0 ❌ 0 🔥 2.317s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coverage

Coverage Report (macos-12 / Python 3.12)
FileStmtsMissCoverMissing
__init__.py00100% 
__main__.py1800100% 
delete_files.py130100% 
rename_files.py100100% 
TOTAL2030100% 

Pytest Result Summary (os: macos-12 / python-version: 3.12)

Tests Skipped Failures Errors Time
89 4 💤 0 ❌ 0 🔥 2.289s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coverage

Coverage Report (macos-12 / Python 3.11)
FileStmtsMissCoverMissing
__init__.py00100% 
__main__.py1800100% 
delete_files.py130100% 
rename_files.py100100% 
TOTAL2030100% 

Pytest Result Summary (os: macos-12 / python-version: 3.11)

Tests Skipped Failures Errors Time
89 4 💤 0 ❌ 0 🔥 2.113s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coverage

Coverage Report (macos-12 / Python 3.10)
FileStmtsMissCoverMissing
__init__.py00100% 
__main__.py1800100% 
delete_files.py130100% 
rename_files.py100100% 
TOTAL2030100% 

Pytest Result Summary (os: macos-12 / python-version: 3.10)

Tests Skipped Failures Errors Time
89 4 💤 0 ❌ 0 🔥 2.740s ⏱️

Please sign in to comment.