Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 17, 2025

User description

  • Analyze the current CI workflow to understand the Atlas migrate lint implementation
  • Identify the issue: current CI creates new comments on every push instead of updating a single comment
  • Verify that gh CLI supports --edit-last and --create-if-none flags
  • Modify the migrate-lint job in .github/workflows/ci.yaml to use --edit-last and --create-if-none
  • Test the modified workflow to ensure it behaves correctly
  • Verify the change addresses the issue by reducing comment clutter

The current migrate-lint job in CI creates a new comment every time Atlas migrate lint runs, causing PR comment spam. This change modifies the workflow to update a single comment instead using GitHub CLI's --edit-last and --create-if-none flags.

Changes made:

  • Modified .github/workflows/ci.yaml in the migrate-lint job
  • Added --edit-last --create-if-none flags to the gh pr comment command
  • This ensures that on first run a comment is created, and on subsequent runs the same comment is updated

Expected behavior:

  • First migration lint run: Creates a new comment with lint results
  • Subsequent runs: Updates the existing comment with new lint results
  • No more comment spam on PRs

Fixes #1365.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


PR Type

Enhancement, Bug fix


Description

  • PRコメントを単一更新に変更

  • Lint結果をバッジ風アイコン表示

  • 詳細出力をdetailsで折りたたみ

  • push時はコメントせず早期終了


Diagram Walkthrough

flowchart LR
  lint["atlas migrate lint 実行"] -- "出力/終了コード取得" --> format["本文(body.txt)生成<br/>✅/✘ と details を付与"]
  format -- "event != pull_request" --> exit["コメントせず終了"]
  format -- "pull_request" --> gh["gh pr comment<br/>--edit-last --create-if-none<br/>--body-file body.txt"]
  gh -- "成功" --> return["終了コードを lint に合わせて返す"]
  gh -- "失敗" --> fail["エラー出力して失敗"]
Loading

File Walkthrough

Relevant files
Enhancement
ci.yaml
migrate lintコメント更新化と出力整形・堅牢化                                                         

.github/workflows/ci.yaml

  • Lint出力を変数化し終了コード保持
  • ✅/✘アイコンとdetailsで本文生成
  • gh pr commentに--edit-last/--create-if-none追加
  • pull_request以外はコメントせず早期終了とエラーハンドリング
+34/-9   

@codecov
Copy link

codecov bot commented Sep 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.73%. Comparing base (c5b307b) to head (753043d).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1366   +/-   ##
=======================================
  Coverage   49.73%   49.73%           
=======================================
  Files         134      134           
  Lines       11738    11738           
=======================================
  Hits         5838     5838           
  Misses       5600     5600           
  Partials      300      300           

☔ 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.

@github-actions
Copy link

github-actions bot commented Sep 18, 2025

Migrate lint ✅

Lint output

@ikura-hamu ikura-hamu marked this pull request as ready for review September 18, 2025 06:03
@ikura-hamu ikura-hamu merged commit 1ff97cf into main Sep 18, 2025
12 checks passed
@ikura-hamu ikura-hamu deleted the copilot/fix-1365 branch September 18, 2025 06:04
@github-actions
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
コメント失敗時の寛容化

gh pr
commentはPRがクローズ済みや権限不足でも失敗し、現在はジョブを即失敗させます。lint自体の結果を優先すべきなので、コメント投稿失敗は警告に留め、ジョブの終了コードはLINT_EXIT_CODEを返すようにしてください。

.github/workflows/ci.yaml [128-136]

 gh pr comment ${{ github.event.pull_request.number }} \
   --edit-last --create-if-none \
-  --body-file body.txt
-GH_COMMENT_EXIT=$?
+  --body-file body.txt || {
+    echo "Warning: failed to post PR comment" >&2
+  }
 
-if [ $GH_COMMENT_EXIT -ne 0 ]; then
-  echo "Failed to post PR comment" >&2
-  exit 1
-fi
-
Suggestion importance[1-10]: 7

__

Why: Suggestion accurately targets the comment block and proposes not failing the job on comment errors, prioritizing the linter exit code; useful but not critical.

Medium
非PRイベントの二重ガード


pull_request_targetmerge_groupなどPRに紐づくイベントでもコメントはできません。誤検知を避けるため、コメント実行をpull_requestイベントに限定し、それ以外は確実にスキップするガードをgh呼び出し直前にも入れてください。

.github/workflows/ci.yaml [123-126]

 if [ "${{ github.event_name }}" != "pull_request" ]; then
   exit $LINT_EXIT_CODE
 fi
 
+# guard again before commenting
+if [ -z "${{ github.event.pull_request.number }}" ]; then
+  exit $LINT_EXIT_CODE
+fi
+
Suggestion importance[1-10]: 5

__

Why: Adding an extra guard before commenting is harmless and can reduce edge-case failures, but the PR already checks event_name; impact is moderate.

Low
Possible issue
出力取得を堅牢化

atlasの実行結果をコマンド置換で変数へ代入すると、失敗時でもset
+e
によりジョブが成功扱いのまま進行します。LINT_EXIT_CODEは取得できていますが、標準出力が多い場合に出力切り捨てやヒアドキュメント整形時の改行問題が起きることがあります。teeでログをファイルにも保存し、後段ではファイルから確実に読み込む形にして堅牢性を上げてください。

.github/workflows/ci.yaml [102-103]

-LINT_OUTPUT="$(atlas migrate lint --env ci 2>&1)"
-LINT_EXIT_CODE=$?
+atlas migrate lint --env ci 2>&1 | tee lint_output.txt
+LINT_EXIT_CODE=${PIPESTATUS[0]}
Suggestion importance[1-10]: 6

__

Why: Replacing command substitution with tee and using PIPESTATUS is a reasonable robustness improvement and correctly maps to the shown lines, but it's an optional enhancement rather than a critical fix.

Low

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.

atlasのmigrate lintのPRコメントを1つだけにする

2 participants