11name : Pull Request Checks
22
33on :
4- pull_request_target :
5- branches :
6- - main
4+ pull_request :
75 workflow_dispatch :
86
97defaults :
@@ -14,6 +12,11 @@ permissions:
1412 contents : read
1513 actions : read
1614
15+ env :
16+ TURBO_REF_FILTER : ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
17+ TURBO_TOKEN : ${{ secrets.TURBO_TOKEN }}
18+ TURBO_TEAM : ${{ secrets.TURBO_TEAM }}
19+
1720jobs :
1821 lint :
1922 name : Lint
2326 - name : Git Checkout
2427 uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
2528 with :
26- fetch-depth : 2
29+ fetch-depth : 0
2730
2831 - name : Restore Cache
2932 uses : actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
@@ -45,16 +48,10 @@ jobs:
4548 run : npm ci --no-audit --no-fund
4649
4750 - name : Run Linting
48- run : npx turbo lint
49- env :
50- TURBO_TOKEN : ${{ secrets.TURBO_TOKEN }}
51- TURBO_TEAM : ${{ secrets.TURBO_TEAM }}
51+ run : npx turbo lint --filter=$TURBO_REF_FILTER
5252
5353 - name : Run Prettier
54- run : npx turbo prettier
55- env :
56- TURBO_TOKEN : ${{ secrets.TURBO_TOKEN }}
57- TURBO_TEAM : ${{ secrets.TURBO_TEAM }}
54+ run : npx turbo prettier --filter=$TURBO_REF_FILTER
5855
5956 unit-tests :
6057 name : Tests on ${{ matrix.os }}
@@ -66,15 +63,15 @@ jobs:
6663 os : [ubuntu-latest, windows-latest]
6764
6865 steps :
69- - name : ' Use GNU tar instead BSD tar'
66+ - name : Use GNU tar instead BSD tar
7067 if : matrix.os == 'windows-latest'
7168 shell : cmd
7269 run : echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
7370
7471 - name : Git Checkout
7572 uses : actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
7673 with :
77- fetch-depth : 2
74+ fetch-depth : 0
7875
7976 - name : Restore Cache
8077 uses : actions/cache/restore@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
@@ -95,14 +92,18 @@ jobs:
9592 - name : Install NPM packages
9693 run : npm ci --no-audit --no-fund
9794
98- - name : Run Unit Tests
99- run : npx turbo test:unit -- --coverage
100- env :
101- TURBO_TOKEN : ${{ secrets.TURBO_TOKEN }}
102- TURBO_TEAM : ${{ secrets.TURBO_TEAM }}
103-
104- - name : Run Storybook Tests
105- run : npx turbo test:storybook
106- env :
107- TURBO_TOKEN : ${{ secrets.TURBO_TOKEN }}
108- TURBO_TEAM : ${{ secrets.TURBO_TEAM }}
95+ - name : Run Unit Tests (Windows)
96+ if : matrix.os == 'windows-latest'
97+ run : npx turbo test:unit --filter=$env:TURBO_REF_FILTER -- --coverage
98+
99+ - name : Run Unit Tests (Ubuntu)
100+ if : matrix.os == 'ubuntu-latest'
101+ run : npx turbo test:unit --filter=$TURBO_REF_FILTER -- --coverage
102+
103+ - name : Run Storybook Tests (Windows)
104+ if : matrix.os == 'windows-latest'
105+ run : npx turbo test:storybook --filter=$env:TURBO_REF_FILTER
106+
107+ - name : Run Storybook Tests (Ubuntu)
108+ if : matrix.os == 'ubuntu-latest'
109+ run : npx turbo test:storybook --filter=$TURBO_REF_FILTER
0 commit comments