Skip to content

Commit a621c4c

Browse files
committed
Add unit test workflow with coverage reporting
Signed-off-by: xil <fridalu66@gmail.com>
1 parent 619bf89 commit a621c4c

5 files changed

Lines changed: 52 additions & 8 deletions

File tree

.github/workflows/test-tools.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Test Tools
2+
3+
on:
4+
push:
5+
branches: ['**']
6+
paths:
7+
- '.github/workflows/test*.yml'
8+
- 'package*.json'
9+
- 'tools/**'
10+
pull_request:
11+
branches: ['**']
12+
paths:
13+
- '.github/workflows/test*.yml'
14+
- 'package*.json'
15+
- 'tools/**'
16+
17+
jobs:
18+
test:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout Repo
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: '20'
28+
29+
- name: Install Dependencies
30+
run: npm ci
31+
32+
- name: Run Tests
33+
run: npm test -- --coverage
34+
35+
- name: Upload coverage to Codecov
36+
uses: codecov/codecov-action@v5
37+
with:
38+
token: ${{ secrets.CODECOV_TOKEN }}
39+
fail_ci_if_error: false

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
44

55
## [Unreleased]
66
### Added
7+
- Add unit test workflow with coverage reporting ([#346](https://github.com/opensearch-project/opensearch-protobufs/pull/346))
78

89
### Changed
910

jest.config.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
module.exports = {
44
preset: 'ts-jest',
55
testEnvironment: 'node',
6-
moduleDirectories: ['node_modules', './tools/src'],
7-
collectCoverageFrom: ['tools/src/**']
6+
moduleDirectories: ['node_modules', './tools/proto-convert/src'],
7+
collectCoverageFrom: [
8+
'tools/proto-convert/src/**/*.ts',
9+
'!tools/proto-convert/src/**/*.d.ts'
10+
],
11+
testMatch: ['**/test/**/*.test.ts']
812
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"backward-compat": "ts-node tools/proto-convert/src/postprocessing/BackwardCompatibleWriter.ts",
1010
"cleanup-common": "ts-node tools/proto-convert/src/postprocessing/CleanupUnusedMessages.ts -i protos/schemas/common.proto",
1111
"postprocessing": "npm run backward-compat && npm run cleanup-common",
12-
"test": "npx jest --testMatch='**/*.test.ts' --no-watchman"
12+
"test": "npx jest --no-watchman"
1313
},
1414
"dependencies": {
1515
"@apidevtools/swagger-parser": "^12.1.0",

tools/proto-convert/test/fixtures/spec/expected.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ components:
9595
properties:
9696
id:
9797
type: integer
98-
underscore_name:
98+
x_name:
9999
type: string
100-
underscore_type:
100+
x_type:
101101
type: string
102102
enum:
103103
- dog
@@ -110,7 +110,7 @@ components:
110110
properties:
111111
isTrained:
112112
type: boolean
113-
underscore_breed:
113+
x_breed:
114114
type: string
115115
Cat:
116116
type: object
@@ -136,11 +136,11 @@ components:
136136
required:
137137
- canFly
138138
properties:
139-
underscore_canFly:
139+
x_canFly:
140140
type: boolean
141141
- type: object
142142
required:
143143
- canTalk
144144
properties:
145-
underscore_canTalk:
145+
x_canTalk:
146146
type: boolean

0 commit comments

Comments
 (0)