Skip to content

Commit

Permalink
Add codecov extra features #1135
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuadkitenge committed Jan 10, 2025
1 parent 9564951 commit 3a6289a
Show file tree
Hide file tree
Showing 5 changed files with 323 additions and 14 deletions.
28 changes: 28 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Post comment if there are changes in bundle size of any size
comment:
require_bundle_changes: True

# Post comment if there are changes in bundle size exceeding 1Kb
comment:
require_bundle_changes: True
bundle_change_threshold: "1Kb"

# Post comment if there are changes in bundle size increases more than 1Mb
comment:
require_bundle_changes: "bundle_increase"
bundle_change_threshold: "1Mb"

# Post informational status (never fails) with threshold of 5%
# This is the default configuration
bundle_analysis:
warning_threshold: "5%"
status: "informational"

# Disable commit status
bundle_analysis:
status: False

# Post commit status that will fail if change is larger than threshold of 10MB
bundle_analysis:
warning_threshold: "10MB"
status: True
18 changes: 17 additions & 1 deletion .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,30 @@ jobs:
run: yarn lint

- name: Run unit tests
run: yarn test
run: yarn test --reporter=default --reporter=junit --outputFile=test-report.junit.xml

- name: Upload coverage reports to Codecov
if: success()
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

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

bundle_analysis:
name: Bundle Analysis
runs-on: ubuntu-latest

steps:
- name: Build app for production
env:
BUNDLE_ANALYZER_UPLOAD_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: yarn build

e2e-tests:
name: End-to-End (with mock data) Tests
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"packageManager": "[email protected]",
"devDependencies": {
"@babel/eslint-parser": "7.25.9",
"@codecov/vite-plugin": "^1.7.0",
"@eslint/compat": "1.2.4",
"@eslint/js": "9.17.0",
"@tanstack/eslint-plugin-query": "5.62.1",
Expand Down
10 changes: 9 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { codecovVitePlugin } from '@codecov/vite-plugin';
import react from '@vitejs/plugin-react';
import browserslistToEsbuild from 'browserslist-to-esbuild';
import fs from 'node:fs';
Expand Down Expand Up @@ -58,7 +59,14 @@ export default defineConfig(({ mode }) => {
// Whether to exclude MSW from the build
const excludeMSW = env.VITE_APP_INCLUDE_MSW !== 'true';

const plugins: PluginOption[] = [react()];
const plugins: PluginOption[] = [
react(),
codecovVitePlugin({
enableBundleAnalysis: env.CODECOV_TOKEN !== undefined,
bundleName: 'inventory-management-system',
uploadToken: env.CODECOV_TOKEN,
}),
];

// Allow hot reloading of json files in public folder when in development
if (env.NODE_ENV === 'development') plugins.push(jsonHMR());
Expand Down
Loading

0 comments on commit 3a6289a

Please sign in to comment.