Repository navigation
141 lines (134 loc) · 5.65 KB
/
Copy pathyarn-coverage.yml
File metadata and controls
141 lines (134 loc) · 5.65 KB
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
name: Jest Coverage
on:
merge_group:
workflow_dispatch:
# Trigger analysis when pushing in master or pull requests, and when creating
# a pull request.
# Note: paths filter removed — the workflow always triggers so that the
# required status check (coverage-result) always completes. Path filtering
# is handled inside the workflow via dorny/paths-filter, which lets PRs
# without UI changes skip the expensive jobs while still reporting a
# passing status.
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
permissions:
contents: read
pull-requests: read
env:
UI_WORKING_DIRECTORY: openmetadata-ui/src/main/resources/ui
UI_COVERAGE_DIRECTORY: openmetadata-ui/src/main/resources/ui/src/test/unit/coverage
concurrency:
group: yarn-coverage-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
jobs:
check-changes:
runs-on: ubuntu-latest
outputs:
ui-changed: ${{ steps.filter.outputs.ui }}
steps:
- name: Checkout
uses: actions/checkout@v7
if: ${{ github.event_name == 'merge_group' }}
with:
fetch-depth: 0
filter: blob:none
persist-credentials: false
- uses: dorny/paths-filter@v4
id: filter
with:
base: ${{ github.event_name == 'merge_group' && github.event.merge_group.base_sha || '' }}
filters: |
ui:
- '.github/workflows/yarn-coverage.yml'
- 'openmetadata-ui/src/main/resources/ui/src/**'
- 'openmetadata-ui/src/main/resources/ui/jest.config.js'
- 'openmetadata-ui/src/main/resources/ui/package.json'
- 'openmetadata-ui/src/main/resources/ui/yarn.lock'
- 'openmetadata-ui/src/main/resources/ui/tsconfig.json'
- 'openmetadata-ui/src/main/resources/ui/babel.config.json'
- 'openmetadata-ui/src/main/resources/ui/.nvmrc'
- 'openmetadata-ui/src/main/resources/ui/sonar-project.properties'
- 'openmetadata-ui-core-components/src/main/resources/ui/src/**'
- 'openmetadata-ui-core-components/src/main/resources/ui/package.json'
- 'openmetadata-ui-core-components/src/main/resources/ui/yarn.lock'
- 'openmetadata-ui-core-components/src/main/resources/ui/vite.config.ts'
ui-coverage-tests:
needs: check-changes
runs-on: ubuntu-latest
if: |
!github.event.pull_request.draft &&
(github.event_name == 'workflow_dispatch' || needs.check-changes.outputs.ui-changed == 'true')
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'merge_group' && github.sha || github.event.pull_request.head.sha }}
fetch-depth: 0
filter: blob:none
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version-file: "openmetadata-ui/src/main/resources/ui/.nvmrc"
# populate-playwright-caches.yml populates this shared Yarn cache. Validation
# must not evict main's fixtures with large copies on ephemeral queue refs.
- name: Restore Yarn dependencies
uses: actions/cache/restore@v6
id: yarn-cache
with:
path: ~/.cache/yarn
key: yarn-pkg-cache-${{ runner.os }}-${{ hashFiles('openmetadata-ui/src/main/resources/ui/yarn.lock') }}
restore-keys: |
yarn-pkg-cache-${{ runner.os }}-
- name: Install Antlr4 CLI
run: |
sudo make install_antlr_cli
- name: Install Yarn Packages
working-directory: ${{ env.UI_WORKING_DIRECTORY }}
run: |
# Retry transient registry failures (5xx on tarball fetches) —
# yarn v1 does not retry HTTP errors on its own.
for attempt in 1 2 3; do
yarn install --network-timeout 100000 && break
if [[ "$attempt" -eq 3 ]]; then
echo "yarn install failed after 3 attempts" >&2
exit 1
fi
echo "::warning::yarn install attempt $attempt failed (registry blip?); retrying in $((attempt * 15))s"
sleep $((attempt * 15))
done
- name: Run Coverage
working-directory: ${{ env.UI_WORKING_DIRECTORY }}
# jest.config.js keeps '50%' for laptops; on the 4-vCPU hosted runner
# that is only 2 workers, so CI asks for all 4.
run: yarn test:cov-summary --maxWorkers=4
id: yarn_coverage
- name: Jest coverage comment
id: coverage_comment
uses: MishaKav/jest-coverage-comment@v1.0.38
with:
coverage-summary-path: ${{env.UI_COVERAGE_DIRECTORY}}/coverage-summary.json
title: Jest test Coverage
summary-title: UI tests summary
badge-title: Coverage
hide-comment: true
- name: Coverage summary
env:
SUMMARY_HTML: ${{ steps.coverage_comment.outputs.summaryHtml }}
run: echo "$SUMMARY_HTML" >> "$GITHUB_STEP_SUMMARY"
# This job is the one to set as the required status check in branch protection.
# It always runs and passes when ui-coverage-tests succeeded OR was skipped
# (i.e. no relevant UI paths changed), so PRs without UI changes are never blocked.
ui-coverage:
if: always()
needs: [ui-coverage-tests]
runs-on: ubuntu-latest
steps:
- name: Check coverage result
run: |
result="${{ needs.ui-coverage-tests.result }}"
if [[ "$result" == "success" || "$result" == "skipped" ]]; then
echo "Coverage check passed or was not required for this PR"
else
echo "Coverage check failed with status: $result"
exit 1
fi