|
| 1 | +name: Lint & Format |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: write |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [main] |
| 9 | + |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: lint |
| 14 | + cancel-in-progress: false |
| 15 | + |
| 16 | +jobs: |
| 17 | + lint: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + - name: Setup Git |
| 25 | + run: | |
| 26 | + echo '${{ github.token }}' | gh auth login --with-token |
| 27 | + gh auth status |
| 28 | + gh auth setup-git |
| 29 | + git config --global user.name 'github-actions[bot]' |
| 30 | + git config --global user.email 'github-actions[bot]@users.noreply.github.com' |
| 31 | +
|
| 32 | + - name: Setup Node |
| 33 | + uses: actions/setup-node@v4 |
| 34 | + with: |
| 35 | + node-version-file: package.json |
| 36 | + check-latest: true |
| 37 | + #cache: yarn |
| 38 | + |
| 39 | + - name: Setup yarn |
| 40 | + run: | |
| 41 | + corepack enable |
| 42 | + yarn set version stable |
| 43 | +
|
| 44 | + - name: Get yarn cachedir |
| 45 | + id: yarn-cachedir |
| 46 | + run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT |
| 47 | + |
| 48 | + - name: Cache yarn |
| 49 | + uses: actions/cache@v4 |
| 50 | + with: |
| 51 | + path: ${{ steps.yarn-cachedir.outputs.dir }} |
| 52 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 53 | + restore-keys: | |
| 54 | + ${{ runner.os }}-yarn- |
| 55 | +
|
| 56 | + - name: Install dependencies |
| 57 | + run: yarn install |
| 58 | + |
| 59 | + - name: Cpp Lint (clang-format & clang-tidy) |
| 60 | + uses: cpp-linter/cpp-linter-action@v2 |
| 61 | + env: |
| 62 | + GITHUB_TOKEN: ${{ github.token }} |
| 63 | + with: |
| 64 | + style: file |
| 65 | + thread-comments: update |
| 66 | + continue-on-error: true |
| 67 | + |
| 68 | + - name: ESLint (+vue +prettier) |
| 69 | + run: yarn run eslint --fix --ignore-pattern .gitignore |
| 70 | + continue-on-error: true |
| 71 | + |
| 72 | + - name: Prettier |
| 73 | + run: yarn run prettier --write . |
| 74 | + continue-on-error: true |
| 75 | + |
| 76 | + - name: Markdown Lint |
| 77 | + uses: DavidAnson/markdownlint-cli2-action@v19 |
| 78 | + with: |
| 79 | + globs: "**/*.{md,markdown} !node_modules" |
| 80 | + fix: true |
| 81 | + continue-on-error: true |
| 82 | + |
| 83 | + - name: Autocorrect Lint |
| 84 | + id: autocorrect-lint |
| 85 | + uses: huacnlee/autocorrect-action@v2 |
| 86 | + env: |
| 87 | + REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }} |
| 88 | + with: |
| 89 | + use_npm: true |
| 90 | + args: --lint --config 'https://raw.githubusercontent.com/huacnlee/autocorrect/main/.autocorrectrc.template' |
| 91 | + reviewdog: true |
| 92 | + continue-on-error: true |
| 93 | + - name: Autocorrect Fix |
| 94 | + if: steps.autocorrect-lint.outcome == 'failure' |
| 95 | + uses: huacnlee/autocorrect-action@v2 |
| 96 | + with: |
| 97 | + use_npm: true |
| 98 | + args: --fix --config 'https://raw.githubusercontent.com/huacnlee/autocorrect/main/.autocorrectrc.template' |
| 99 | + continue-on-error: true |
| 100 | + - name: Create PullRequest |
| 101 | + run: | |
| 102 | + git branch -f lint |
| 103 | + git switch lint |
| 104 | + git add . |
| 105 | + git commit -m "lint:${{ github.ref }}" |
| 106 | + git push -f origin lint |
| 107 | + gh pr create --fill |
| 108 | + continue-on-error: true |
0 commit comments