diff --git a/.github/workflows/_pr_entrypoint.yaml b/.github/workflows/_pr_entrypoint.yaml index 81a4b7f71..dce8a91eb 100644 --- a/.github/workflows/_pr_entrypoint.yaml +++ b/.github/workflows/_pr_entrypoint.yaml @@ -154,6 +154,8 @@ jobs: with: runner: ${{ needs.sanity-checks.outputs.runner }} builder: ${{ needs.sanity-checks.outputs.builder }} + before_ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} + after_ref: ${{ github.sha }} run_test_cases: needs: diff --git a/.github/workflows/_push-entrypoint.yaml b/.github/workflows/_push-entrypoint.yaml index a59511259..bccb21c78 100644 --- a/.github/workflows/_push-entrypoint.yaml +++ b/.github/workflows/_push-entrypoint.yaml @@ -166,6 +166,8 @@ jobs: with: runner: ${{ needs.sanity-checks.outputs.runner }} builder: ${{ needs.sanity-checks.outputs.builder }} + before_ref: ${{ github.event.before }} + after_ref: ${{ github.sha }} run_test_cases: if: needs.prepare.outputs.release != 'true' diff --git a/.github/workflows/run_emqx_app_tests.yaml b/.github/workflows/run_emqx_app_tests.yaml index b5b821741..5479a86ab 100644 --- a/.github/workflows/run_emqx_app_tests.yaml +++ b/.github/workflows/run_emqx_app_tests.yaml @@ -16,6 +16,12 @@ on: builder: required: true type: string + before_ref: + required: true + type: string + after_ref: + required: true + type: string env: IS_CI: "yes" @@ -34,20 +40,12 @@ jobs: with: fetch-depth: 0 - name: run + env: + BEFORE_REF: ${{ inputs.before_ref }} + AFTER_REF: ${{ inputs.after_ref }} run: | git config --global --add safe.directory "$GITHUB_WORKSPACE" - echo "git diff base: $GITHUB_BASE_REF" - if [[ "$GITHUB_BASE_REF" =~ [0-9a-f]{8,40} ]]; then - # base is a commit sha1 - compare_base="$GITHUB_BASE_REF" - else - repo="${GITHUB_REPOSITORY}" - git remote -v - remote="$(git remote -v | grep -E "github\.com(:|/)$repo((\.git)|(\s))" | grep fetch | awk '{print $1}')" - git fetch "$remote" "$GITHUB_BASE_REF" - compare_base="$remote/$GITHUB_BASE_REF" - fi - changed_files="$(git diff --name-only ${compare_base} HEAD apps/emqx)" + changed_files="$(git diff --name-only ${BEFORE_REF} ${AFTER_REF} apps/emqx)" if [ "$changed_files" = '' ]; then echo "nothing changed in apps/emqx, ignored." exit 0