-
Notifications
You must be signed in to change notification settings - Fork 337
148 lines (148 loc) · 5.2 KB
/
test.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
name: Test
on:
pull_request:
concurrency:
group: ${{ github.ref }}-test
cancel-in-progress: true
env:
HUSKY: 0 # disable husky
TURBO_TEAM: ${{ secrets.TURBO_TEAM }} # for Turborepo remote cache
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} # for Turborepo remote cache
NEXT_TELEMETRY_DISABLED: 1 # disable NextJS telemetry
SENTRYCLI_SKIP_DOWNLOAD: 1 # disable Sentry.io CLI download
FORCE_COLOR: 0 # disable terminal color in yarn berry
defaults:
run:
shell: bash
jobs:
check-yarn-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 18
- run: yarn --immutable
changed-workspaces:
runs-on: ubuntu-latest
outputs:
projects: ${{ steps.dry-run.outputs.projects }}
projects-web: ${{ steps.dry-run.outputs.projects-web }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 18
- run: yarn --immutable
- name: Set needs.changed-workspaces.outputs.{projects,projects-web}
id: dry-run
run: |
echo yarn build:ci --dry='json' --filter='[${{ github.event.pull_request.base.sha }}]' | tee -a $GITHUB_STEP_SUMMARY
export DRY_BUILD_JSON=$(
yarn build:ci --dry='json' --filter='[${{ github.event.pull_request.base.sha }}]' | jq '{packages: .packages}'
)
node <<EOF | tee -a $GITHUB_OUTPUT $GITHUB_STEP_SUMMARY
const { packages } = JSON.parse(process.env.DRY_BUILD_JSON);
console.log('projects=' + JSON.stringify(packages.filter(p => /^(?:ui|web.*)$/.test(p))));
EOF
node <<EOF | tee -a $GITHUB_OUTPUT $GITHUB_STEP_SUMMARY
const { packages } = JSON.parse(process.env.DRY_BUILD_JSON);
console.log('projects-web=' + JSON.stringify(packages.filter(p => /^web.*$/.test(p))));
EOF
ts-lint-build:
if: ${{ success() && needs.changed-workspaces.outputs.projects != '[]' }}
needs: changed-workspaces
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: ${{ fromJSON(needs.changed-workspaces.outputs.projects) }}
steps:
- uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 18
- run: yarn --immutable
- name: ts-check
run: |
echo '```' >> $GITHUB_STEP_SUMMARY
yarn ts-check:ci --filter=${{ matrix.project }} | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: lint
run: |
echo '```' >> $GITHUB_STEP_SUMMARY
yarn lint:ci --filter=${{ matrix.project }} | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: build
if: ${{ needs.changed-workspaces.outputs.projects-web != '[]' }}
run: |
echo '```' >> $GITHUB_STEP_SUMMARY
yarn build:ci --filter=${{ matrix.project }} | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
jest-test:
if: ${{ success() && needs.changed-workspaces.outputs.projects != '[]' }}
needs: changed-workspaces
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4, 5]
shardTotal: [5]
steps:
- uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 18
- run: yarn --immutable
- name: test
run: |
echo '```' >> $GITHUB_STEP_SUMMARY
yarn test:ci --filter=${{ join(fromJSON(needs.changed-workspaces.outputs.projects), ' --filter=') }} -- --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --coverage | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
e2e-playwright:
if: ${{ success() && needs.changed-workspaces.outputs.projects-web != '[]' }}
needs: changed-workspaces
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: [web]
browser:
- chromium
# - firefox
# - webkit
# - mobile-chrome
- mobile-safari
shardIndex: [1, 2, 3, 4, 5]
shardTotal: [5]
container:
image: mcr.microsoft.com/playwright:v1.33.0-focal
steps:
- uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: 18
- run: yarn --immutable
- name: Playwright testing
run: |
echo '```' >> $GITHUB_STEP_SUMMARY
yarn playwright test --project=${{ matrix.browser }} --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
env:
CI: 1
DEBUG: pw:webserver
PROJECT_NAME: ${{ matrix.project }}
PLAYWRIGHT_HTML_REPORT: playwright-report/${{ matrix.browser }}/${{ matrix.shardIndex }}
- uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: trace.playwright.dev
path: playwright-report/
retention-days: 7