From 5b4a21364d6e19c0ca3c576c2ba0e813e3d7a546 Mon Sep 17 00:00:00 2001 From: LV Mingze <18231950177@163.com> Date: Fri, 11 Oct 2024 20:33:27 +0800 Subject: [PATCH 01/26] Create lint.yml --- .github/workflows/lint.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..ffc0add --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,29 @@ +name: Lint Code + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: '1.20' + + - name: Install golangci-lint + run: | + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.49.0 + + - name: Run golangci-lint + run: golangci-lint run ./... From 6a50c242d1b4e2d287103b562d53a1fd526806b6 Mon Sep 17 00:00:00 2001 From: LV Mingze <18231950177@163.com> Date: Fri, 11 Oct 2024 20:37:58 +0800 Subject: [PATCH 02/26] Update lint.yml --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ffc0add..3197d6a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: '1.20' + go-version: '1.23.1' - name: Install golangci-lint run: | From 3f6a98dfdf23b072e2ecb47276263af4abc1485a Mon Sep 17 00:00:00 2001 From: LV Mingze <18231950177@163.com> Date: Fri, 11 Oct 2024 20:41:58 +0800 Subject: [PATCH 03/26] Update lint.yml --- .github/workflows/lint.yml | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3197d6a..68527d2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,29 +1,27 @@ -name: Lint Code +name: Go Code Style Check on: push: - branches: - - main + branches: [main] pull_request: - branches: - - main jobs: - lint: + code_style_check: runs-on: ubuntu-latest steps: - - name: Check out code - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: - go-version: '1.23.1' + go-version: 1.23.1 - - name: Install golangci-lint - run: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.49.0 + - name: Run gofmt + run: gofmt -l -w. - - name: Run golangci-lint - run: golangci-lint run ./... + - name: Run golint + run: golint./... + + - name: Run go vet + run: go vet./... From 6ad8820cf59aa90f29ba678acfcb060c304aa82f Mon Sep 17 00:00:00 2001 From: LV Mingze <18231950177@163.com> Date: Fri, 11 Oct 2024 20:46:34 +0800 Subject: [PATCH 04/26] Update lint.yml --- .github/workflows/lint.yml | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 68527d2..ef108c5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,27 +1,21 @@ -name: Go Code Style Check - +name: Commitlint on: push: - branches: [main] + branches: ["main"] pull_request: - + branches: ["main"] + workflow_dispatch: jobs: - code_style_check: + commitlint: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: 1.23.1 - - - name: Run gofmt - run: gofmt -l -w. - - - name: Run golint - run: golint./... - - - name: Run go vet - run: go vet./... + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-node@v3 + with: + node-version: '20' + - run: npm install -g @commitlint/cli @commitlint/config-conventional + - run: | + echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js + - run: commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose From a814804752d824c38bc55d5e85cbc8ad82b84bbf Mon Sep 17 00:00:00 2001 From: LV Mingze <18231950177@163.com> Date: Fri, 11 Oct 2024 20:51:36 +0800 Subject: [PATCH 05/26] Update lint.yml --- .github/workflows/lint.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ef108c5..496f5cc 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,21 +1,21 @@ -name: Commitlint -on: - push: - branches: ["main"] - pull_request: - branches: ["main"] - workflow_dispatch: +name: TechMojotvGo +on: push jobs: - commitlint: + build: + name: Build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Set up Go 1.12 + uses: actions/setup-go@v1 with: - fetch-depth: 0 - - uses: actions/setup-node@v3 - with: - node-version: '20' - - run: npm install -g @commitlint/cli @commitlint/config-conventional - - run: | - echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js - - run: commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose + go-version: 1.23.1 + id: go + + - name: Check out source code + uses: actions/checkout@v1 + + - name: Build + run: go build . + + - name: Test + run: go test -v . From 1d6f92bdd89446ef0bb96e399139a4e68b8a6797 Mon Sep 17 00:00:00 2001 From: LV Mingze <18231950177@163.com> Date: Fri, 11 Oct 2024 20:51:58 +0800 Subject: [PATCH 06/26] Update lint.yml --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 496f5cc..822bcf2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,7 +5,7 @@ jobs: name: Build runs-on: ubuntu-latest steps: - - name: Set up Go 1.12 + - name: Set up Go 1.23.1 uses: actions/setup-go@v1 with: go-version: 1.23.1 From 54d0ae337b7b517f6751d9e581bae992cf21949e Mon Sep 17 00:00:00 2001 From: LV Mingze <18231950177@163.com> Date: Fri, 11 Oct 2024 20:52:28 +0800 Subject: [PATCH 07/26] Update lint.yml --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 822bcf2..9006940 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,7 +3,7 @@ on: push jobs: build: name: Build - runs-on: ubuntu-latest + runs-on: windows-latest steps: - name: Set up Go 1.23.1 uses: actions/setup-go@v1 From 9d4a7862d38f460a6eb8170f4b53a93ddb65c3cc Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Fri, 11 Oct 2024 23:25:54 +0800 Subject: [PATCH 08/26] Update commitlint workflow to exclude main branch and dynamically configure commitlint --- .github/workflows/commitlint.yml | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index 21f23f6..cbfc5da 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -10,20 +10,33 @@ on: jobs: commitlint: runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 + - name: Checkout Repository + uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/setup-node@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 with: node-version: '20' - - run: npm install -g @commitlint/cli @commitlint/config-conventional - - run: | - echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js - - name: Check commits + + - name: Install Dependencies + run: | + npm ci + npm install @commitlint/cli @commitlint/config-conventional + + - name: Configure Commitlint + run: | + # 确保 .commitlintrc.js 存在 + touch .commitlintrc.js + echo "module.exports = {extends: ['@commitlint/config-conventional']};"> .commitlintrc.js + + - name: Check Commits run: | if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then - commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose + npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose else - commitlint --from $(git rev-list --max-parents=0 HEAD) --to HEAD --verbose - fi + npx commitlint --from $(git rev-list --max-parents=0 HEAD) --to HEAD --verbose + fi \ No newline at end of file From 45789e9638af2d9c618f6468b190407f48c8e860 Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Fri, 11 Oct 2024 23:40:51 +0800 Subject: [PATCH 09/26] Update commitlint workflow to exclude main branch and dynamically configure commitlint --- .github/workflows/commitlint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index cbfc5da..29dd4f2 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -5,7 +5,7 @@ on: branches-ignore: ["main"] # 排除 main 分支的 push 事件 pull_request: branches-ignore: ["main"] # 排除 main 分支的 pull request 事件 - workflow_dispatch: + workflow_dispatch: # 允许手动触发工作流程 jobs: commitlint: From ddbed8aa89c57f7a99a67c04aa682e664c0510ad Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 16:08:56 +0800 Subject: [PATCH 10/26] Update commitlint.yml to ensure it triggers on push/pull_request and can be dispatched manually --- .github/workflows/commitlint.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index 29dd4f2..e8fb733 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -2,9 +2,11 @@ name: Commitlint on: push: - branches-ignore: ["main"] # 排除 main 分支的 push 事件 + branches-ignore: + - "main" # 排除 main 分支的 push 事件 pull_request: - branches-ignore: ["main"] # 排除 main 分支的 pull request 事件 + branches-ignore: + - "main" # 排除 main 分支的 pull_request 事件 workflow_dispatch: # 允许手动触发工作流程 jobs: From fe3fcf297cecedc25205cbbecfa4eb7dc5080f5d Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 16:25:11 +0800 Subject: [PATCH 11/26] Update commitlint.yml to ensure it triggers on push/pull_request and can be dispatched manually --- .github/workflows/commitlint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index e8fb733..a1b9ffe 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -2,10 +2,10 @@ name: Commitlint on: push: - branches-ignore: + branches-ignore: - "main" # 排除 main 分支的 push 事件 pull_request: - branches-ignore: + branches-ignore: - "main" # 排除 main 分支的 pull_request 事件 workflow_dispatch: # 允许手动触发工作流程 From 9eea77caa2fb5678627c3f0ae00015a813a8a221 Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 16:32:25 +0800 Subject: [PATCH 12/26] Update commitlint.yml to use latest versions of actions and fix Node.js version --- .github/workflows/commitlint.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index a1b9ffe..b3b73b8 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -15,14 +15,12 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 + uses: actions/checkout@v4 # 使用最新版本的 checkout 动作 - name: Set up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 # 使用最新版本的 setup-node 动作 with: - node-version: '20' + node-version: '20' # 显式指定 Node.js 版本 - name: Install Dependencies run: | From e1a6f98d9dc6a1221186ebe5f459f242afb65cfe Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 16:40:06 +0800 Subject: [PATCH 13/26] Update commitlint.yml to ensure package-lock.json exists and dependencies are installed correctly --- .github/workflows/commitlint.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index b3b73b8..cd65cd7 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -15,17 +15,24 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@v4 # 使用最新版本的 checkout 动作 + uses: actions/checkout@v3 # 使用最新版本的 checkout 动作 - name: Set up Node.js - uses: actions/setup-node@v4 # 使用最新版本的 setup-node 动作 + uses: actions/setup-node@v3 # 使用最新版本的 setup-node 动作 with: node-version: '20' # 显式指定 Node.js 版本 + - name: Generate package-lock.json + run: | + # 确保 package-lock.json 文件存在 + if [ ! -f "package-lock.json" ]; then + # 如果 package-lock.json 不存在,则生成 + npm install + fi + - name: Install Dependencies run: | - npm ci - npm install @commitlint/cli @commitlint/config-conventional + npm ci # 使用 npm ci 安装依赖 - name: Configure Commitlint run: | From 37747ca5069ed54e3230c7c6c624754f7044481a Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 16:44:27 +0800 Subject: [PATCH 14/26] Update commitlint.yml to ensure package.json and package-lock.json exist --- .github/workflows/commitlint.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index cd65cd7..c34a3b0 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -16,31 +16,45 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v3 # 使用最新版本的 checkout 动作 + with: + fetch-depth: 0 # 获取完整的提交历史 - name: Set up Node.js uses: actions/setup-node@v3 # 使用最新版本的 setup-node 动作 with: node-version: '20' # 显式指定 Node.js 版本 - - name: Generate package-lock.json + - name: Ensure package.json Exists + id: check_package_json + run: | + if [ -f "package.json" ]; then + echo "::set-output name=exists::true" + else + echo "::set-output name=exists::false" + fi + + - name: Generate package-lock.json if necessary + if: steps.check_package_json.outputs.exists == 'true' run: | - # 确保 package-lock.json 文件存在 + # 如果 package-lock.json 不存在,则生成 if [ ! -f "package-lock.json" ]; then - # 如果 package-lock.json 不存在,则生成 npm install fi - name: Install Dependencies + if: steps.check_package_json.outputs.exists == 'true' run: | npm ci # 使用 npm ci 安装依赖 - name: Configure Commitlint + if: steps.check_package_json.outputs.exists == 'true' run: | # 确保 .commitlintrc.js 存在 touch .commitlintrc.js echo "module.exports = {extends: ['@commitlint/config-conventional']};"> .commitlintrc.js - name: Check Commits + if: steps.check_package_json.outputs.exists == 'true' run: | if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose From 0c72b7339630c882fe4e5d256e87f7d549efe1e2 Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 16:46:20 +0800 Subject: [PATCH 15/26] Update commitlint.yml to address deprecation warnings --- .github/workflows/commitlint.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index c34a3b0..97af87e 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -28,13 +28,13 @@ jobs: id: check_package_json run: | if [ -f "package.json" ]; then - echo "::set-output name=exists::true" + echo "PACKAGE_JSON_EXISTS=true" >> $GITHUB_ENV else - echo "::set-output name=exists::false" + echo "PACKAGE_JSON_EXISTS=false" >> $GITHUB_ENV fi - name: Generate package-lock.json if necessary - if: steps.check_package_json.outputs.exists == 'true' + if: env.PACKAGE_JSON_EXISTS == 'true' run: | # 如果 package-lock.json 不存在,则生成 if [ ! -f "package-lock.json" ]; then @@ -42,19 +42,19 @@ jobs: fi - name: Install Dependencies - if: steps.check_package_json.outputs.exists == 'true' + if: env.PACKAGE_JSON_EXISTS == 'true' run: | npm ci # 使用 npm ci 安装依赖 - name: Configure Commitlint - if: steps.check_package_json.outputs.exists == 'true' + if: env.PACKAGE_JSON_EXISTS == 'true' run: | # 确保 .commitlintrc.js 存在 touch .commitlintrc.js echo "module.exports = {extends: ['@commitlint/config-conventional']};"> .commitlintrc.js - name: Check Commits - if: steps.check_package_json.outputs.exists == 'true' + if: env.PACKAGE_JSON_EXISTS == 'true' run: | if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose From 87383c473f16ea03c0dc404b78d82e997811409e Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 17:44:39 +0800 Subject: [PATCH 16/26] Add .gitignore file to exclude node_modules/ --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ From ec612f790e7dcae8883d454c93fd1b7c85ae00c8 Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 20:07:25 +0800 Subject: [PATCH 17/26] Update commitlint.yml --- .github/workflows/commitlint.yml | 60 +++++++------------------------- 1 file changed, 13 insertions(+), 47 deletions(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index 97af87e..2e107bb 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -2,62 +2,28 @@ name: Commitlint on: push: - branches-ignore: - - "main" # 排除 main 分支的 push 事件 + branches-ignore: ["main"] # 排除 main 分支的 push 事件 pull_request: - branches-ignore: - - "main" # 排除 main 分支的 pull_request 事件 - workflow_dispatch: # 允许手动触发工作流程 + branches-ignore: ["main"] # 排除 main 分支的 pull request 事件 + workflow_dispatch: jobs: commitlint: runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v3 # 使用最新版本的 checkout 动作 + - uses: actions/checkout@v3 with: - fetch-depth: 0 # 获取完整的提交历史 - - - name: Set up Node.js - uses: actions/setup-node@v3 # 使用最新版本的 setup-node 动作 + fetch-depth: 0 + - uses: actions/setup-node@v3 with: - node-version: '20' # 显式指定 Node.js 版本 - - - name: Ensure package.json Exists - id: check_package_json - run: | - if [ -f "package.json" ]; then - echo "PACKAGE_JSON_EXISTS=true" >> $GITHUB_ENV - else - echo "PACKAGE_JSON_EXISTS=false" >> $GITHUB_ENV - fi - - - name: Generate package-lock.json if necessary - if: env.PACKAGE_JSON_EXISTS == 'true' - run: | - # 如果 package-lock.json 不存在,则生成 - if [ ! -f "package-lock.json" ]; then - npm install - fi - - - name: Install Dependencies - if: env.PACKAGE_JSON_EXISTS == 'true' - run: | - npm ci # 使用 npm ci 安装依赖 - - - name: Configure Commitlint - if: env.PACKAGE_JSON_EXISTS == 'true' - run: | - # 确保 .commitlintrc.js 存在 - touch .commitlintrc.js - echo "module.exports = {extends: ['@commitlint/config-conventional']};"> .commitlintrc.js - - - name: Check Commits - if: env.PACKAGE_JSON_EXISTS == 'true' + node-version: '20' + - run: npm install -g @commitlint/cli @commitlint/config-conventional + - run: | + echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js + - name: Check commits run: | if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then - npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose + commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose else - npx commitlint --from $(git rev-list --max-parents=0 HEAD) --to HEAD --verbose + commitlint --from $(git rev-list --max-parents=0 HEAD) --to HEAD --verbose fi \ No newline at end of file From 4de7454c9e71623c4cbc84421e4e2ec6ec4d41c3 Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 20:19:08 +0800 Subject: [PATCH 18/26] Update commitlint.yml --- .github/workflows/commitlint.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index 2e107bb..0b7ca5c 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -13,17 +13,30 @@ jobs: steps: - uses: actions/checkout@v3 with: - fetch-depth: 0 + fetch-depth: 0 # 获取完整的历史记录 + - uses: actions/setup-node@v3 with: node-version: '20' + - run: npm install -g @commitlint/cli @commitlint/config-conventional + - run: | echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js + - name: Check commits run: | + # 获取当前仓库的所有提交信息 + git log --pretty=format:'%H %s%n' --no-merges | tee /tmp/commits.log + # 打印所有提交信息以供调试 + cat /tmp/commits.log + + # 确定检查的范围 if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then - commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose + COMMIT_RANGE="${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}" else - commitlint --from $(git rev-list --max-parents=0 HEAD) --to HEAD --verbose - fi \ No newline at end of file + COMMIT_RANGE="$(git rev-list --max-parents=0 HEAD)...HEAD" + fi + + # 执行commitlint检查 + npx commitlint --from $COMMIT_RANGE --to HEAD --verbose \ No newline at end of file From 02522f2f75820d180ff0f4c9e1fef26d78609ce1 Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 20:21:05 +0800 Subject: [PATCH 19/26] Update commitlint.yml --- .github/workflows/commitlint.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index 0b7ca5c..bcc46da 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -33,10 +33,23 @@ jobs: # 确定检查的范围 if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then - COMMIT_RANGE="${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}" + # 获取 PR 的 base 和 head SHA + BASE_SHA=${{ github.event.pull_request.base.sha }} + HEAD_SHA=${{ github.event.pull_request.head.sha }} + + # 确保提交范围正确 + COMMIT_RANGE="$BASE_SHA...$HEAD_SHA" else - COMMIT_RANGE="$(git rev-list --max-parents=0 HEAD)...HEAD" + # 对于非 PR 事件,获取最近一次提交的父级 SHA + PARENT_SHA=$(git rev-parse --verify HEAD~1) + COMMIT_RANGE="$PARENT_SHA...HEAD" + fi + + # 确保提交范围有效 + if [ -z "$COMMIT_RANGE" ]; then + echo "No valid commit range found." + exit 0 fi # 执行commitlint检查 - npx commitlint --from $COMMIT_RANGE --to HEAD --verbose \ No newline at end of file + npx commitlint --since $COMMIT_RANGE --to HEAD --verbose \ No newline at end of file From 2c174167f56400740cb2bb7e8362abac3413c891 Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 20:22:59 +0800 Subject: [PATCH 20/26] Update commitlint.yml --- .github/workflows/commitlint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index bcc46da..8b387fd 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -52,4 +52,4 @@ jobs: fi # 执行commitlint检查 - npx commitlint --since $COMMIT_RANGE --to HEAD --verbose \ No newline at end of file + npx commitlint --from $COMMIT_RANGE --to HEAD --verbose \ No newline at end of file From eef2d9ae462cd33f2d8ad42791a21e1b559e17c6 Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 20:27:43 +0800 Subject: [PATCH 21/26] Update commitlint.yml --- .github/workflows/commitlint.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index 8b387fd..792e918 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -25,12 +25,18 @@ jobs: echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js - name: Check commits + env: + GITHUB_CONTEXT: ${{ toJson(github) }} run: | # 获取当前仓库的所有提交信息 git log --pretty=format:'%H %s%n' --no-merges | tee /tmp/commits.log # 打印所有提交信息以供调试 cat /tmp/commits.log + # 获取环境变量中的 GitHub 事件上下文 + echo "GitHub Event Context:" + echo "$GITHUB_CONTEXT" + # 确定检查的范围 if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then # 获取 PR 的 base 和 head SHA @@ -45,6 +51,9 @@ jobs: COMMIT_RANGE="$PARENT_SHA...HEAD" fi + # 打印提交范围 + echo "Commit Range: $COMMIT_RANGE" + # 确保提交范围有效 if [ -z "$COMMIT_RANGE" ]; then echo "No valid commit range found." From 7e536e9e93603754b89ee40fe6f2e4134a9cb567 Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 20:36:06 +0800 Subject: [PATCH 22/26] Update commitlint.yml --- .github/workflows/commitlint.yml | 42 +++----------------------------- 1 file changed, 4 insertions(+), 38 deletions(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index 792e918..cbd7bd0 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -1,3 +1,4 @@ + name: Commitlint on: @@ -13,52 +14,17 @@ jobs: steps: - uses: actions/checkout@v3 with: - fetch-depth: 0 # 获取完整的历史记录 - + fetch-depth: 0 - uses: actions/setup-node@v3 with: node-version: '20' - - run: npm install -g @commitlint/cli @commitlint/config-conventional - - run: | echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js - - name: Check commits - env: - GITHUB_CONTEXT: ${{ toJson(github) }} run: | - # 获取当前仓库的所有提交信息 - git log --pretty=format:'%H %s%n' --no-merges | tee /tmp/commits.log - # 打印所有提交信息以供调试 - cat /tmp/commits.log - - # 获取环境变量中的 GitHub 事件上下文 - echo "GitHub Event Context:" - echo "$GITHUB_CONTEXT" - - # 确定检查的范围 if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then - # 获取 PR 的 base 和 head SHA - BASE_SHA=${{ github.event.pull_request.base.sha }} - HEAD_SHA=${{ github.event.pull_request.head.sha }} - - # 确保提交范围正确 - COMMIT_RANGE="$BASE_SHA...$HEAD_SHA" + commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose else - # 对于非 PR 事件,获取最近一次提交的父级 SHA - PARENT_SHA=$(git rev-parse --verify HEAD~1) - COMMIT_RANGE="$PARENT_SHA...HEAD" - fi - - # 打印提交范围 - echo "Commit Range: $COMMIT_RANGE" - - # 确保提交范围有效 - if [ -z "$COMMIT_RANGE" ]; then - echo "No valid commit range found." - exit 0 + commitlint --from $(git rev-list --max-parents=0 HEAD) --to HEAD --verbose fi - - # 执行commitlint检查 - npx commitlint --from $COMMIT_RANGE --to HEAD --verbose \ No newline at end of file From b4f77b282f295bd7e93ec76c45f91123149de021 Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 21:17:04 +0800 Subject: [PATCH 23/26] Update commitlint.yml --- .github/workflows/commitlint.yml | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index cbd7bd0..fc80385 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -1,30 +1,32 @@ - name: Commitlint on: - push: - branches-ignore: ["main"] # 排除 main 分支的 push 事件 - pull_request: - branches-ignore: ["main"] # 排除 main 分支的 pull request 事件 - workflow_dispatch: + pull_request: # 只在 PR 事件时触发 + workflow_dispatch: # 允许手动触发 jobs: commitlint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout Repository + uses: actions/checkout@v3 with: - fetch-depth: 0 - - uses: actions/setup-node@v3 + fetch-depth: 0 # 获取完整的历史记录 + + - name: Setup Node.js Environment + uses: actions/setup-node@v3 with: node-version: '20' - - run: npm install -g @commitlint/cli @commitlint/config-conventional - - run: | + + - name: Install Commitlint + run: npm install -g @commitlint/cli @commitlint/config-conventional + + - name: Configure Commitlint + run: | echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js - - name: Check commits + + - name: Check Commits run: | if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose - else - commitlint --from $(git rev-list --max-parents=0 HEAD) --to HEAD --verbose - fi + fi \ No newline at end of file From 4b24a2b4108063b993a20e3d9ade0ff4cafe063f Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 22:11:01 +0800 Subject: [PATCH 24/26] Update commitlint.yml --- .github/workflows/commitlint.yml | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index fc80385..75e30a3 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -1,32 +1,26 @@ name: Commitlint on: - pull_request: # 只在 PR 事件时触发 - workflow_dispatch: # 允许手动触发 + pull_request: # 直接删除 branches-ignore 字段 + workflow_dispatch: jobs: commitlint: runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@v3 + - uses: actions/checkout@v3 with: - fetch-depth: 0 # 获取完整的历史记录 - - - name: Setup Node.js Environment - uses: actions/setup-node@v3 + fetch-depth: 0 + - uses: actions/setup-node@v3 with: - node-version: '20' - - - name: Install Commitlint - run: npm install -g @commitlint/cli @commitlint/config-conventional - - - name: Configure Commitlint - run: | + node-version: '16' # 使用一个稳定的 Node.js 版本,比如 16 + - run: npm install -g @commitlint/cli @commitlint/config-conventional + - run: | echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js - - - name: Check Commits + - name: Check commits run: | if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose + else + commitlint --from $(git rev-list --max-parents=0 HEAD) --to HEAD --verbose fi \ No newline at end of file From 8bba7140c2002611b4119374258e0158828bc7f7 Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 22:27:14 +0800 Subject: [PATCH 25/26] Update commitlint.yml --- .github/workflows/commitlint.yml | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index 75e30a3..fc80385 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -1,26 +1,32 @@ name: Commitlint on: - pull_request: # 直接删除 branches-ignore 字段 - workflow_dispatch: + pull_request: # 只在 PR 事件时触发 + workflow_dispatch: # 允许手动触发 jobs: commitlint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout Repository + uses: actions/checkout@v3 with: - fetch-depth: 0 - - uses: actions/setup-node@v3 + fetch-depth: 0 # 获取完整的历史记录 + + - name: Setup Node.js Environment + uses: actions/setup-node@v3 with: - node-version: '16' # 使用一个稳定的 Node.js 版本,比如 16 - - run: npm install -g @commitlint/cli @commitlint/config-conventional - - run: | + node-version: '20' + + - name: Install Commitlint + run: npm install -g @commitlint/cli @commitlint/config-conventional + + - name: Configure Commitlint + run: | echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js - - name: Check commits + + - name: Check Commits run: | if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose - else - commitlint --from $(git rev-list --max-parents=0 HEAD) --to HEAD --verbose fi \ No newline at end of file From 50b1db942a7188a3016ecb1807dfd97b2c83117a Mon Sep 17 00:00:00 2001 From: hpy <3190879375@qq.com> Date: Sun, 13 Oct 2024 23:53:35 +0800 Subject: [PATCH 26/26] Add new commitlint workflow --- .github/workflows/commitlint-new.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/workflows/commitlint-new.yml diff --git a/.github/workflows/commitlint-new.yml b/.github/workflows/commitlint-new.yml new file mode 100644 index 0000000..e69de29