1- # Workflow for testing the project across multiple operating systems and Python versions.
2- # This workflow runs on main branch pushes, pull requests to main, and can be manually triggered.
3- # It performs unit tests, generates coverage reports, and updates the README with the latest coverage data.
1+ name : Test Multi-OS
42
5- name : Multi-OS Test
3+ # ワークフローの処理の流れ:
4+ # 1. トリガー条件:
5+ # - 手動実行
6+ # - mainブランチへのプルリクエスト
7+ # - mainブランチへのプッシュ(Version Updateワークフロー以外)
8+ # 2. ファイルの存在確認(Ubuntu環境)
9+ # 3. 複数の環境(OS、Pythonバージョン)でのテスト実行
10+ # 4. テスト結果に基づくREADMEの更新
11+ # - pytest-coverage-commentアクション使用
12+ # URL: https://github.com/marketplace/actions/pytest-coverage-comment
13+ # 5. 全テスト結果の確認
614
715on :
816 workflow_dispatch :
9- push :
10- branches :
11- - ' *'
1217 pull_request :
1318 branches :
1419 - ' main'
20+ push :
21+ branches :
22+ - ' main'
1523
1624jobs :
25+ check_file :
26+ runs-on : ubuntu-latest
27+ outputs :
28+ file_exists : ${{ steps.check_file.outputs.file_exists }}
29+ steps :
30+ - uses : actions/checkout@v4
31+ - name : Check file existence
32+ id : check_file
33+ run : |
34+ if find . -name "ton_whales_staking_dashboard.py" -print -quit | grep -q .; then
35+ echo "file_exists=true" >> $GITHUB_OUTPUT
36+ else
37+ echo "file_exists=false" >> $GITHUB_OUTPUT
38+ fi
39+
1740 test :
41+ needs : check_file
42+ if : github.actor != 'dependabot[bot]' && !startsWith(github.event.head_commit.message, 'Bump version') && !contains(github.ref, 'version-update')
1843 strategy :
1944 matrix :
20- os : [macos-12 , ubuntu-latest]
21- python-version : ['3.10', '3. 11', '3.12']
45+ os : [macos-13 , ubuntu-latest]
46+ python-version : ['3.11', '3.12']
2247 runs-on : ${{ matrix.os }}
2348 env :
24- # タイムゾーンを東京時間に設定
2549 TZ : ' Asia/Tokyo'
2650 permissions :
2751 contents : write
2852 pull-requests : write
2953 steps :
30- # リポジトリをチェックアウト
3154 - uses : actions/checkout@v4
32- # Python環境のセットアップ
33- - uses : actions/setup-python@v5
55+ - name : Set up Python
56+ uses : actions/setup-python@v5
3457 with :
3558 python-version : ${{matrix.python-version}}
36- # ffmpegのインストール
3759 - name : Install FFmpeg (macOS)
38- if : matrix.os == 'macos-12 '
60+ if : matrix.os == 'macos-13 '
3961 run : brew install ffmpeg
4062 - name : Install FFmpeg (Ubuntu)
4163 if : matrix.os == 'ubuntu-latest'
4264 run : sudo apt-get update && sudo apt-get install -y ffmpeg
43- # Windowsのタイムゾーン設定
44- - name : Set timezone on Windows
45- if : runner.os == 'Windows'
46- run : tzutil /s "Tokyo Standard Time"
47- shell : cmd
65+ - name : Set timezone
66+ 67+ with :
68+ timezoneLinux : " Asia/Tokyo"
69+ timezoneMacos : " Asia/Tokyo"
70+ timezoneWindows : " Tokyo Standard Time"
71+ - name : Check timezone
72+ shell : bash
73+ run : |
74+ echo "System date: $(date)"
75+ echo "TZ environment variable: $TZ"
76+ python -c "import datetime, platform; print(f'Python timezone: {datetime.datetime.now().astimezone().tzinfo}'); print(f'OS: {platform.system()}')"
4877 - name : Install poetry
49- # poetryのインストール
5078 run : pip install poetry
5179 - name : Cache dependencies
52- # キャッシュの活用
5380 uses : actions/cache@v4
5481 with :
5582 path : ~/.cache/pypoetry
5683 key : ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
5784 - name : Install dependencies
58- # Poetryで依存関係をインストール
5985 run : poetry install
6086 - name : Run test
6187 id : pytest
62- # エラーが発生しても続行する
6388 continue-on-error : true
6489 # run: poetry run pytest --durations=0 --junitxml=pytest.xml --cov-report "xml:coverage.xml" --cov=video_grid_merge tests/ | tee pytest-coverage.txt
6590 run : poetry run task test_gh_action_xml
6691 - name : Pytest coverage comment
67- # カバレッジレポートをコメントとして生成
6892 id : coverageComment
6993 uses : MishaKav/pytest-coverage-comment@main
7094 with :
@@ -88,10 +112,8 @@ jobs:
88112 exit 1
89113 - name : Save summary report
90114 run : |
91- # カバレッジのサマリーレポートをMarkdownファイルとして保存
92115 echo '${{ steps.coverageComment.outputs.summaryReport }}' > summary-report.md
93116 - name : Upload coverage data
94- # カバレッジデータをアップロード
95117 uses : actions/upload-artifact@v4
96118 with :
97119 name : coverage-data-${{ matrix.os }}-${{ matrix.python-version }}
@@ -106,9 +128,9 @@ jobs:
106128 summary-report.md
107129
108130 update_readme :
109- needs : test
131+ needs : [check_file, test]
110132 runs-on : ubuntu-latest
111- if : always()
133+ if : github.actor != 'dependabot[bot]' && !startsWith(github.event.head_commit.message, 'Bump version') && !contains(github.ref, 'version-update') && always()
112134 permissions :
113135 contents : write
114136 pull-requests : write
@@ -130,19 +152,37 @@ jobs:
130152
131153 # README.mdのヘッダーとバッジを追加
132154 echo "# Coverage Reports" > README.md
133- echo "[](https://github.com/$GITHUB_REPOSITORY/actions/workflows/test_branch .yml)" >> README.md
155+ echo "[](https://github.com/$GITHUB_REPOSITORY/actions/workflows/test_multi_os .yml)" >> README.md
134156 echo "" >> README.md
135157
136158 # 最新のコミット情報をREADMEに追加
137- commit_hash =${GITHUB_SHA::8}
138- commit_link="[$commit_hash ](https://github.com/$GITHUB_REPOSITORY/tree/$commit_hash )"
159+ commit_hash8 =${GITHUB_SHA::8}
160+ commit_link="[$commit_hash8 ](https://github.com/$GITHUB_REPOSITORY/tree/$commit_hash8 )"
139161 echo -e "> [!Note]" >> README.md
140162 echo -e "> " >> README.md
141163 echo -e "> Commit: $commit_link" >> README.md
142- echo -e "" >> README.md # この行を追加
164+ echo -e "" >> README.md
165+
166+ # テスト対象外のファイルに関する注記を追加(ファイルの存在確認結果に基づく)
167+ commit_hash=${GITHUB_SHA}
168+ file_path_1="ton_txns_data_conv/staking/ton_whales_staking_dashboard.py"
169+ file_path_2="staking/ton_whales_staking_dashboard.py"
170+ # 後述するカバレッジレポートのリンク修正のためプログラムのソースコードディレクトリを除いたリンクにする
171+ file_link="https://github.com/$GITHUB_REPOSITORY/blob/$commit_hash/$file_path_2"
172+
173+ if [[ "${{ needs.check_file.outputs.file_exists }}" == "true" ]]; then
174+ echo -e "> [!Important]" >> README.md
175+ echo -e "> The following file is intentionally excluded from test coverage:" >> README.md
176+ echo -e "> - [$file_path_1]($file_link)" >> README.md
177+ echo -e "> " >> README.md
178+ echo -e "> This file contains complex external dependencies and is verified through manual and integration testing." >> README.md
179+ echo -e "> " >> README.md
180+ else
181+ echo "Note: File $file_path_1 not found. Skipping addition to README.md." >&2
182+ fi
143183
144184 # macOS、Ubuntuの各OSとPythonバージョンごとにカバレッジレポートを追加
145- for os in macos-12 ubuntu-latest; do
185+ for os in macos-13 ubuntu-latest; do
146186 for version in 3.11 3.12; do
147187 echo "## Coverage Report (os: $os / python-version: $version)" >> README.md
148188 if [ -f "coverage-data-$os-$version/summary-report.md" ]; then
@@ -157,10 +197,10 @@ jobs:
157197 done
158198 done
159199
160- # ファイルパスを修正する
200+ # カバレッジレポート内のリンクを有効にするためにファイルパスを修正する
161201 sed -i '
162- s|/blob/\([a-f0-9]*\)/\([^"]*\)|/blob/\1/video_grid_merge /\2|g;
163- s|/blob/\([a-f0-9]*\)/video_grid_merge /README\.md|/blob/\1/README.md|g
202+ s|/blob/\([a-f0-9]*\)/\([^"]*\)|/blob/\1/ton_txns_data_conv /\2|g;
203+ s|/blob/\([a-f0-9]*\)/ton_txns_data_conv /README\.md|/blob/\1/README.md|g
164204 ' README.md
165205 - name : Commit and push
166206 run : |
0 commit comments