ci: devcontainer の clang-format を 14 に固定 (PR #78 の CI 失敗修正)#81
Merged
Conversation
PR #78 で追加した format.yml の clang-format dry-run ジョブが、 already-formatted なツリーに対して落ちていた。原因は clang-format の メジャーバージョン不一致: - PR #75/#76 はローカルの clang-format 14 で .clang-format のリファイン と全ソースの一括 reformat を実施 - 一方 devcontainer image (:latest) は `apt-get install clang-format` で バージョン無指定のため Ubuntu 24.04 のデフォルト = clang-format 18 が 入る。format.yml はその image 上で走る 18 と 14 では整形結果が異なるため、14 で整形済みのツリーに 18 の --dry-run --Werror を当てると必ず diff が出て落ちる (CI ログでも "clang-format version 18.1.3" を確認)。 dev ステージのインストールを `clang-format-14` 明示指定に変更し、 update-alternatives で plain な `clang-format` 名を張り直す。これで reformat に使われた版と CI が使う版のメジャーが一致する。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
PR #78 (issue #63 — CI に clang-format dry-run チェックを追加) が追加する
.github/workflows/format.ymlのformat-checkジョブが、整形済みのツリーに対して失敗していた。
根本原因 (CI 失敗ログから判明した事実)
clang-format のメジャーバージョン不一致。
.clang-formatのリファインと全ソースの一括 reformat を実施した。
.devcontainer/Dockerfileのdevステージはapt-get install clang-formatとバージョン無指定でインストールしており、Ubuntu 24.04 のデフォルトである clang-format 18 が入る。
format.ymlはこの:latestimage 上で走る。#78 の失敗 run のログ冒頭にも
Ubuntu clang-format version 18.1.3と出力され、その直後から
cc/cicada/...等でcode should be clang-formattedの violation が多数並んでいた。14 で整形したツリーに 18 の
--dry-run --Werrorを当てれば整形ルールの差で必ず diff が出るため、ジョブは緑になりようがない状態だった。
修正内容
.devcontainer/Dockerfileのdevステージのインストールをclang-format→clang-format-14の明示指定に変更し、update-alternativesで plain なclang-format名をclang-format-14に張り直す(
format.ymlも人間もバージョンサフィックス無しで呼べるように)。これで「reformat に使った版」と「CI が使う版」のメジャーが 14 で一致する。
clang-format-14は Ubuntu 24.04 noble の universe に1:14.0.6-19build4として存在する。#75 / #76 / #78 のスタックとの関係
スタック構成は
master ← #75 ← #76 ← #78。本 PR は master から独立に切ったブランチ。
.devcontainer/Dockerfileは #75/#76/#78 のどのブランチでも変更されていないため、master へ独立にマージできる。
本 PR がマージされた後の道筋:
:latest) が再ビルドされclang-format 14 入りになる。
最終的に master にマージされる)と、
format.ymlは clang-format 14 のimage 上で走る。
--dry-run --Werrorは diffゼロで緑になる。
検証 (ローカルで担保できた範囲)
docker がこの環境に無いため image ビルド自体は回せていないが、以下を確認:
clang-formatは 14.0.0、CI が使っているのは18.1.3(失敗ログより)。バージョン不一致を直接確認。
clang-format-14で style: ソース全体を .clang-format に合わせて一括 reformat #76 の reformat 済みツリー にgit ls-files -- cc include common | grep -E '\.(cc|hh|cpp)$' | xargs clang-format-14 --dry-run --Werrorを実行 → exit 0(緑)。
clang-format-14パッケージが Ubuntu 24.04 noble の universe に存在することを確認(
1:14.0.6-19build4)。CI 本体は GitHub 上でしか回せないため、image 再ビルド後の最終確認は
マージ後の Actions に委ねる。