-
Notifications
You must be signed in to change notification settings - Fork 306
53 lines (47 loc) · 2.05 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: CI
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- 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
- uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install Dependencies
run: yarn
- name: Run Eslint checks
run: yarn check:es
- name: Run Changed tests only
if: github.event_name == 'pull_request'
run: npx jest --verbose --onlyChanged --changedSince=${{ env.BASE }}