■ はじめに
Github Actions で Scala の Linter を実行する
目次
【1】Scala Linter 1)scalafmt 2)scalastyle 【2】サンプル
【1】Scala Linter
https://dk521123.hatenablog.com/entry/2023/01/25/000000
でも紹介したが。。。 1)scalafmt 2)scalastyle
1)scalafmt
* Scala の フォーマッタ
コマンド
sbt scalafmt
https://scalameta.org/scalafmt/docs/installation.html#task-keys
Command | Explantions |
---|---|
myproject/scalafmt | Format main sources of myproject project |
myproject/Test/scalafmt | Format test sources of myproject project |
scalafmtCheck | Check if the scala sources under the project have been formatted. |
scalafmtSbt | Format .sbt and project/.scala files. |
scalafmtSbtCheck | Check if the files have been formatted by scalafmtSbt. |
scalafmtOnly |
Format specified files listed. |
scalafmtAll or scalafmtCheckAll | Execute the scalafmt or scalafmtCheck task for all configurations in which it is enabled (since v2.0.0-RC5) |
2)scalastyle
* Scala の Linter => Scala のコーディングスタイルチェッカー
コマンド
sbt scalastyle
【2】サンプル
name: RunScalaLinters on: workflow_dispatch: jobs: sample-job: runs-on: ubuntu-latest steps: - name: Run checkout uses: actions/checkout@v4 - name: Setup JDK uses: actions/setup-java@v4 with: java-version: '11' - name: Run sbt format run: sbt scalafmtAll - name: Run sbt linter run: sbt scalastyle - uses: stefanzweifel/git-auto-commit-action@v3.0.0 with: commit_message: Apply Change for Scala linters
参考文献
scalafmtのはじめかた #GitHubActions - Qiita
関連記事
Github ~ 入門編 ~
https://dk521123.hatenablog.com/entry/2019/07/18/234652
Github Actions ~ 基礎知識編 ~
https://dk521123.hatenablog.com/entry/2021/11/04/142835
Github Actions ~ 入門編 ~
https://dk521123.hatenablog.com/entry/2022/06/16/151443
Github Actions ~ 基本編 ~
https://dk521123.hatenablog.com/entry/2023/12/22/195715
Github Actions ~ 自動コミット ~
https://dk521123.hatenablog.com/entry/2024/03/14/100841
SBT ~ sbtプラグイン ~
https://dk521123.hatenablog.com/entry/2023/01/25/000000
SBT ~ 入門編 ~
https://dk521123.hatenablog.com/entry/2023/03/22/000000