diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6de550a8c..fbe1dcd59 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -117,42 +117,62 @@ jobs: # Verify libvirt is running using sudo to bypass group membership delays sudo virsh list --all || true - - uses: oven-sh/setup-bun@v2 - with: - bun-version: latest + - name: Build UI Package First + run: | + echo "🔧 Building UI package for web tests dependency..." + cd ../unraid-ui && pnpm run build - name: Run Tests Concurrently run: | set -e - # Run all tests in parallel with labeled output + # Run all tests in parallel with labeled output and coverage generation echo "🚀 Starting API coverage tests..." pnpm run coverage > api-test.log 2>&1 & API_PID=$! echo "🚀 Starting Connect plugin tests..." - (cd ../packages/unraid-api-plugin-connect && pnpm test) > connect-test.log 2>&1 & + (cd ../packages/unraid-api-plugin-connect && pnpm test --coverage 2>/dev/null || pnpm test) > connect-test.log 2>&1 & CONNECT_PID=$! echo "🚀 Starting Shared package tests..." - (cd ../packages/unraid-shared && pnpm test) > shared-test.log 2>&1 & + (cd ../packages/unraid-shared && pnpm test --coverage 2>/dev/null || pnpm test) > shared-test.log 2>&1 & SHARED_PID=$! + echo "🚀 Starting Web package coverage tests..." + (cd ../web && (pnpm test --coverage || pnpm test)) > web-test.log 2>&1 & + WEB_PID=$! + + echo "🚀 Starting UI package coverage tests..." + (cd ../unraid-ui && pnpm test --coverage 2>/dev/null || pnpm test) > ui-test.log 2>&1 & + UI_PID=$! + # Wait for all processes and capture exit codes wait $API_PID && echo "✅ API tests completed" || { echo "❌ API tests failed"; API_EXIT=1; } wait $CONNECT_PID && echo "✅ Connect tests completed" || { echo "❌ Connect tests failed"; CONNECT_EXIT=1; } wait $SHARED_PID && echo "✅ Shared tests completed" || { echo "❌ Shared tests failed"; SHARED_EXIT=1; } + wait $WEB_PID && echo "✅ Web tests completed" || { echo "❌ Web tests failed"; WEB_EXIT=1; } + wait $UI_PID && echo "✅ UI tests completed" || { echo "❌ UI tests failed"; UI_EXIT=1; } # Display all outputs echo "📋 API Test Results:" && cat api-test.log echo "📋 Connect Plugin Test Results:" && cat connect-test.log echo "📋 Shared Package Test Results:" && cat shared-test.log + echo "📋 Web Package Test Results:" && cat web-test.log + echo "📋 UI Package Test Results:" && cat ui-test.log # Exit with error if any test failed - if [[ ${API_EXIT:-0} -eq 1 || ${CONNECT_EXIT:-0} -eq 1 || ${SHARED_EXIT:-0} -eq 1 ]]; then + if [[ ${API_EXIT:-0} -eq 1 || ${CONNECT_EXIT:-0} -eq 1 || ${SHARED_EXIT:-0} -eq 1 || ${WEB_EXIT:-0} -eq 1 || ${UI_EXIT:-0} -eq 1 ]]; then exit 1 fi + - name: Upload all coverage reports to Codecov + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage/coverage-final.json,../web/coverage/coverage-final.json,../unraid-ui/coverage/coverage-final.json,../packages/unraid-api-plugin-connect/coverage/coverage-final.json,../packages/unraid-shared/coverage/coverage-final.json + fail_ci_if_error: false + build-api: name: Build API runs-on: ubuntu-latest diff --git a/readme.md b/readme.md index 7c6b1848b..301b0fa15 100644 --- a/readme.md +++ b/readme.md @@ -18,6 +18,7 @@ [![Issues][issues-shield]][issues-url] [![MIT License][license-shield]][license-url] [![LinkedIn][linkedin-shield]][linkedin-url] +[![Codecov][codecov-shield]][codecov-url] @@ -283,6 +284,8 @@ Project Link: [https://github.com/unraid/api](https://github.com/unraid/api) [license-url]: https://github.com/unraid/api/blob/main/LICENSE.txt [linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555 [linkedin-url]: https://www.linkedin.com/company/unraid +[codecov-shield]: https://img.shields.io/codecov/c/github/unraid/api?style=for-the-badge +[codecov-url]: https://codecov.io/gh/unraid/api [Nuxt.js]: https://img.shields.io/badge/Nuxt-002E3B?style=for-the-badge&logo=nuxtdotjs&logoColor=#00DC82 [Node.js]: https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge&logo=node.js&logoColor=white [PHP]: https://img.shields.io/badge/php-%23777BB4.svg?style=for-the-badge&logo=php&logoColor=white diff --git a/web/vitest.config.mjs b/web/vitest.config.mjs index 331dd1c2e..da7750963 100644 --- a/web/vitest.config.mjs +++ b/web/vitest.config.mjs @@ -22,6 +22,9 @@ export default defineConfig({ include: ['__test__/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts}'], testTimeout: 5000, hookTimeout: 5000, + coverage: { + reporter: ['text', 'json', 'html'], + }, }, resolve: { alias: {