🔖
dotnet formatでのlint checkをgithub actionsで実行する
super-linter
super-linterというやつがなんでもやってくれてすごい.
試しに設定してみた.
.github/workflows/lint.yml
name: Lint C# code 👮♀️
on: [push, pull_request]
jobs:
build:
name: Lint Code
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Lint code
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
実行してみると下記のような感じでformatに従ってないときにfailしてくれた
2021-12-18 14:18:03 [INFO] File:[/github/workspace/Assets/Scripts/SampleButton.cs]
2021-12-18 14:18:05 [ERROR] Found errors in [dotnet-format] linter!
2021-12-18 14:18:05 [ERROR] Error code: 2. Command output:
diff的にはこんな感じ.
$ git diff
diff --git a/Assets/Scripts/SampleButton.cs b/Assets/Scripts/SampleButton.cs
index 5267e8d..1c12de0 100644
--- a/Assets/Scripts/SampleButton.cs
+++ b/Assets/Scripts/SampleButton.cs
@@ -6,7 +6,8 @@ namespace Sample
[RequireComponent(typeof(Button))]
public class SampleButton : MonoBehaviour
{
- private void Start() {
+ private void Start()
+ {
this.GetComponent<Button>().onClick.AddListener(() =>
{
UnityEngine.Debug.Log("Hoge");
.editorconfigでいろいろフォーマット設定できるっぽい. PR reviewに仕込んでおくとよさそう!
Discussion