Skip to content

ci: Crystal を固定し ameba を Crystal 1.21 対応コミットに追従させる(#108) - #109

Merged
limit7412 merged 5 commits into
masterfrom
claude/add-policy-to-issues-vdp4s3-108
Aug 9, 2026
Merged

ci: Crystal を固定し ameba を Crystal 1.21 対応コミットに追従させる(#108)#109
limit7412 merged 5 commits into
masterfrom
claude/add-policy-to-issues-vdp4s3-108

Conversation

@limit7412

@limit7412 limit7412 commented Aug 5, 2026

Copy link
Copy Markdown
Owner

close #108

課題

crystal: latest が 1.21.0 に上がったことで、shards install の ameba postinstall がコンパイルできず CI が常に落ちる状態だった。差分の内容によらず、いま出す PR はすべて赤になる。

Error: undefined method 'next_string_array_token' for Crystal::Lexer

Crystal 1.21 で Crystal::Lexer#next_string_array_token が削除されたが、~> 1.6 で解決される最新の安定版 ameba 1.6.4 はこのメソッドに依存している。

変更内容

方針は「Crystal 固定 + ameba 追従」の併用。

  • .github/workflows/ci.yml
    • crystal: latestcrystal: 1.21.0。Crystal 側の更新でいきなり CI が壊れるのを防ぐ(今回は master への push が 3 週間無かったため気付くのが遅れた)
    • ameba のビルドステップを追加。追従先の ameba(1.7 系)は shard.yml から postinstall が外れており、shards install だけでは bin/ameba が作られない
  • serverless.yml: ビルドイメージを crystallang/crystal:latest-alpine1.21.0-alpine に固定(レビュー指摘対応 / 下記)
  • shard.yml: ameba を version: ~> 1.6 → 修正を含む master のコミットに固定
    • 対応(lexer.responds_to?(:next_string_array_token) での分岐)は master に入っているが、タグは v1.6.4 の次が v1.7.0-dev のみで安定版のリリースがまだ無い
    • ブランチ追従ではなくコミット固定にして、ビルドの再現性は保つ
  • shard.lock: 上記に合わせて更新
  • 既存コードの lint 修正 8 箇所(下記)

デプロイ用ビルドイメージの固定

CI だけを固定しても、serverless.ymlbefore:package:createDeploymentArtifactscrystallang/crystal:latest-alpine でアプリをコンパイルするため、本番成果物は検証済みのコンパイラとは別のもので作られていた。Crystal が更新されれば互換性が壊れた瞬間に deploy も落ちる。本 PR の趣旨がデプロイ側で達成できていなかったので、同じ 1.21.0 に揃えた。

次に上げるときに両方揃えられるよう、ci.ymlserverless.yml に相互参照のコメントを入れている。

ameba 1.7 系で新たに検出された指摘

ameba 側で Style/RedundantNilInControlExpression が追加され、Style/RedundantBegin / Style/HeredocIndent の検出範囲も広がったため、master 由来の既存コードが 8 箇所引っかかった。いずれも ameba が [Correctable] と判定する機械的な修正で、挙動は変わらない。ameba を上げた本 PR の責任範囲として同梱した。

  • 戻り値が nilable なメソッドの return nilreturnsrc/discord/models.cr ×4、src/github/models.crsrc/github/usecase.cr
  • ブロック直下の begin/rescue → ブロックの rescuesrc/main.cr
  • ヒアドキュメント本文を 2 スペースインデント(spec/github/models_spec.cr
    • <<- なので生成される文字列の内容は変わらない

今後

ameba 1.7 系がリリースされたら shard.ymlversion: 指定に戻す。その旨は shard.yml のコメントにも残した。Crystal を上げるときは ameba 側の対応状況と serverless.yml のビルドイメージのタグも合わせて確認する。

影響

このブロッカーで CI が赤のままだった PR:

いずれも本ブランチを取り込んで CI green を確認済み。本 PR が master にマージされれば、各 PR の差分からはこのコミット群が消える。

検証

CI green。shard.lock の解決は Installing ameba (1.7.0-dev at cdd58b3) で確認、固定したビルドイメージは deploy ジョブが実際にそれでコンパイルして成功していることで確認している。

実行環境から crystal-lang.org への到達がネットワークポリシーで遮断されており Crystal / shards をローカルにインストールできないため、検証は CI に依存している。shard.lockversion: は shards の GitResolver がコミット解決時に書き出す "#{spec.version.value}+git.commit.#{commit}" の形式に合わせた。

crystal: latest が 1.21.0 に上がったことで、shards install の ameba
postinstall がコンパイルできず CI が常に落ちる状態になっていた。
(undefined method 'next_string_array_token' for Crystal::Lexer)

- ci.yml の Crystal を 1.21.0 に固定し、Crystal 側の更新で不意に壊れないようにする
- ameba を Crystal 1.21 対応が入った master のコミットに固定する
  安定版(1.7 系)がリリースされたら version 指定に戻す

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MoGxJDiZa8c2E3PVAnxbK8
claude added 3 commits August 5, 2026 08:38
追従先の ameba(1.7 系)は shard.yml から postinstall が外れており、
shards install だけでは bin/ameba が作られず ./bin/ameba が 127 で落ちる。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MoGxJDiZa8c2E3PVAnxbK8
bin/ が存在せずリンクに失敗していた。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MoGxJDiZa8c2E3PVAnxbK8
追従先の ameba は Style/RedundantNilInControlExpression の追加と
Style/RedundantBegin / Style/HeredocIndent の検出範囲拡大により、
既存コード 8 箇所を指摘する。いずれも Correctable な機械的修正。

- 戻り値が nilable なメソッドの `return nil` を `return` に
- ブロック直下の begin/rescue をブロックの rescue に
- ヒアドキュメント本文を 2 スペースインデントに(文字列の内容は不変)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MoGxJDiZa8c2E3PVAnxbK8
@limit7412
limit7412 marked this pull request as ready for review August 9, 2026 15:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c580bf82fc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/ci.yml
serverless.yml のビルドは crystallang/crystal:latest-alpine を使っており、
CI だけ 1.21.0 に固定しても本番成果物は latest でコンパイルされていた。
Crystal が更新されると検証済みと違うコンパイラで成果物が作られ、互換性が
壊れていれば deploy も突然落ちる。ci.yml と同じ 1.21.0 に固定する。

PR #109 のレビュー指摘対応。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MoGxJDiZa8c2E3PVAnxbK8
@limit7412
limit7412 merged commit af06b36 into master Aug 9, 2026
2 checks passed
@limit7412
limit7412 deleted the claude/add-policy-to-issues-vdp4s3-108 branch August 9, 2026 15:38
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.

CI が ameba の postinstall で失敗する(Crystal 1.21 非対応)

2 participants