From 41ca3da925fa38885ea20065714d71ad915ed65a Mon Sep 17 00:00:00 2001 From: FrankLeeeee Date: Mon, 6 Mar 2023 23:01:16 +0800 Subject: [PATCH 1/4] [workflow] fixed the post-commit failure when no formatting needed --- .github/workflows/post_commit.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/post_commit.yml b/.github/workflows/post_commit.yml index 765a4d4281e9..b4668562ce5f 100644 --- a/.github/workflows/post_commit.yml +++ b/.github/workflows/post_commit.yml @@ -2,8 +2,8 @@ name: post-commit on: pull_request: - types: - - closed + # types: + # - closed jobs: # this job will run after a PR is merged to run pre-commit on any changed file @@ -69,7 +69,10 @@ jobs: # create commit for pre-commit - name: Create commits + id: commit + continue-on-error: true run: | + exit -1 git config --global user.name 'github-actions' git config --global user.email 'github-actions@github.com' git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} @@ -78,6 +81,7 @@ jobs: # create pull request - name: Create Pull Request + if: steps.commit.outputs.status == 'success' id: cpr uses: peter-evans/create-pull-request@v4 with: @@ -85,6 +89,7 @@ jobs: title: "[format] applied code formatting on changed files in PR ${{ github.event.pull_request.number }}" - name: Enable Auto-merge for the New PR + if: steps.commit.outputs.status == 'success' uses: peter-evans/enable-pull-request-automerge@v2 with: pull-request-number: ${{ steps.cpr.outputs.pull-request-number }} From 1668034b1b7a511cf3ac0d9e05ad5906419ec25a Mon Sep 17 00:00:00 2001 From: FrankLeeeee Date: Mon, 6 Mar 2023 23:03:00 +0800 Subject: [PATCH 2/4] polish code --- .github/workflows/post_commit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/post_commit.yml b/.github/workflows/post_commit.yml index b4668562ce5f..2b93b8facde2 100644 --- a/.github/workflows/post_commit.yml +++ b/.github/workflows/post_commit.yml @@ -11,7 +11,7 @@ jobs: # be auto-executed by the workflow pre-commit: runs-on: ubuntu-latest - if: github.event.pull_request.merged == true && github.repository == 'hpcaitech/ColossalAI' + # if: github.event.pull_request.merged == true && github.repository == 'hpcaitech/ColossalAI' steps: - uses: actions/checkout@v2 with: From 3e52dff3ff85f0ab4bfd733962a1a36088e9c58d Mon Sep 17 00:00:00 2001 From: FrankLeeeee Date: Mon, 6 Mar 2023 23:04:54 +0800 Subject: [PATCH 3/4] polish code --- .github/workflows/post_commit.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/post_commit.yml b/.github/workflows/post_commit.yml index 2b93b8facde2..8f628e755ca7 100644 --- a/.github/workflows/post_commit.yml +++ b/.github/workflows/post_commit.yml @@ -2,8 +2,8 @@ name: post-commit on: pull_request: - # types: - # - closed + types: + - closed jobs: # this job will run after a PR is merged to run pre-commit on any changed file @@ -11,7 +11,7 @@ jobs: # be auto-executed by the workflow pre-commit: runs-on: ubuntu-latest - # if: github.event.pull_request.merged == true && github.repository == 'hpcaitech/ColossalAI' + if: github.event.pull_request.merged == true && github.repository == 'hpcaitech/ColossalAI' steps: - uses: actions/checkout@v2 with: From 7f48f15ec433fe2f13613a148decd25586a51c37 Mon Sep 17 00:00:00 2001 From: FrankLeeeee Date: Mon, 6 Mar 2023 23:05:47 +0800 Subject: [PATCH 4/4] polish code --- .github/workflows/post_commit.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/post_commit.yml b/.github/workflows/post_commit.yml index 8f628e755ca7..bf93eabbf43f 100644 --- a/.github/workflows/post_commit.yml +++ b/.github/workflows/post_commit.yml @@ -68,11 +68,12 @@ jobs: done # create commit for pre-commit + # when all files are well formatted, there is no need to create a commit + # therefore, this step will produce an error, which should be allowed - name: Create commits id: commit continue-on-error: true run: | - exit -1 git config --global user.name 'github-actions' git config --global user.email 'github-actions@github.com' git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}