From 4fef324823c6aed3ee45e3c38dbb5da84edc10a6 Mon Sep 17 00:00:00 2001 From: minorcell Date: Mon, 19 May 2025 12:43:29 +0800 Subject: [PATCH 1/3] ci: add code quality checks with HTMLHint and Stylelint workflows --- .github/workflows/quality.yml | 49 +++++++++++++++++++++++++++++++++++ .htmlhintrc | 22 ++++++++++++++++ size.yml | 10 ------- 3 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/quality.yml create mode 100644 .htmlhintrc delete mode 100644 size.yml diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml new file mode 100644 index 0000000..03d4c34 --- /dev/null +++ b/.github/workflows/quality.yml @@ -0,0 +1,49 @@ +name: Code Quality Checks + +on: [push, pull_request] + +jobs: + lint: + name: Run Linters + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + # HTMLHint 检查 + - name: Run HTMLHint + uses: tj-actions/htmlhint@v3 + with: + htmlhint_config: .htmlhintrc + + # 安装 Node.js + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + # 安装 Stylelint + - name: Install Stylelint + run: | + npm init -y + npm install stylelint stylelint-config-standard --save-dev + + # 创建基础配置(如果还没有) + - name: Create default .stylelintrc.json + run: | + echo '{ + "extends": "stylelint-config-standard" + }' > .stylelintrc.json + if: ${{ !hashFiles('.stylelintrc.json') }} + + # 执行 Stylelint + - name: Run Stylelint + run: npx stylelint "**/*.css" + + check-size: + name: Check Bundle Size + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: andresz1/size-limit-action@v1 diff --git a/.htmlhintrc b/.htmlhintrc new file mode 100644 index 0000000..223da32 --- /dev/null +++ b/.htmlhintrc @@ -0,0 +1,22 @@ +{ + "tagname-lowercase": true, + "attr-lowercase": true, + "attr-value-double-quotes": true, + "attr-value-not-empty": true, + "attr-no-duplication": true, + "doctype-first": true, + "tag-pair": true, + "tag-self-close": true, + "spec-char-escape": true, + "id-unique": true, + "src-not-empty": true, + "title-require": true, + "alt-require": true, + "doctype-html5": true, + "style-disabled": true, + "inline-style-disabled": true, + "inline-script-disabled": true, + "space-tab-mixed-disabled": "space", + "id-class-ad-disabled": true, + "href-abs-or-rel": false +} diff --git a/size.yml b/size.yml deleted file mode 100644 index 8ac2199..0000000 --- a/size.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: Check Bundle Size - -on: [pull_request] - -jobs: - check-size: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: andresz1/size-limit-action@v1 From 1aa34f94b8a81869e6d8fb354e6b8bacb55df0d7 Mon Sep 17 00:00:00 2001 From: minorcell Date: Mon, 19 May 2025 12:48:15 +0800 Subject: [PATCH 2/3] chore: add read permissions and remove redundant newline in quality workflow --- .github/workflows/quality.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index 03d4c34..a557cd5 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -2,6 +2,9 @@ name: Code Quality Checks on: [push, pull_request] +permissions: + contents: read + jobs: lint: name: Run Linters @@ -28,7 +31,6 @@ jobs: run: | npm init -y npm install stylelint stylelint-config-standard --save-dev - # 创建基础配置(如果还没有) - name: Create default .stylelintrc.json run: | @@ -46,4 +48,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: andresz1/size-limit-action@v1 + - uses: andresz1/size-limit-action@v1 \ No newline at end of file From b5bc179f7fada16633478b3df756b836efd629cd Mon Sep 17 00:00:00 2001 From: minorcell Date: Mon, 19 May 2025 12:52:08 +0800 Subject: [PATCH 3/3] chore: remove labeler workflow and update HTMLHint setup in quality workflow --- .github/workflows/label.yml | 22 ---------------------- .github/workflows/quality.yml | 16 +++++++++------- 2 files changed, 9 insertions(+), 29 deletions(-) delete mode 100644 .github/workflows/label.yml diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml deleted file mode 100644 index 4613569..0000000 --- a/.github/workflows/label.yml +++ /dev/null @@ -1,22 +0,0 @@ -# This workflow will triage pull requests and apply a label based on the -# paths that are modified in the pull request. -# -# To use this workflow, you will need to set up a .github/labeler.yml -# file with configuration. For more information, see: -# https://github.com/actions/labeler - -name: Labeler -on: [pull_request_target] - -jobs: - label: - - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write - - steps: - - uses: actions/labeler@v4 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index a557cd5..3dd4348 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -14,17 +14,17 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - # HTMLHint 检查 - - name: Run HTMLHint - uses: tj-actions/htmlhint@v3 - with: - htmlhint_config: .htmlhintrc - # 安装 Node.js - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: 20 + + # 安装并运行 HTMLHint + - name: Install and Run HTMLHint + run: | + npm install htmlhint --save-dev + npx htmlhint "**/*.html" --config .htmlhintrc # 安装 Stylelint - name: Install Stylelint @@ -48,4 +48,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: andresz1/size-limit-action@v1 \ No newline at end of file + - uses: andresz1/size-limit-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file