From 9c7fcb013f019d1e9dccf7c4e23a1429c95c14b0 Mon Sep 17 00:00:00 2001 From: Zeke Zhang <958414905@qq.com> Date: Tue, 16 Jul 2024 08:48:45 +0800 Subject: [PATCH] refactor: optimize e2e workflow (#4883) * refactor: optimize e2e workflow * fix: fix * Revert "fix: fix" This reverts commit f256b2394b04eb406815c6a676f9eaf0fd80bb46. * Revert "refactor: optimize e2e workflow" This reverts commit bb7d8c783e348c58395dc5e401f3b177698e5b7b. * refactor: optimize e2e workflow * refactor: make better for workflow * chore: optimize git logs * fix: should to fetch all * chore: test * chore: test * Revertt "chore: test" This reverts commit 049088ad198138a444e27034299e05dd1e404bda. * chore: test --- .github/workflows/e2e.yml | 100 ++++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 30 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index f48dc2a1b8..3c21173a71 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -38,12 +38,20 @@ jobs: path: packages/pro-plugins fetch-depth: 0 ssh-key: ${{ secrets.SUBMODULE_SSH_KEY }} - - name: git checkout ${{ github.event.pull_request.base.ref }} - run: cd packages/pro-plugins && git checkout ${{ github.event.pull_request.base.ref }} - continue-on-error: true - - name: git checkout ${{ github.head_ref || github.ref_name }} - run: cd packages/pro-plugins && git checkout${{ github.head_ref || github.ref_name }} - continue-on-error: true + - run: | + cd packages/pro-plugins && + if git show-ref --quiet refs/remotes/origin/${{ github.head_ref || github.ref_name }}; then + git checkout ${{ github.head_ref || github.ref_name }} + else + if git show-ref --quiet refs/remotes/origin/${{ github.event.pull_request.base.ref }}; then + git checkout ${{ github.event.pull_request.base.ref }} + else + git checkout main + fi + fi + - name: Git logs + run: | + cd packages/pro-plugins && git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -n 10 - name: Use Node.js uses: actions/setup-node@v4 with: @@ -94,12 +102,20 @@ jobs: path: packages/pro-plugins fetch-depth: 0 ssh-key: ${{ secrets.SUBMODULE_SSH_KEY }} - - name: git checkout ${{ github.event.pull_request.base.ref }} - run: cd packages/pro-plugins && git checkout ${{ github.event.pull_request.base.ref }} - continue-on-error: true - - name: git checkout ${{ github.head_ref || github.ref_name }} - run: cd packages/pro-plugins && git checkout ${{ github.head_ref || github.ref_name }} - continue-on-error: true + - run: | + cd packages/pro-plugins && + if git show-ref --quiet refs/remotes/origin/${{ github.head_ref || github.ref_name }}; then + git checkout ${{ github.head_ref || github.ref_name }} + else + if git show-ref --quiet refs/remotes/origin/${{ github.event.pull_request.base.ref }}; then + git checkout ${{ github.event.pull_request.base.ref }} + else + git checkout main + fi + fi + - name: Git logs + run: | + cd packages/pro-plugins && git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -n 10 - name: Set variables continue-on-error: true # 外部开发者提交 PR 的时候因为没有权限这里会报错,为了能够继续执行后续步骤,所以这里设置为 continue-on-error: true run: | @@ -181,12 +197,20 @@ jobs: path: packages/pro-plugins fetch-depth: 0 ssh-key: ${{ secrets.SUBMODULE_SSH_KEY }} - - name: git checkout ${{ github.event.pull_request.base.ref }} - run: cd packages/pro-plugins && git checkout ${{ github.event.pull_request.base.ref }} - continue-on-error: true - - name: git checkout ${{ github.head_ref || github.ref_name }} - run: cd packages/pro-plugins && git checkout ${{ github.head_ref || github.ref_name }} - continue-on-error: true + - run: | + cd packages/pro-plugins && + if git show-ref --quiet refs/remotes/origin/${{ github.head_ref || github.ref_name }}; then + git checkout ${{ github.head_ref || github.ref_name }} + else + if git show-ref --quiet refs/remotes/origin/${{ github.event.pull_request.base.ref }}; then + git checkout ${{ github.event.pull_request.base.ref }} + else + git checkout main + fi + fi + - name: Git logs + run: | + cd packages/pro-plugins && git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -n 10 - name: Set variables continue-on-error: true # 外部开发者提交 PR 的时候因为没有权限这里会报错,为了能够继续执行后续步骤,所以这里设置为 continue-on-error: true run: | @@ -268,12 +292,20 @@ jobs: path: packages/pro-plugins fetch-depth: 0 ssh-key: ${{ secrets.SUBMODULE_SSH_KEY }} - - name: git checkout ${{ github.event.pull_request.base.ref }} - run: cd packages/pro-plugins && git checkout ${{ github.event.pull_request.base.ref }} - continue-on-error: true - - name: git checkout ${{ github.head_ref || github.ref_name }} - run: cd packages/pro-plugins && git checkout ${{ github.head_ref || github.ref_name }} - continue-on-error: true + - run: | + cd packages/pro-plugins && + if git show-ref --quiet refs/remotes/origin/${{ github.head_ref || github.ref_name }}; then + git checkout ${{ github.head_ref || github.ref_name }} + else + if git show-ref --quiet refs/remotes/origin/${{ github.event.pull_request.base.ref }}; then + git checkout ${{ github.event.pull_request.base.ref }} + else + git checkout main + fi + fi + - name: Git logs + run: | + cd packages/pro-plugins && git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -n 10 - name: Set variables continue-on-error: true # 外部开发者提交 PR 的时候因为没有权限这里会报错,为了能够继续执行后续步骤,所以这里设置为 continue-on-error: true run: | @@ -355,12 +387,20 @@ jobs: path: packages/pro-plugins fetch-depth: 0 ssh-key: ${{ secrets.SUBMODULE_SSH_KEY }} - - name: git checkout ${{ github.event.pull_request.base.ref }} - run: cd packages/pro-plugins && git checkout ${{ github.event.pull_request.base.ref }} - continue-on-error: true - - name: git checkout ${{ github.head_ref || github.ref_name }} - run: cd packages/pro-plugins && git checkout ${{ github.head_ref || github.ref_name }} - continue-on-error: true + - run: | + cd packages/pro-plugins && + if git show-ref --quiet refs/remotes/origin/${{ github.head_ref || github.ref_name }}; then + git checkout ${{ github.head_ref || github.ref_name }} + else + if git show-ref --quiet refs/remotes/origin/${{ github.event.pull_request.base.ref }}; then + git checkout ${{ github.event.pull_request.base.ref }} + else + git checkout main + fi + fi + - name: Git logs + run: | + cd packages/pro-plugins && git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -n 10 - name: Set variables continue-on-error: true # 外部开发者提交 PR 的时候因为没有权限这里会报错,为了能够继续执行后续步骤,所以这里设置为 continue-on-error: true run: |