From 73e83b4cb5b1adcd0463fc32d558d71a391b9264 Mon Sep 17 00:00:00 2001 From: NtskwK Date: Fri, 16 Jan 2026 09:13:38 +0800 Subject: chore: add UI linter workflow with oxlint and oxfmt --- .github/workflows/check.yml | 2 +- .github/workflows/lint.yml | 93 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/lint.yml (limited to '.github/workflows') diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 0cbcf35..702cc0a 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -4,7 +4,7 @@ on: push: paths: - "ui/**" - - ".github/workflows/ui_check.yml" + - ".github/workflows/check.yml" pull_request: branches: ["main", "master", "dev"] workflow_dispatch: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..c8d1b27 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,93 @@ +name: UI Linter + +on: + workflow_run: + workflows: ["UI Checker"] + types: + - completed + workflow_dispatch: + inputs: + commit_message: + description: "Commit Message" + type: string + required: false + +jobs: + check: + if: | + (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || + github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + steps: + - name: Check if it is a direct push + id: check_push + run: | + if [[ "${{ github.event_name }}" == "workflow_run" ]]; then + if [[ "${{ github.event.workflow_run.event }}" == "pull_request" ]]; then + echo "PR detected. Exiting." + echo "is_pr=True" >> $GITHUB_OUTPUT + else + echo "Direct push or other event detected. Proceeding..." + echo "is_pr=False" >> $GITHUB_OUTPUT + fi + else + echo "Manual trigger detected. Proceeding..." + echo "is_pr=False" >> $GITHUB_OUTPUT + fi + + - name: Checkout repository + if: steps.check_push.outputs.is_pr != 'True' + uses: actions/checkout@v6 + with: + show-progress: false + persist-credentials: false + + - name: Install pnpm + if: steps.check_push.outputs.is_pr != 'True' + uses: pnpm/action-setup@v4 + with: + version: 9 + run_install: true + package_json_file: ui/package.json + + - name: Install Node.js + if: steps.check_push.outputs.is_pr != 'True' + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: "pnpm" + cache-dependency-path: ui/pnpm-lock.yaml + + - run: pnpm format + working-directory: ui + + - run: pnpm lint:fix + working-directory: ui + + - name: Commit changes + id: commit_changes + if: steps.check_push.outputs.is_pr != 'True' + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + git add . + + if git diff-index --quiet HEAD --; then + echo "No changes to commit" + else + commit_msg="${{ github.event.inputs.commit_message }}" + if [ -z "$commit_msg" ]; then + commit_msg="chore: Auto Templates Optimization" + fi + git commit -m "$commit_msg" -m "Triggered by ${{github.sha}}" -m "[skip changelog]" + git pull origin $(git rev-parse --abbrev-ref HEAD) --unshallow --rebase + echo "have_commits=True" >> $GITHUB_OUTPUT + fi + + - name: Push changes + if: steps.check_push.outputs.is_pr != 'True' && steps.commit_changes.outputs.have_commits == 'True' && github.repository_owner == 'MAA1999' + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} -- cgit v1.2.3-70-g09d2 From 36138be8e858cb35845014421aeaa7fa6a426217 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Fri, 16 Jan 2026 09:26:30 +0800 Subject: refactor(ci): Refactor lint workflow for auto fixes on push Updated the lint workflow to automatically fix issues on push to main or dev branches. Changed the checkout action version and adjusted the commit message for auto commits. --- .github/workflows/lint.yml | 83 ++++++++++------------------------------------ 1 file changed, 17 insertions(+), 66 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c8d1b27..5188f4e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,62 +1,35 @@ -name: UI Linter +name: UI Auto Fix on: - workflow_run: - workflows: ["UI Checker"] - types: - - completed + push: + branches: ["main", "dev"] + paths: + - "ui/**" workflow_dispatch: - inputs: - commit_message: - description: "Commit Message" - type: string - required: false jobs: - check: - if: | - (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || - github.event_name == 'workflow_dispatch' + fix: + if: github.event_name != 'pull_request' runs-on: ubuntu-latest steps: - - name: Check if it is a direct push - id: check_push - run: | - if [[ "${{ github.event_name }}" == "workflow_run" ]]; then - if [[ "${{ github.event.workflow_run.event }}" == "pull_request" ]]; then - echo "PR detected. Exiting." - echo "is_pr=True" >> $GITHUB_OUTPUT - else - echo "Direct push or other event detected. Proceeding..." - echo "is_pr=False" >> $GITHUB_OUTPUT - fi - else - echo "Manual trigger detected. Proceeding..." - echo "is_pr=False" >> $GITHUB_OUTPUT - fi - - - name: Checkout repository - if: steps.check_push.outputs.is_pr != 'True' - uses: actions/checkout@v6 + - uses: actions/checkout@v4 with: - show-progress: false - persist-credentials: false - + token: ${{ secrets.GITHUB_TOKEN }} + - name: Install pnpm - if: steps.check_push.outputs.is_pr != 'True' uses: pnpm/action-setup@v4 with: version: 9 - run_install: true - package_json_file: ui/package.json - name: Install Node.js - if: steps.check_push.outputs.is_pr != 'True' uses: actions/setup-node@v4 with: node-version: 22 cache: "pnpm" - cache-dependency-path: ui/pnpm-lock.yaml + cache-dependency-path: "ui/pnpm-lock.yaml" + + - run: pnpm install + working-directory: ui - run: pnpm format working-directory: ui @@ -65,29 +38,7 @@ jobs: working-directory: ui - name: Commit changes - id: commit_changes - if: steps.check_push.outputs.is_pr != 'True' - run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - - git add . - - if git diff-index --quiet HEAD --; then - echo "No changes to commit" - else - commit_msg="${{ github.event.inputs.commit_message }}" - if [ -z "$commit_msg" ]; then - commit_msg="chore: Auto Templates Optimization" - fi - git commit -m "$commit_msg" -m "Triggered by ${{github.sha}}" -m "[skip changelog]" - git pull origin $(git rev-parse --abbrev-ref HEAD) --unshallow --rebase - echo "have_commits=True" >> $GITHUB_OUTPUT - fi - - - name: Push changes - if: steps.check_push.outputs.is_pr != 'True' && steps.commit_changes.outputs.have_commits == 'True' && github.repository_owner == 'MAA1999' - uses: ad-m/github-push-action@master + uses: stefanzweifel/git-auto-commit-action@v5 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.ref }} + commit_message: "style: auto format and lint fix [skip ci]" + file_pattern: "ui/**" -- cgit v1.2.3-70-g09d2 From 3fa38e2d8a081db6f41ef65c37157442f77845d4 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Fri, 16 Jan 2026 09:30:39 +0800 Subject: chore(ci): Rename workflow from 'UI Auto Fix' to 'UI Auto Lint' --- .github/workflows/lint.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5188f4e..5c4a69d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: UI Auto Fix +name: UI Auto Lint on: push: @@ -7,6 +7,9 @@ on: - "ui/**" workflow_dispatch: +permissions: + contents: write + jobs: fix: if: github.event_name != 'pull_request' -- cgit v1.2.3-70-g09d2 From a3a1991fbd04dbe283734a8826e60d05ab3fa92a Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Fri, 16 Jan 2026 09:33:04 +0800 Subject: fix(ci): Enhance GitHub Actions workflow with lint and format Add linting and formatting checks to workflow. --- .github/workflows/check.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 702cc0a..58fc378 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -6,7 +6,9 @@ on: - "ui/**" - ".github/workflows/check.yml" pull_request: - branches: ["main", "master", "dev"] + paths: + - "ui/**" + - ".github/workflows/check.yml" workflow_dispatch: jobs: @@ -32,3 +34,10 @@ jobs: - run: pnpm check working-directory: ui + + - run: pnpm lint + working-directory: ui + + - run: pnpm format --check + working-directory: ui + -- cgit v1.2.3-70-g09d2