From 64aaa420ee7d71bfbb3b83493d0bff9ece1a5567 Mon Sep 17 00:00:00 2001 From: PP Date: Tue, 23 Nov 2021 17:20:23 +0800 Subject: [PATCH] pull rebase the HEAD repo for interface check (#9714) --- .github/workflows/interface-check-report.js | 4 +- .github/workflows/interface-check.yml | 47 ++++++++++++--------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/.github/workflows/interface-check-report.js b/.github/workflows/interface-check-report.js index 832a6725ff..fc3a758296 100644 --- a/.github/workflows/interface-check-report.js +++ b/.github/workflows/interface-check-report.js @@ -8,13 +8,13 @@ if (reportContent.includes('@')) { reportContent = reportContent.split('\n').slice(3).join('\n'); reportContent = `## Interface Check Report \`\`\`diff -! WARNING this pull request has changed these public interface: +! WARNING this pull request has changed these public interfaces: ${reportContent} \`\`\` `; } else { reportContent = `## Interface Check Report -This pull request does not change any public interface !`; +This pull request does not change any public interfaces !`; } fs.writeFileSync(interfaceDiffPath, reportContent, 'utf8'); diff --git a/.github/workflows/interface-check.yml b/.github/workflows/interface-check.yml index 1ca5ceea2b..d698d21a79 100644 --- a/.github/workflows/interface-check.yml +++ b/.github/workflows/interface-check.yml @@ -7,42 +7,51 @@ jobs: interface_check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.sha }} - - - name: npm install + - name: clone REPO run: | + git config --global user.name "test" + git config --global user.email "test@test.com" + git clone https://github.com/cocos-creator/engine.git + + - name: checkout BASE branch + working-directory: ./engine + run: | + git fetch origin ${{ github.base_ref }} + git checkout -b ${{ github.base_ref }} remotes/origin/${{ github.base_ref }} + git branch npm install --ignore-scripts - - name: build HEAD declaration + - name: build BASE declaration + working-directory: ./engine run: | npm run build-declaration - cp ./bin/.declarations/cc.d.ts ./bin/cc_head.d.ts - - - name: git checkout to base branch + cp ./bin/.declarations/cc.d.ts ./bin/cc_base.d.ts + + - name: rebase HEAD branch + working-directory: ./engine run: | - base_branch=`echo ${{ github.base_ref }} | awk -F'/' '{print $NF}'` - git fetch origin ${base_branch} - git checkout remotes/origin/${base_branch} - - - name: build base declaration + git remote add HEAD_REPO https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git + git pull --rebase HEAD_REPO ${{ github.head_ref }} + + - name: build HEAD declaration + working-directory: ./engine run: | npm run build-declaration - uses: LouisBrunner/diff-action@v0.1.2 with: - old: ./bin/.declarations/cc.d.ts - new: ./bin/cc_head.d.ts + old: ./engine/bin/cc_base.d.ts + new: ./engine/bin/.declarations/cc.d.ts mode: addition tolerance: worse - output: ./interface-diff.txt + output: ./engine/interface-diff.txt - name: optimize interface check report + working-directory: ./engine run: | cat ./interface-diff.txt node ./.github/workflows/interface-check-report.js - + - uses: marocchino/sticky-pull-request-comment@v2 with: - path: ./interface-diff.txt + path: ./engine/interface-diff.txt