Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b3f8c43
Update ci.yml
nofarb Jun 12, 2025
0537289
Update package.json
nofarb Jun 12, 2025
515a571
Update vite.config.js
nofarb Jun 12, 2025
cd164d3
Update enforce-license-compliance.yml
nofarb Jun 12, 2025
094a266
Update vite.config.js
nofarb Jun 12, 2025
3d6580b
Update package.json
nofarb Jun 12, 2025
0bbef1d
Update package.json
nofarb Jun 12, 2025
7a0e565
Update vite.config.js
nofarb Jun 12, 2025
33c9c3f
Update package.json
nofarb Jun 12, 2025
fc60a4e
Update ci.yml
nofarb Jun 12, 2025
644a765
Update ci.yml
nofarb Jun 12, 2025
0aecfea
Update ci.yml
nofarb Jun 12, 2025
97f82b3
Update vite.config.js
nofarb Jun 13, 2025
21b3a03
Update vite.config.js
nofarb Jun 13, 2025
5c461ee
Update package.json
nofarb Jun 13, 2025
b1e6f8d
Update package.json
nofarb Jun 13, 2025
f363e9b
Update vite.config.js
nofarb Jun 13, 2025
9956e10
Update ci.yml
nofarb Jun 13, 2025
4e7e737
Update ci.yml
nofarb Jun 13, 2025
df8ad67
Update vite.config.js
nofarb Jun 13, 2025
d3a0a0e
Update vite.config.js
nofarb Jun 13, 2025
29fd99b
Update ci.yml
nofarb Jun 13, 2025
35b9032
Update calculator.test.js
nofarb Jun 13, 2025
6c03226
Delete .circleci directory
nofarb Jun 13, 2025
6994cf8
added logic
nofarblue Jun 13, 2025
79451a5
added tests
nofarblue Jun 13, 2025
4de0ba9
added tests
nofarblue Jun 13, 2025
45c743b
added tests
nofarblue Jun 13, 2025
630785f
added bundle
nofarblue Jun 13, 2025
61cd6b4
Update README.md
nofarb Jun 13, 2025
4ca7241
Merge pull request #5 from nofarb/nofarb-patch-2
nofarb Jun 13, 2025
fe13f66
Update ci.yml
nofarb Jun 13, 2025
b25b4fb
tru sonar
nofarb Jun 13, 2025
c8496d3
Delete .github/workflows/enforce-license-compliance.yml
nofarb Jun 13, 2025
df8d857
fix sonar integration
nofarb Jun 13, 2025
ec47494
Update ci.yml
nofarb Jun 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 0 additions & 122 deletions .circleci/config.yml

This file was deleted.

97 changes: 88 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,99 @@
name: Workflow for Codecov example-javascript
name: Codecov CI with Vitest and SonarQube

on: [push, pull_request]

jobs:
run:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node 18

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm install
- name: Run tests and collect coverage
run: npm run test
- name: Upload coverage to Codecov

- name: Initialize clean package.json
run: |
npm init -y
npm install vitest@1.6.1 @vitest/coverage-v8@1.6.1
# Optional: only install Codecov bundle plugin if you want bundle analysis:
# npm install @codecov/vite-plugin@latest

- name: Add test & build scripts manually
run: |
jq '.scripts.test="vitest run --coverage"' package.json > tmp.json && mv tmp.json package.json
jq '.scripts.build="vite build"' package.json > tmp.json && mv tmp.json package.json

- name: Create vitest.config.ts
run: |
echo "import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
include: ['app/**/*.test.js'],
coverage: {
provider: 'v8',
reporters: ['text', 'json', 'html', 'lcov'],
reportDir: 'coverage'
},
reporters: [
'default',
['junit', { outputFile: 'junit.xml' }]
]
}
})" > vitest.config.ts

# Uncomment this block if you eventually want bundle analysis enabled again:
#
# - name: Create vite.config.js (for Codecov Bundle Analysis)
# run: |
# echo "import { defineConfig } from 'vite';
# import { codecovVitePlugin } from '@codecov/vite-plugin';
# export default defineConfig({
# plugins: [
# codecovVitePlugin({
# enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
# bundleName: 'example-javascript',
# uploadToken: process.env.CODECOV_TOKEN
# })
# ]
# })" > vite.config.js

# - name: Build app for bundle analysis
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
# run: npm run build

- name: Run tests with coverage
run: npm run test || true

- name: List coverage files (debugging)
run: ls -R coverage

- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}

- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_ORG_TOKEN }}

- name: Install SonarQube scanner
run: npm install -g sonarqube-scanner

- name: Run SonarQube scanner
run: |
sonar-scanner \
-Dsonar.projectKey=nofarb_example-javascript \
-Dsonar.sources=app \
-Dsonar.organization=nofarb \
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info \
-Dsonar.host.url=${{ vars.SONAR_HOST_URL }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }}
14 changes: 0 additions & 14 deletions .github/workflows/enforce-license-compliance.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For more information, please see the links below.
- [Community Boards](https://community.codecov.io)
- [Support](https://codecov.io/support)
- [Documentation](https://docs.codecov.io)


## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-javascript.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-javascript?ref=badge_large)
File renamed without changes.
16 changes: 2 additions & 14 deletions app/calculator.test.js → app/core/calculator.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from '@jest/globals';
import { expect, test } from 'vitest';

import {
add,
Expand All @@ -25,17 +25,5 @@ test('subtract function', () => {
});

test('multiply function', () => {
expect(multiply(1, 2)).toBe(2.0);
expect(multiply(1.0, 2.0)).toBe(2.0);
expect(multiply(0, 2.0)).toBe(0.0);
expect(multiply(2.0, 0)).toBe(0.0);
expect(multiply(-4, 2.0)).toBe(-8.0);
});

test('divide function', () => {
expect(divide(1, 2)).toBe(0.5);
expect(divide(1.0, 2.0)).toBe(0.5);
expect(divide(0, 2.0)).toBe(0);
expect(divide(-4, 2.0)).toBe(-2.0);
// expect(divide(2.0, 0)).toBe('Cannot divide by 0');
expect(multiply(1, 2)).toBe(2);
});
13 changes: 13 additions & 0 deletions app/utils/mathUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export function square(x) {
return x * x;
}

export function cube(x) {
return x * x * x;
}

export function factorial(n) {
if (n === 0) return 1;
return n * factorial(n - 1);
}

14 changes: 14 additions & 0 deletions app/utils/mathUtils.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { expect, test } from 'vitest';
import { square, cube, factorial } from './mathUtils';

test('square function', () => {
expect(square(2)).toBe(4);
expect(square(-3)).toBe(9);
});

test('cube function', () => {
expect(cube(2)).toBe(8);
expect(cube(-3)).toBe(-27);
});

// Intentionally leave factorial untested for now
Empty file added index.html
Empty file.
2 changes: 2 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { square } from './app/mathUtils.js';
console.log(square(5));
15 changes: 5 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
{
"name": "@codecov/example-javascript",
"version": "0.0.1",
"description": "Codecov Example Javascript",
"name": "example-javascript",
"version": "1.0.0",
"scripts": {
"test": "vitest run --coverage --coverageReporters=lcov --coverageReporters=text --coverageReporters=html"

"test": "vitest run --coverage"
},
"dependencies": {
"vitest": "^3.0.0",
"codecov": "^3.8.0"
"vitest": "1.6.1"
},
"devDependencies": {
"jest": "^29.0.0",
"jest-environment-jsdom": "^29.0.0",
"codecov": "^3.8.0"
"@vitest/coverage-v8": "1.6.1"
}
}
14 changes: 9 additions & 5 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { defineConfig } from 'vitest/config'
import { defineConfig } from "vite";


export default defineConfig({
test: {
include: ['app/**/*.test.js'],
coverage: {
provider: 'v8', // Use V8 as the coverage provider
reporters: ['text', 'json', 'html', 'lcov'], // Include 'html' and 'lcov' for HTML and LCOV reports
reportDir: 'coverage', // Optional: specify the directory for coverage reports
},
},
provider: 'v8',
reporters: ['lcov', 'text', 'json', 'html'],
reportDir: 'coverage'
}
}
})

Loading