Skip to content

Commit db8af00

Browse files
authored
Merge pull request #80 from Exabyte-io/chore/SOF-7640
SOF-7640: remove data source dependencies
2 parents 0bb4dd0 + efdeec4 commit db8af00

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2213
-845
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish Coverage to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
deploy-coverage:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: 20.x
23+
cache: 'npm'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Generate coverage report
29+
run: npm run test:coverage:html
30+
31+
- name: Setup Pages
32+
uses: actions/configure-pages@v4
33+
34+
- name: Upload coverage to Pages
35+
uses: actions/upload-pages-artifact@v3
36+
with:
37+
path: coverage/
38+
39+
- name: Deploy to GitHub Pages
40+
id: deployment
41+
uses: actions/deploy-pages@v4

.github/workflows/coverage.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Code Coverage
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [ main ]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
coverage:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
node-version: [20.x]
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
cache: 'npm'
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Run tests with coverage
33+
run: npm run test:coverage
34+
35+
- name: Upload coverage reports as artifacts
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: coverage-report-${{ github.sha }}
39+
path: coverage/
40+
retention-days: 30
41+
42+
- name: Upload coverage to Codecov (optional)
43+
uses: codecov/codecov-action@v4
44+
with:
45+
file: ./coverage/lcov.info
46+
flags: unittests
47+
name: codecov-umbrella
48+
fail_ci_if_error: false
49+
verbose: true

.github/workflows/pr-coverage.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: PR Coverage Report
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
coverage-comment:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v4
12+
13+
- name: Setup Node.js
14+
uses: actions/setup-node@v4
15+
with:
16+
node-version: 20.x
17+
cache: 'npm'
18+
19+
- name: Install dependencies
20+
run: npm ci
21+
22+
- name: Run tests with coverage
23+
run: npm run test:coverage
24+
25+
- name: Comment PR with coverage report
26+
uses: romeovs/[email protected]
27+
with:
28+
github-token: ${{ secrets.GITHUB_TOKEN }}
29+
lcov-file: ./coverage/lcov.info
30+
delete-old-comments: true
31+
32+
- name: Upload coverage artifacts
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: coverage-report-pr-${{ github.event.number }}
36+
path: coverage/
37+
retention-days: 7

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ build/
22
node_modules/
33
.eslintcache
44
.nyc_output/
5+
coverage/
56
.idea/
67
.DS_Store

.nycrc

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,29 @@
22
"all": true,
33
"include": [
44
"src/**/*.js",
5-
"src/**/*.jsx"
5+
"src/**/*.jsx",
6+
"src/**/*.ts"
7+
],
8+
"exclude": [
9+
"tests/**/*",
10+
"**/*.test.ts",
11+
"**/*.spec.ts",
12+
"**/*.d.ts"
13+
],
14+
"reporter": [
15+
"text",
16+
"html",
17+
"lcov"
18+
],
19+
"check-coverage": true,
20+
"branches": 80,
21+
"lines": 85,
22+
"functions": 80,
23+
"statements": 85,
24+
"sourceMap": true,
25+
"instrument": true,
26+
"require": [
27+
"ts-node/register"
628
]
729
}
830

COVERAGE.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Code Coverage Guide
2+
3+
This document explains how to generate and view code coverage reports for the ade.js project.
4+
5+
## Quick Start
6+
7+
### Local Development
8+
```bash
9+
# Generate and view coverage report
10+
npm run test:coverage:html
11+
npm run test:coverage:view
12+
```
13+
14+
### Check Coverage Thresholds
15+
```bash
16+
# Run tests and verify coverage meets minimum thresholds
17+
npm run test:coverage:check
18+
```
19+
20+
## Coverage Options
21+
22+
### 1. Local HTML Report
23+
- **Command**: `npm run test:coverage:html`
24+
- **Output**: `coverage/index.html`
25+
- **View**: `npm run test:coverage:view` (opens in browser automatically)
26+
27+
### 2. GitHub Actions Coverage
28+
29+
#### PR Coverage Comments
30+
- **Trigger**: Every pull request
31+
- **What it does**:
32+
- Runs tests with coverage
33+
- Posts a detailed coverage report as a PR comment
34+
- Shows coverage changes compared to base branch
35+
- Uploads coverage artifacts for download
36+
37+
#### Coverage Artifacts
38+
- **Location**: GitHub Actions → Artifacts tab
39+
- **Retention**: 30 days for main branch, 7 days for PRs
40+
- **Download**: Click on artifact to download and view locally
41+
42+
#### GitHub Pages (Optional)
43+
- **URL**: `https://exabyte-io.github.io/ade.js/`
44+
- **Trigger**: Every push to main branch
45+
- **Features**:
46+
- Always up-to-date coverage report
47+
- No authentication required
48+
- Easy sharing with team
49+
50+
### 3. External Services
51+
52+
#### Codecov Integration
53+
- **Service**: [Codecov](https://codecov.io)
54+
- **Features**:
55+
- Historical coverage tracking
56+
- Coverage trends and graphs
57+
- PR coverage comparison
58+
- Coverage badges
59+
- **Setup**: Automatic via GitHub Actions
60+
61+
## Coverage Thresholds
62+
63+
The project enforces these minimum coverage levels:
64+
65+
| Metric | Threshold |
66+
|--------|-----------|
67+
| Statements | 85% |
68+
| Branches | 80% |
69+
| Functions | 80% |
70+
| Lines | 85% |
71+
72+
## Workflow Files
73+
74+
- `.github/workflows/coverage.yml` - Basic coverage with artifacts
75+
- `.github/workflows/coverage-pages.yml` - GitHub Pages publishing
76+
- `.github/workflows/pr-coverage.yml` - PR coverage comments
77+
78+
## Configuration
79+
80+
### nyc Configuration (`.nycrc`)
81+
```json
82+
{
83+
"reporter": ["text", "html", "lcov"],
84+
"check-coverage": true,
85+
"branches": 80,
86+
"lines": 85,
87+
"functions": 80,
88+
"statements": 85
89+
}
90+
```
91+
92+
### Coverage Files
93+
- `coverage/lcov.info` - LCOV format for external services
94+
- `coverage/index.html` - HTML report for browser viewing
95+
- `coverage/` - Complete coverage report directory
96+
97+
## Troubleshooting
98+
99+
### Coverage Report Not Found
100+
```bash
101+
# Generate coverage first
102+
npm run test:coverage:html
103+
104+
# Then view it
105+
npm run test:coverage:view
106+
```
107+
108+
### GitHub Pages Not Working
109+
1. Check repository settings → Pages
110+
2. Ensure GitHub Actions has Pages write permissions
111+
3. Verify workflow is running on main branch pushes
112+
113+
### Coverage Thresholds Failing
114+
1. Run `npm run test:coverage:check` to see specific failures
115+
2. Add tests for uncovered code paths
116+
3. Consider adjusting thresholds if appropriate
117+
118+
## Best Practices
119+
120+
1. **Always check coverage locally** before pushing
121+
2. **Review PR coverage comments** to understand impact
122+
3. **Use coverage artifacts** for detailed analysis
123+
4. **Monitor coverage trends** over time
124+
5. **Aim for meaningful coverage** rather than just hitting thresholds

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,51 @@ npm run transpile
4444

4545
# run tests
4646
npm run test
47+
48+
# run tests with coverage
49+
npm run test:coverage
50+
51+
# run tests with coverage and check thresholds
52+
npm run test:coverage:check
53+
54+
# generate HTML coverage report
55+
npm run test:coverage:html
4756
```
4857

58+
## Code Coverage
59+
60+
This project includes comprehensive code coverage reporting with multiple viewing options:
61+
62+
### Local Coverage
63+
- Run `npm run test:coverage:html` to generate an HTML coverage report locally
64+
- Open `coverage/index.html` in your browser to view the report
65+
66+
### GitHub Integration
67+
The project uses GitHub Actions to automatically generate and display coverage reports:
68+
69+
1. **PR Coverage Comments**: Every pull request automatically gets a coverage report comment showing:
70+
- Overall coverage percentages
71+
- Coverage changes compared to the base branch
72+
- Detailed file-by-file coverage breakdown
73+
74+
2. **Coverage Artifacts**: Coverage reports are uploaded as GitHub artifacts for each PR and commit
75+
- Download from the Actions tab in GitHub
76+
- Available for 30 days for main branch, 7 days for PRs
77+
78+
3. **GitHub Pages** (Optional): Coverage reports are published to GitHub Pages for easy browser viewing
79+
- Available at: `https://exabyte-io.github.io/ade.js/`
80+
- Updated on every push to main branch
81+
82+
### Coverage Thresholds
83+
The project enforces minimum coverage thresholds:
84+
- **Statements**: 85%
85+
- **Branches**: 80%
86+
- **Functions**: 80%
87+
- **Lines**: 85%
88+
89+
### External Coverage Services
90+
- **Codecov**: Coverage data is automatically uploaded to Codecov for historical tracking and trend analysis
91+
4992
ADe
5093
===
5194

0 commit comments

Comments
 (0)