From c53a64b272e46d04a9edcc036787ed57fc0b0c54 Mon Sep 17 00:00:00 2001 From: wenyutang Date: Fri, 26 Jul 2024 14:45:58 +0800 Subject: [PATCH 1/2] ci: support fork repo to pull request --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++++-- .github/workflows/e2e.yml | 7 ++++++- codecov.yml | 5 ++++- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index feafdf2f..fe4573ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,12 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: checkout + if: ${{ github.event_name == 'pull_request' }} + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} - uses: actions/setup-node@v3 with: node-version: lts/* @@ -40,7 +45,29 @@ jobs: permissions: pull-requests: write steps: - - uses: actions/checkout@v2 + - name: checkout PR + if: ${{ github.event_name == 'pull_request' }} + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: ${{ github.head_ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - name: Checkout + if: ${{ github.event_name != 'pull_request' }} + uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{ github.ref_name }} + repository: ${{ github.repository }} + - name: Merge Branches + if: ${{ github.event_name == 'pull_request' }} + run: | + git config --global user.email "bot@user.noreply.github.com" + git config --global user.name "bot" + + git remote add ${{ github.event.pull_request.base.repo.owner.login }} ${{ github.event.pull_request.base.repo.clone_url }} + git fetch ${{ github.event.pull_request.base.repo.owner.login }} + git merge ${{ github.event.pull_request.base.repo.owner.login }}/${{ github.event.pull_request.base.ref }} - uses: actions/setup-node@v3 with: node-version: lts/* diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 32f32170..92d24e9e 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -9,7 +9,12 @@ jobs: e2e-test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: checkout + if: ${{ github.event_name == 'pull_request' }} + uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} - uses: actions/setup-node@v2 with: node-version: lts/* diff --git a/codecov.yml b/codecov.yml index 482587a6..5fa2efd0 100644 --- a/codecov.yml +++ b/codecov.yml @@ -6,8 +6,11 @@ coverage: status: project: default: - target: auto # require coverage equal or more than current + target: auto # require coverage equal or more than current if_ci_failed: error #success, failure, error, ignore +ignore: + - "src/test/**" + comment: layout: "reach, diff, flags, files" From a99eccab941ec2cb07c0cdf4b271260f73bb80e0 Mon Sep 17 00:00:00 2001 From: wenyutang Date: Fri, 26 Jul 2024 14:53:44 +0800 Subject: [PATCH 2/2] ci: update --- .github/workflows/ci.yml | 13 ++----------- .github/workflows/e2e.yml | 1 - 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe4573ec..7369d63a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,6 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - if: ${{ github.event_name == 'pull_request' }} uses: actions/checkout@v3 with: ref: ${{ github.head_ref }} @@ -32,7 +31,7 @@ jobs: semver-title: runs-on: ubuntu-latest - if: (github.event_name == 'pull_request') + if: (github.event_name == 'pull_request_target') permissions: pull-requests: write steps: @@ -46,21 +45,13 @@ jobs: pull-requests: write steps: - name: checkout PR - if: ${{ github.event_name == 'pull_request' }} uses: actions/checkout@v3 with: fetch-depth: 0 ref: ${{ github.head_ref }} repository: ${{ github.event.pull_request.head.repo.full_name }} - - name: Checkout - if: ${{ github.event_name != 'pull_request' }} - uses: actions/checkout@v2 - with: - fetch-depth: 0 - ref: ${{ github.ref_name }} - repository: ${{ github.repository }} - name: Merge Branches - if: ${{ github.event_name == 'pull_request' }} + if: ${{ github.event_name == 'pull_request_target' }} run: | git config --global user.email "bot@user.noreply.github.com" git config --global user.name "bot" diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 92d24e9e..87075155 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -10,7 +10,6 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - if: ${{ github.event_name == 'pull_request' }} uses: actions/checkout@v3 with: ref: ${{ github.head_ref }}