-
Notifications
You must be signed in to change notification settings - Fork 70
151 lines (128 loc) · 4.5 KB
/
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
148
149
150
151
name: CI
on:
push: { branches: [dev, main] }
pull_request:
jobs:
install:
timeout-minutes: 10
strategy:
matrix: { node: ["18.x"], os: [ubuntu-latest] }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- if: ${{ steps.yarn-cache.outputs.cache-hit != 'true' }}
name: Install dependencies
run: yarn --immutable
test:
if: false
needs: install
timeout-minutes: 60
strategy:
matrix: { node: ["18.x"], os: [ubuntu-latest] }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn --immutable
- name: Verify linting
run: yarn lint
- name: Build Pioneer
run: yarn build
- name: Run tests
run: node --max_old_space_size=7000 --expose-gc $(yarn bin jest) --logHeapUsage --silent
working-directory: packages/ui
storybook-test:
needs: install
timeout-minutes: 60
strategy:
matrix: { node: ["18.x"], os: [ubuntu-latest] }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn --immutable
- name: Install Playwright
run: npx playwright install --with-deps
- name: Get the Storybook preview deployment url
run: |
PROJECT="pioneer-2-storybook"
PREFIX="git-"
URL_BRANCH=$( \
node \
-e "process.stdout.write(process.argv[1].replace(/#/g, '').replace(/\W/g, '-').toLowerCase())" \
"$BRANCH" \
)
LONG="$PROJECT-$PREFIX$URL_BRANCH-joystream"
SHORT=$(echo "$LONG" | head -c 46)
SUBDOMAIN=$( \
[ ${#LONG} -te 63 ] \
&& echo "$LONG" \
|| echo "$SHORT-$(echo -n "$PREFIX$BRANCH$PROJECT" | sha256sum | head -c 6)" \
)
echo "VERCEL_DEPLOYMENT_URL=$SUBDOMAIN.vercel.app" >> "$GITHUB_ENV"
env:
BRANCH: ${{ github.ref_name }}
- name: Wait for the deployment to complete
run: |
while true; do
RES=$(curl -L "https://api.vercel.com/v13/deployments/${{ env.VERCEL_DEPLOYMENT_URL }}")
ARR=($( \
node \
-e " \
const res = JSON.parse(process.argv[1]); \
process.stdout.write(`${res.status} ${res.meta.githubCommitSha}`);
" \
"RES" \
))
STATUS=${ARR[1]}
SHA=${ARR[2]}
[ "SHA" == "$COMMIT_SHA" ] && [ "STATUS" == "READY"] && break
echo "Wait for the Storybook deployment..."
sleep 20
done
env:
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Run Storybook tests
run: yarn workspace @joystream/pioneer test-storybook
env:
TARGET_URL: https://${{ env.VERCEL_DEPLOYMENT_URL }}