微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 Github Action 验证 .editorconfig 文件

如何解决使用 Github Action 验证 .editorconfig 文件

我想确保我的 Github 存储库中的任何拉取请求都遵循 .editorconfig(ASp.NET Core 5 C# 项目)中定义的规则。我发现 https://github.com/github/super-linter 使用 lint 代码

我在我的工作流程中添加了以下 linter.yml 文件

---
###########################
###########################
## Linter GitHub Actions ##
###########################
###########################
name: Lint Code Base

#
# Documentation:
# https://help.github.com/en/articles/workflow-Syntax-for-github-actions
#

#############################
# Start the job on all push #
#############################
on:
  push:
    branches-ignore: [main]
    # Remove the line above to run when pushing to main
  pull_request:
    branches: [main]

###############
# Set the Job #
###############
jobs:
  build:
    # Name the Job
    name: Lint Code Base
    # Set the agent to run on
    runs-on: ubuntu-latest

    ##################
    # Load all steps #
    ##################
    steps:
      ##########################
      # Checkout the code base #
      ##########################
      - name: Checkout Code
        uses: actions/checkout@v2
        with:
          # Full git history is needed to get a proper list of changed files within `super-linter`
          fetch-depth: 0

      ################################
      # Run Linter against codebase #
      ################################
      - name: Lint Code Base
        uses: github/super-linter@v4
        env:
          VALIDATE_ALL_CODEBASE: false
          DEFAULT_BRANCH: main
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

它成功了,但我没有看到它正在验证 Github 存储库根目录中的 .editorconfig 规则?我错过了什么吗?

解决方法

检查 Super Linter Github Action 中的 Environment VariablesEDITORCONFIG_FILE_NAME 文件的默认值为 .ecrc

因此,如果您的文件名为 .editorconfig,则您必须将其添加到操作参数列表中,如下所示:

- name: Lint Code Base
  uses: github/super-linter@v4
  env:
    VALIDATE_ALL_CODEBASE: false
    DEFAULT_BRANCH: main
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    EDITORCONFIG_FILE_NAME: .editorconfig

识别此文件后,Super Linter 操作将使用 editorconfig-checker 存储库对其进行检查。

编辑:根据注释,超级 linter 使用的 dotnet-format 也自动使用 .editorconf 文件。如果你想使用这个 linter 检查它,不需要设置 EDITORCONFIG_FILE_NAME。仅设置 VALIDATE_CSHARP: true

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?