Skip to content

fix(ci): dockerbuild ワークフローの起動失敗を解消し PR でも実行可能にする#6784

Open
nanasess wants to merge 2 commits into
EC-CUBE:4.4from
nanasess:fix/dockerbuild
Open

fix(ci): dockerbuild ワークフローの起動失敗を解消し PR でも実行可能にする#6784
nanasess wants to merge 2 commits into
EC-CUBE:4.4from
nanasess:fix/dockerbuild

Conversation

@nanasess
Copy link
Copy Markdown
Contributor

@nanasess nanasess commented May 27, 2026

概要(Overview・Refs Issue)

Testing dockerbuild ワークフロー (.github/workflows/dockerbuild.yml) が 2026-05-13 以降、4.4 ブランチで連続失敗していた問題を修正する。

失敗 run の例: https://github.com/EC-CUBE/ec-cube/actions/runs/26124921377

GitHub UI には「This run likely failed because of a workflow file issue」と表示され、gh api /repos/EC-CUBE/ec-cube/actions/runs/<id>/jobs の結果が {"total_count":0,"jobs":[]} となっており、ステップ実行前の workflow ファイル検証段階で失敗していた。

合わせて以下を整理する。

方針(Policy)

起動失敗の根本原因

dockerbuild.yml の matrix 定義で include 内に orphan な {php: '8.3', tag: '8.3-apache'} エントリ が残存していた。

base matrix は php: ['8.4', '8.5'] (8.3 が外れている) のため、GitHub Actions の matrix include 仕様 により {php: '8.3', tag: '8.3-apache'} は既存 combination にマージできず新規 combination として作成されるが、この新規 combination には operating-system が含まれず runs-on: \${{ matrix.operating-system }} が空となり workflow 検証エラーで起動失敗していた。

直接の起点は 2025-11-25 の commit 42a0cec799 (ci: GitHub ActionsでPHP 8.4と8.5のサポートを追加) で base を php: ['8.4'] → ['8.4', '8.5'] に変更しつつ include の 8.3 エントリを残置したこと。2026-05-13 以降は 4.4 (旧 4.3-symfony7) ブランチが現役 CI 対象となり、毎 push で workflow 起動失敗が顕在化していた。

修正内容

base matrix に '8.3' を再加入し、include の 8.3 エントリと整合させる。unit-test.yml / plugin-test.yml / e2e-test.yml も 8.3 をテスト対象としている点とも揃う。

PR 時の失敗検知

dockerbuild.ymlon.workflow_call: に変更し main.yml から呼び出す。success ジョブの needsdockerbuild を追加し、PR の dockerbuild が失敗すれば success に到達しない構成にした。

PR では ghcr.io への push は行わず、ビルドと docker compose up --wait での EC-CUBE 起動確認までを実施する。

不要ステップの削除

#6778 で Codeception が削除されたため、ホスト側で動かしていた以下のステップは不要となり削除する。

  • Setup PHP
  • Install ext-redis 6.1+
  • Initialize Composer

.dockerignorevendor/ を除外しているため、ホスト側 composer install の結果は Docker イメージに反映されず、これらは Codeception 実行のためだけに存在していた。

実装に関する補足(Appendix)

  • on.release は維持。タグ公開時は従来通り dockerbuild.yml が直接トリガーされ ghcr.io にイメージを push する。
  • main.ymldockerbuild ジョブには needs: を指定しておらず、rector / phpstan / php-cs-fixer と並列で実行される (DX 上、Docker ビルドは早期に結果が出る方が便利なため)。
  • Login to GitHub Container Registry / Push Docker imageif: github.event_name != 'pull_request' でガード。PR 由来の GITHUB_TOKENpackages: write を持たないケースで失敗するのを避けるため。

テスト(Test)

  • YAML 構文チェック: python3 -c "import yaml; yaml.safe_load(open('.github/workflows/dockerbuild.yml'))" で OK
  • matrix 展開: 3 ジョブ (8.3 / 8.4 / 8.5) になることを確認
  • このブランチ向け PR で main.yml 経由の dockerbuild ジョブが実際に起動し、各 PHP バージョンで Docker ビルド + EC-CUBE 起動確認まで通ることを確認
  • マージ後、4.4 への push で Testing dockerbuild ワークフローが起動し ghcr.io への push まで完了することを確認

相談(Discussion)

  • 現状 dockerbuild は 4.4 で 8.3 / 8.4 / 8.5 の 3 並列。CI 時間が気になるようなら PR 時のみ 1 バージョンに絞る等の制限を検討する余地がある。

マイナーバージョン互換性保持のための制限事項チェックリスト

  • 既存機能の仕様変更はありません
  • フックポイントの呼び出しタイミングの変更はありません
  • フックポイントのパラメータの削除・データ型の変更はありません
  • twigファイルに渡しているパラメータの削除・データ型の変更はありません
  • Serviceクラスの公開関数の、引数の削除・データ型の変更はありません
  • 入出力ファイル(CSVなど)のフォーマット変更はありません

レビュワー確認項目

  • 動作確認
  • コードレビュー
  • E2E/Unit テスト確認(テストの追加・変更が必要かどうか)
  • 互換性が保持されているか
  • セキュリティ上の問題がないか
    • 権限を超えた操作が可能にならないか
    • 不要なファイルアップロードがないか
    • 外部へ公開されるファイルや機能の追加ではないか
    • テンプレートでのエスケープ漏れがないか

Summary by CodeRabbit

  • Chores
    • CIワークフロー間の呼び出しを許可し、パイプラインの柔軟性を向上
    • ビルドマトリクスに PHP 8.3 を追加
    • E2E 前にイメージビルドを組み込み、ビルドジョブにコンテナ書き込み権限を付与
    • Docker イメージビルド処理を見直し、拡張インストールの振る舞いや条件実行を最適化

Review Change Stack

base matrix から外れていた `php: '8.3'` を再加入し、`include` 内の orphan
エントリ `{php: '8.3', tag: '8.3-apache'}` が新規 combination を作って
`runs-on` を空にする問題を解消する。これにより 2026-05-13 以降ずっと
「This run likely failed because of a workflow file issue」で失敗していた
`Testing dockerbuild` ワークフローが起動可能になる。

併せて以下を整理する:

- `on.push` を `workflow_call:` に変更し、`main.yml` から呼び出す
  形に統一。`success` ジョブの `needs` に `dockerbuild` を追加し、
  PR 時の失敗を `main.yml` の `success` 到達でブロックできるようにする
- PR 時は `Login to GitHub Container Registry` / `Push Docker image`
  をスキップ。ビルドと `docker compose up --wait` による起動確認のみ実行
- Codeception 削除 (PR EC-CUBE#6778) で不要になった `Setup PHP` /
  `Install ext-redis 6.1+` / `Initialize Composer` ステップを削除
  (`.dockerignore` で `vendor/` を除外しているため、ホスト側 composer
  install は Docker イメージに反映されず無意味)

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a31d3a4d-4409-48b0-9322-2943ffe7092a

📥 Commits

Reviewing files that changed from the base of the PR and between 4c0c5fb and 6dd6ee6.

📒 Files selected for processing (2)
  • .github/workflows/dockerbuild.yml
  • Dockerfile

📝 Walkthrough

Walkthrough

dockerbuild.yml ワークフローが再利用可能なワークフローに変更され、main.yml から呼び出されるようになりました。PHP 8.3 サポートが追加され、レジストリログインとイメージプッシュの条件がイベント型に基づいた動作に更新されました。

Changes

再利用可能な Docker ビルドワークフロー

Layer / File(s) Summary
dockerbuild.yml 再利用可能ワークフロー化
.github/workflows/dockerbuild.yml
workflow_call トリガーが追加され、他のワークフローから呼び出し可能になりました。PHP ビルドマトリクスに 8.3 を追加、各バージョンで ext_install_args を切り替え、docker/build-push-actionEXT_INSTALL_ARGS を渡すよう変更。レジストリログインとイメージプッシュは github.event_name != 'pull_request' の条件でスキップされます。
main.yml からのワークフロー呼び出し統合
.github/workflows/main.yml
dockerbuild ジョブが uses: ./.github/workflows/dockerbuild.yml で追加され、当該ジョブに packages: write 権限が付与されました。成功条件ジョブの依存関係に dockerbuild が追加されました。
Dockerfile の拡張インストール引数導入
Dockerfile
ARG EXT_INSTALL_ARGS, ARG GD_OPTIONS を導入し、opcache を EXT_INSTALL_ARGS から除外する形に変更。pgsql/pdo_pgsqlgd の個別設定後に EXT_INSTALL_ARGS で残り拡張をインストールする手順に置き換えられています。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

bug

Suggested reviewers

  • ji-eunsoo
  • dotani1111
  • saori-kakiuchi

Poem

🐰 Workflows now call to each other with grace,
Docker builds reusable across the place,
PHP 8.3 joins the test suite's dance,
Registry gates open wide at the chance,
Pull requests skip login—a workflow romance! 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed pull request のタイトルは dockerbuild ワークフローの起動失敗修正と PR での実行可能化という主要な変更を的確に要約しており、changeset の中心的な目的と合致しています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/dockerbuild.yml:
- Around line 46-47: The current conditional if: github.event_name !=
'pull_request' in .github/workflows/dockerbuild.yml is wrong for workflow_call
because github.event_name reflects the caller; replace it with a tighter check
for actual tag/release pushes (for example: if: github.event_name == 'release'
|| startsWith(github.ref, 'refs/tags/')) so the docker/login-action push step
only runs on release/tag events; update the conditional that currently reads if:
github.event_name != 'pull_request' accordingly (or alternatively use ref_type
== 'tag' when available) to ensure Login/Push only executes for tags/releases.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 47a46edb-fe10-4959-844f-cf416621178b

📥 Commits

Reviewing files that changed from the base of the PR and between 1059ca0 and 4c0c5fb.

📒 Files selected for processing (2)
  • .github/workflows/dockerbuild.yml
  • .github/workflows/main.yml

Comment on lines +46 to 47
if: github.event_name != 'pull_request'
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

In a reusable GitHub Actions workflow triggered by workflow_call, what value does github.event_name have, and what is the recommended way to conditionally skip publish steps for pull_request callers while allowing tag/release publishes?

💡 Result:

In a reusable workflow called via on: workflow_call, github.event_name has the value of the event that triggered the caller workflow (not workflow_call). For example, if the caller was triggered by pull_request_target, then github.event_name inside the called workflow will be pull_request_target—so checks like github.event_name == 'workflow_call' will be false in that called workflow. [1][2][3] Recommended way to conditionally skip “publish” for pull_request callers while allowing tag/release publishes: 1) In the reusable workflow, add an explicit input flag (e.g., should_publish) to represent whether the caller intends to publish. 2) In the caller workflow, set that input based on the caller’s event type (e.g., only set it to true for push tag events / release events, and false for pull_request* events). 3) In the reusable workflow, guard publish jobs/steps with that input, e.g. if: ${{ inputs.should_publish }}. This avoids relying on github.event_name == 'workflow_call', which is not reliable because the called workflow’s github context is associated with the caller workflow’s event. [1][3]

Citations:


github.event_name の前提がズレています(workflow_call 側でも呼び出し元イベントの値になります)

  • workflow_call された側の github.event_name は呼び出し元ワークフローのイベント値のため、pull_request で呼ばれている場合は if: github.event_name != 'pull_request' により Login/Push は実行されません。
  • ただし「タグ/リリース時のみ push」が要件なら、現状は pull_request 以外すべてで走り得るため release / tagref_type == 'tag' 等)で条件を絞り込むのが安全です。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/dockerbuild.yml around lines 46 - 47, The current
conditional if: github.event_name != 'pull_request' in
.github/workflows/dockerbuild.yml is wrong for workflow_call because
github.event_name reflects the caller; replace it with a tighter check for
actual tag/release pushes (for example: if: github.event_name == 'release' ||
startsWith(github.ref, 'refs/tags/')) so the docker/login-action push step only
runs on release/tag events; update the conditional that currently reads if:
github.event_name != 'pull_request' accordingly (or alternatively use ref_type
== 'tag' when available) to ensure Login/Push only executes for tags/releases.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.10%. Comparing base (fa83cdf) to head (6dd6ee6).
⚠️ Report is 30 commits behind head on 4.4.

Additional details and impacted files
@@             Coverage Diff              @@
##                4.4    #6784      +/-   ##
============================================
- Coverage     76.87%   75.10%   -1.77%     
  Complexity     6752     6752              
============================================
  Files           483      483              
  Lines         26279    26279              
============================================
- Hits          20201    19738     -463     
- Misses         6078     6541     +463     
Flag Coverage Δ
Unit 75.10% <ø> (-1.77%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

PHP 8.5.0 から opcache がコアへ静的組み込み (non-optional) となり共有モジュール
(.so) を生成しなくなったため、`docker-php-ext-install opcache` が `modules/*`
を見つけられず install-modules で失敗していた (8.5 のみ失敗、8.3/8.4 は成功)。

EC-CUBE2 系と同じく、インストール対象を `EXT_INSTALL_ARGS` ビルド引数で外出しし、
ワークフローの matrix で PHP バージョンごとに制御する方式へ変更。8.5 では
opcache を install 対象から除外する (組み込み opcache は既定で有効)。

あわせて、存在しないパスを指す不正な
`docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql` (ハイフン1個) を削除。

ローカル検証: 8.4 / 8.5 ともにビルド成功し、必要拡張 (zip/gd/mysqli/pdo_mysql/
pgsql/pdo_pgsql/intl/opcache/apcu) のロードと opcache.enable=true を確認済み。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant