-
Notifications
You must be signed in to change notification settings - Fork 7
147 lines (128 loc) · 3.9 KB
/
pr-ci.yml
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: CI
on:
pull_request:
types: [opened, synchronize]
env:
HUSKY: 0
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_TELEMETRY_DISABLED: 1
DO_NOT_TRACK: 1
# Needed for VScode test runner
DISPLAY: ':99.0'
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
changes:
runs-on: ubuntu-latest
env:
TURBO_RUN_FILTER: ${{ github.event_name == 'pull_request' && '...[origin/master]' || '...[HEAD^]' }}
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
flat: ${{ steps.flat.outputs.result }}
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
lfs: true
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
cache: 'npm'
node-version: 20
- name: Install [email protected] & glob
run: |
npm i -g [email protected] glob
echo "PATH=$(npm config get config):$PATH" >> $GITHUB_ENV
- name: Verify turbo installation
shell: bash
run: |
source $GITHUB_ENV
turbo --version
- name: Debug TURBO_RUN_FILTER
run: echo "TURBO_RUN_FILTER is $TURBO_RUN_FILTER"
- name: Validate JSON Output
run: |
content=$(turbo build --filter=$TURBO_RUN_FILTER --dry-run=json)
echo $content | jq .
- name: Debug turbo command
run: |
set -x
turbo build --filter=$TURBO_RUN_FILTER --dry-run=json
set +x
- name: Verify turbo installation
run: which turbo
- name: Debug content
run: |
content=`turbo build --filter=$TURBO_RUN_FILTER --dry-run=json`
echo "Content is: $content"
- name: Changeset
id: changeset
run: |
content=`turbo build --filter=$TURBO_RUN_FILTER --dry-run=json`
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
echo "::set-output name=result::$content"
- name: Flat output
id: flat
run: |
filteredPkgs=`turbo build --filter=$TURBO_RUN_FILTER --dry-run=json | node ./scripts/diff.js`
echo "::set-output name=result::$filteredPkgs"
echo "$filteredPkgs"
verify:
name: Verify changes
needs: changes
runs-on: ubuntu-latest
if: ${{ needs.changes.outputs.flat != '[]' }}
defaults:
run:
shell: bash
working-directory: ./out
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 20
cache: "yarn"
- name: Install turbo
run: yarn global add [email protected]
- name: prune
run: turbo prune ${{ needs.changes.outputs.flat }}
working-directory: ./
- name: Turbo Cache
id: turbo-cache
uses: actions/cache@v3
with:
path: .turbo
key: turbo-${{ github.job }}-${{ github.head_ref }}-${{ github.sha }}
restore-keys: |
turbo-${{ github.job }}-${{ github.head_ref }}-
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Install dependencies
run: yarn --frozen-lockfile --immutable
- name: Linting
run: yarn lint
# verify that build scripts function correctly
- name: Build
run: yarn build
- name: Test
run: yarn run test
- uses: actions/upload-artifact@v3
if: always()
with:
name: cypress-artifacts
path: |
./**/cypress/snapshots
./**/cypress/screenshots