From 35fe9c3296e04c8338c8e93ac86b69fbd6c0b10b Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 1 May 2024 17:01:59 +0800 Subject: [PATCH] GHA CI: add file health checking --- .github/workflows/ci_file_health.yaml | 25 ++++++++++++++++ .../workflows/helper/pre-commit/.typos.toml | 18 +++++++++++ .pre-commit-config.yaml | 30 +++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 .github/workflows/ci_file_health.yaml create mode 100644 .github/workflows/helper/pre-commit/.typos.toml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/ci_file_health.yaml b/.github/workflows/ci_file_health.yaml new file mode 100644 index 0000000..c9c981a --- /dev/null +++ b/.github/workflows/ci_file_health.yaml @@ -0,0 +1,25 @@ +name: CI - File health + +on: [pull_request, push] + +permissions: {} + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: ${{ github.head_ref != '' }} + +jobs: + ci: + name: Check + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install tools + uses: actions/setup-python@v5 + with: + python-version: "*" + + - name: Check files + uses: pre-commit/action@v3.0.1 diff --git a/.github/workflows/helper/pre-commit/.typos.toml b/.github/workflows/helper/pre-commit/.typos.toml new file mode 100644 index 0000000..0f33373 --- /dev/null +++ b/.github/workflows/helper/pre-commit/.typos.toml @@ -0,0 +1,18 @@ +# https://github.com/crate-ci/typos/blob/master/docs/reference.md +# https://github.com/crate-ci/typos/blob/master/docs/design.md#identifiers-and-words + +# try adding to `identifiers` list first, if doesn't work then `words` list + +[default.extend-identifiers] +additionals = "additionals" +caf = "caf" +curren = "curren" +FO = "FO" +ket = "ket" +Q_INVOKABLE = "Q_INVOKABLE" +switchs = "switchs" +ths = "ths" + +[default.extend-words] +BA = "BA" +helo = "helo" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a799b79 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,30 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks.git + rev: v4.5.0 + hooks: + - id: fix-byte-order-marker + name: Check file encoding (UTF-8 without BOM) + + - id: mixed-line-ending + name: Check line ending character (LF) + args: ["--fix=lf"] + + - id: end-of-file-fixer + name: Check trailing newlines + + - id: trailing-whitespace + name: Check trailing whitespaces + + - repo: https://github.com/codespell-project/codespell.git + rev: v2.2.6 + hooks: + - id: codespell + name: Check spelling (codespell) + args: ["--ignore-words-list", ""] + + - repo: https://github.com/crate-ci/typos.git + rev: v1.16.18 + hooks: + - id: typos + name: Check spelling (typos) + args: ["--config", ".github/workflows/helper/pre-commit/.typos.toml"]