diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d5ffd45af..52c8869a2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,32 +8,31 @@ jobs: - name: Checkout uses: actions/checkout@v3 with: - # During a pre-merge check, Github creates and checks out an temporary merge commit. That - # commit won't work as the HEAD for jest --changedSince ref: ${{ github.event.pull_request.head.sha }} - - name: Fetch merge base commits - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - # Fetch commits to a depth so that head and base reach their merge base. - comparison=$(gh api\ - repos/paraswap/parapswap-dex-lib/compare/${{ github.event.pull_request.base.sha }}...${{github.event.pull_request.head.sha }}) - behind_by=$(echo -E $comparison | jq -r '.behind_by') - ahead_by=$(echo -E $comparison | jq -r '.ahead_by') - echo "ahead_by: $ahead_by; behind by: $behind_by" - # +1 because fetch depth=1 is the commit itself. - if [[ $behind_by -gt 0 ]]; then - base_depth=$((behind_by+1)) - echo Fetching base to depth $base_depth - git -c protocol.version=2 fetch --no-tags --no-recurse-submodules\ - --depth=$base_depth origin ${{github.event.pull_request.base.sha }} - fi - if [[ $ahead_by -gt 0 ]]; then - head_depth=$((ahead_by+1)) - echo Fetching head to depth $head_depth - git -c protocol.version=2 fetch --no-tags --no-recurse-submodules\ - --depth=$head_depth origin ${{github.event.pull_request.head.sha }} - fi + + - name: Fetch merge base commits + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Fetch commits to a depth so that head and base reach their merge base. + comparison=$(gh api\ + repos/paraswap/parapswap-dex-lib/compare/${{ github.event.pull_request.base.sha }}...${{github.event.pull_request.head.sha }}) + behind_by=$(echo -E $comparison | jq -r '.behind_by') + ahead_by=$(echo -E $comparison | jq -r '.ahead_by') + echo "ahead_by: $ahead_by; behind by: $behind_by" + # +1 because fetch depth=1 is the commit itself. + if [[ $behind_by -gt 0 ]]; then + base_depth=$((behind_by+1)) + echo Fetching base to depth $base_depth + git -c protocol.version=2 fetch --no-tags --no-recurse-submodules\ + --depth=$base_depth origin ${{github.event.pull_request.base.sha }} + fi + if [[ $ahead_by -gt 0 ]]; then + head_depth=$((ahead_by+1)) + echo Fetching head to depth $head_depth + git -c protocol.version=2 fetch --no-tags --no-recurse-submodules\ + --depth=$head_depth origin ${{github.event.pull_request.head.sha }} + fi - uses: actions/checkout@v2