-
Notifications
You must be signed in to change notification settings - Fork 719
138 lines (126 loc) · 5.93 KB
/
Copy pathcoverage.yml
File metadata and controls
138 lines (126 loc) · 5.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Coverage
on:
workflow_call:
permissions:
contents: read
code-quality: write
jobs:
phpunit:
name: PHPUnit
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
php: [ '8.5' ]
db: [ pgsql ]
include:
- db: pgsql
database_url: postgres://postgres:password@127.0.0.1:5432/eccube_db
database_server_version: 18
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
persist-credentials: false
# CVE-2026-24765 (GHSA-vvj3-c3rp-c85p) 対策 (多層防御):
# 悪意ある *.coverage ファイルが PHPUnit の PHPT ランナーで unserialize され
# RCE に至るのを防ぐため、テスト実行前に削除する。
- name: Remove potentially malicious coverage files
run: find . -name "*.coverage" -delete
## Docker Hub からの pull はタイムアウトで CI が不安定になるため、
## DB はコンテナではなく setup アクション (apt) でインストールする
- name: Setup PostgreSQL
uses: ankane/setup-postgres@6d3ffa1aa7498a42b79e9f9f5838b99971839300 # v1
with:
postgres-version: '18'
user: postgres
- name: Configure PostgreSQL
run: |
for _ in $(seq 1 30); do pg_isready -h 127.0.0.1 && break; sleep 1; done
pg_isready -h 127.0.0.1 || { echo 'PostgreSQL did not become ready within 30s'; exit 1; }
psql -h 127.0.0.1 -U postgres -c "ALTER USER postgres PASSWORD 'password'"
## DATABASE_URL と同一経路 (TCP/postgres/password) で接続できることを検証
PGPASSWORD=password psql -h 127.0.0.1 -U postgres -c 'SELECT VERSION()'
- name: Setup PHP
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
with:
php-version: ${{ matrix.php }}
extensions: redis
coverage: pcov
- name: Initialize Composer
uses: ./.github/actions/composer
- name: Generate ECCUBE_AUTH_MAGIC
run: echo "ECCUBE_AUTH_MAGIC=$(openssl rand -hex 32)" >> $GITHUB_ENV
- name: Setup EC-CUBE
env:
APP_ENV: 'test'
DATABASE_URL: ${{ matrix.database_url }}
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
ECCUBE_AUTH_MAGIC: ${{ env.ECCUBE_AUTH_MAGIC }}
run: |
bin/console doctrine:database:create
bin/console doctrine:schema:create
bin/console eccube:fixtures:load
# Agent Commerce (#6794) の UCP スキーマ契約テスト用に UCP 公式 schema を取得する。
# リポジトリには同梱しない (Apache-2.0)。docblock の参照バージョンと一致するリリースタグ
# v2026-04-08 に固定し、var/ (gitignore) へ clone する。未取得環境では該当テストは skip。
- name: Fetch UCP spec schemas (tag v2026-04-08)
run: |
git clone --filter=blob:none --branch v2026-04-08 --single-branch --quiet \
https://github.com/Universal-Commerce-Protocol/ucp.git var/agent-commerce-spec/ucp
- name: PHPUnit
id: phpunit
env:
APP_ENV: 'test'
DATABASE_URL: ${{ matrix.database_url }}
DATABASE_SERVER_VERSION: ${{ matrix.database_server_version }}
MAILER_URL: 'smtp://127.0.0.1:1025'
continue-on-error: true
run: |
echo "session.save_path=$PWD/var/sessions/test" > php.ini
echo "memory_limit=1012M" >> php.ini
# rector グループ (AttributeArgumentsOrderRectorTest) は rector 同梱の
# nikic/php-parser を読み込み、pcov 有効時に本体の nikic/php-parser と衝突して
# fatal (Cannot redeclare PhpParser\Node\Scalar\Float_) になるため除外する。
php -c php.ini -dpcov.enabled=1 vendor/bin/phpunit --exclude-group cache-clear --exclude-group cache-clear-install --exclude-group update-schema-doctrine --exclude-group rector --coverage-cobertura=coverage1.xml --testdox
# GitHub のコードカバレッジ (Code Quality) にアップロードする。
# - PHPUnit ステップの outcome でガードする: 上記の continue-on-error により
# テストがクラッシュしてもジョブは成功扱いのままになり、coverage1.xml が
# 欠損・不完全な状態でアップロードされる恐れがあるため。
# - fork からの PR ではアクション内部でスキップされる (GITHUB_TOKEN が read-only のため)。
- name: Upload coverage to GitHub
if: steps.phpunit.outcome == 'success'
uses: actions/upload-code-coverage@1c15be36fc3733ba839b1dd643bd9556e4426dc1 # v1.4.1
with:
file: coverage1.xml
language: PHP
label: Unit
- name: Upload report
if: success()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: phpunit-reports
path: coverage1.xml
upload:
name: Upload coverage reports
runs-on: ubuntu-latest
needs: [ phpunit ]
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
persist-credentials: false
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
path: reports
- name: Upload unit test coverage
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v5
with:
files: ./reports/phpunit-reports/coverage1.xml
flags: Unit
fail_ci_if_error: true
# cli.codecov.io のバイナリは GPG 公開鍵を取得できず署名検証が
# "No public key" で失敗するため、PyPI 版 CLI を使い検証経路を回避する
use_pypi: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}