-
Notifications
You must be signed in to change notification settings - Fork 3
Lint欲の秋 ~CIを添えて~ #1964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lint欲の秋 ~CIを添えて~ #1964
Conversation
…r-2 into feat/nose/rails-lint
| # 同じブランチ(ref)の並行実行を抑止(後から来た実行を優先) | ||
| concurrency: | ||
| group: rubocop-${{ github.ref }} | ||
| cancel-in-progress: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
書いたことなかった
学び
|
|
||
| # ② 自動修正の差分があればコミット&push | ||
| # - push のとき:そのまま | ||
| # - PR のとき:同一リポのブランチ(フォーク以外)のみ push 許可 | ||
| # - [skip ci]: そのコミットで再度 CI を走らせない抑制用タグ | ||
| - name: Commit auto-fixed files | ||
| if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.repository == github.event.pull_request.head.repo.full_name) | ||
| run: | | ||
| if ! git diff --quiet; then | ||
| git config user.name "github-actions[bot]" # bot としてコミット | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
| git add api/ | ||
| git commit -m "chore(rubocop): auto fix (-A) [skip ci]" | ||
| git push | ||
| else | ||
| echo "No changes to commit." | ||
| fi | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これ、短くできます
おそらく下の感じでいける
https://github.com/NUTFes/group-manager-2/blob/gm3/develop/.github/workflows/user-code-quality.yml
# 変更があれば、コミット&プッシュする
- name: Commit formatted files
uses: EndBug/add-and-commit@v9
with:
author_name: GitHub Action
author_email: action@github.com
message: "chore: auto format code"
push: true
hikahana
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多分おそらくメイビーLGTM
…up-manager-2 into feat/harata/rails-lint-and-ci
対応Issue
resolve #0
概要
実装詳細
RuboCopの導入
api/GemfileにRuboCopを追加.rubocop.ymlでRuboCopの設定をカスタマイズ.rubocop_todo.ymlで既存の違反を一時的に無視コードの自動修正
Style/FrozenStringLiteralComment、Style/SymbolArray等のスタイル違反を修正dependent: :destroyの追加等の機能改善GitHub Actionsワークフローの実装
api-code-quality.ymlでRuboCop自動修正・チェック機能を追加push:api/**変更時に起動(全ブランチ)。pull_request: ベースgm3/developかつapi/**変更時に起動。rubocop -A --no-serverを実行(ここでは失敗させず、自動修正のみ適用)。[skip ci]を付与してループ抑止。rubocop --parallel --format githubで最終チェック(残違反があればジョブを fail。PR には行内アノテーションが表示される)。concurrencyにより同一 ref の並行実行をキャンセル。if: github.actor != 'github-actions[bot]'で bot の自動コミットによる再実行をスキップ。github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>。画面スクリーンショット等
テスト項目
api/**を変更した PR / push でワークフローが起動する。備考