forked from open-metadata/OpenMetadata
-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (127 loc) · 5.03 KB
/
yarn-coverage.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
name: SonarCloud + Jest Coverage
on:
# Trigger analysis when pushing in master or pull requests, and when creating
# a pull request.
push:
branches:
- main
- "0.[0-9]+.[0-9]+"
paths:
- openmetadata-ui/src/main/resources/ui/**
pull_request_target:
types: [opened, synchronize, reopened, labeled]
paths:
- openmetadata-ui/src/main/resources/ui/**
permissions:
contents: read
pull-requests: write # Required for Providing Jest Coverage Comment
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.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
ui-coverage-tests:
strategy:
matrix:
node-version: [18.x]
runs-on: ubuntu-latest
steps:
- name: Wait for the labeler
uses: lewagon/[email protected]
if: ${{ github.event_name == 'pull_request_target' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
check-name: Team Label
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 90
- name: Verify PR labels
uses: jesusvasquez333/[email protected]
if: ${{ github.event_name == 'pull_request_target' }}
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
valid-labels: "safe to test"
pull-request-number: "${{ github.event.pull_request.number }}"
disable-reviews: true # To not auto approve changes
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Caching NPM dependencies
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Caching NPM dependencies
uses: actions/cache@v3
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Use Node.js ${{ matrix.node-version }}
if: steps.npm-cache.outputs.exit-code == 0
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install Antlr4 CLI
run: |
sudo make install_antlr_cli
- name: Install Yarn Packages
if: steps.yarn-cache.outputs.exit-code == 0
working-directory: ${{ env.UI_WORKING_DIRECTORY }}
run: yarn install
- name: Run Coverage
working-directory: ${{ env.UI_WORKING_DIRECTORY }}
run: yarn test:cov-summary
id: yarn_coverage
- name: Jest coverage comment
uses: MishaKav/[email protected]
with:
coverage-summary-path: ${{env.UI_COVERAGE_DIRECTORY}}/coverage-summary.json
title: Jest test Coverage
summary-title: UI tests summary
badge-title: Coverage
- name: yarn add sonarqube-scanner
working-directory: ${{ env.UI_WORKING_DIRECTORY }}
run: npm install -g sonarqube-scanner
id: npm_install_sonar_scanner
- name: SonarCloud Scan On PR
if: github.event_name == 'pull_request_target' && steps.npm_install_sonar_scanner.outcome == 'success'
working-directory: ${{ env.UI_WORKING_DIRECTORY }}
run: |
sonar-scanner -Dsonar.host.url=${SONARCLOUD_URL} \
-Dproject.settings=sonar-project.properties \
-Dsonar.pullrequest.key=${{ github.event.pull_request.number }} \
-Dsonar.pullrequest.branch=${{ github.head_ref }} \
-Dsonar.pullrequest.base=main \
-Donar.pullrequest.github.repository=OpenMetadata \
-Dsonar.scm.revision=${{ github.event.pull_request.head.sha }} \
-Dsonar.pullrequest.provider=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.UI_SONAR_TOKEN }}
SONARCLOUD_URL: https://sonarcloud.io
- name: SonarCloud Scan
if: github.event_name == 'push' && steps.npm_install_sonar_scanner.outcome == 'success'
working-directory: ${{ env.UI_WORKING_DIRECTORY }}
run: |
sonar-scanner -Dsonar.host.url=${SONARCLOUD_URL} \
-Dproject.settings=sonar-project.properties
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.UI_SONAR_TOKEN }}
SONARCLOUD_URL: https://sonarcloud.io