The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Add module metrics (#70841)
Frasercf6e1c032ad6
diff --git a/.github/workflows/module-boundaries-stats.yml b/.github/workflows/module-boundaries-stats.ymlnew file mode 100644index 00000000000..65d170c8762--- /dev/null+++ b/.github/workflows/module-boundaries-stats.yml@@ -0,0 +1,78 @@+name: Module Boundaries Stats++on:+ workflow_dispatch:+ schedule:+ - cron: 40 1 * * 5 # every Friday at 1:40++jobs:+ module-boundaries-stats:+ runs-on: ubuntu-latest+ timeout-minutes: 10+ steps:+ - uses: actions/checkout@v4+ - uses: oven-sh/setup-bun@v2+ - name: Install dependencies+ run: bun install --frozen-lockfile+ - name: get module boundary stats+ id: get-stats+ run: |+ NAMED_MODULES=$(node --input-type=module -e "+ import { elements } from './frontend/lint/module-boundaries.mjs';+ const named = elements.filter(e => !['shared/other', 'app/misc', 'other'].includes(e.type));+ ")++ NAMED_DIRS=$(node --input-type=module -e "+ import { elements } from './frontend/lint/module-boundaries.mjs';+ const dirs = new Set();+ for (const el of elements) {+ const m = el.pattern.match(/^frontend\/src\/metabase\/(\w[\w-]*)\//)+ if (m) dirs.add(m[1]);+ }+ ")+ TOTAL_DIRS=$(ls -d frontend/src/metabase/*/ | xargs -I{} basename {} | wc -l | tr -d ' ')+ NAMED_COUNT=$(echo "$NAMED_DIRS" | grep -c . || true)+ UNMODULED=$(($TOTAL_DIRS - $NAMED_COUNT))++ VIOLATIONS=$(bun run module-boundaries 2>&1 | grep -o '✖ [0-9]* problems' | grep -o '[0-9]*' || echo "0")++ echo "$NAMED_MODULES modules, $UNMODULED unmoduled folders, $VIOLATIONS violations"++ echo "NAMED_MODULES=$NAMED_MODULES" >> $GITHUB_OUTPUT+ echo "UNMODULED=$UNMODULED" >> $GITHUB_OUTPUT+ echo "VIOLATIONS=$VIOLATIONS" >> $GITHUB_OUTPUT+ - name: Upload stats+ uses: actions/github-script@v7+ env:+ NAMED_MODULES: ${{ steps.get-stats.outputs.NAMED_MODULES }}+ UNMODULED: ${{ steps.get-stats.outputs.UNMODULED }}+ VIOLATIONS: ${{ steps.get-stats.outputs.VIOLATIONS }}+ API_KEY: ${{ secrets.STATS_API_KEY }}+ with:+ script: | # js+ const { uploadCsvToMb } = require('${{ github.workspace }}/.github/scripts/csv-to-mb.js');++ console.log("NAMED_MODULES", Number(process.env.NAMED_MODULES));+ console.log("UNMODULED", Number(process.env.UNMODULED));+ console.log("VIOLATIONS", Number(process.env.VIOLATIONS));++ const data = [+ {+ 'Date': new Date().toISOString().slice(0, 10), // YYYY-MM-DD+ 'Modules': Number(process.env.NAMED_MODULES),+ 'Unmoduled folders': Number(process.env.UNMODULED),+ 'Violations': Number(process.env.VIOLATIONS),+ }+ ];++ uploadCsvToMb({+ baseUrl: 'https://stats.metabase.com',+ tableId: 75146,+ jsonData: data,+ mode: 'append',+ }).then(() => {+ console.log('Data uploaded successfully');+ }).catch((error) => {+ console.error('Error uploading data:', error);+ process.exit(1);+ });