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 auto-detection of changed Loki stories for stress testing (#68951)
Nemanja Glumaccb119f840b21
diff --git a/.github/workflows/loki-stress-test-flake-fix.yml b/.github/workflows/loki-stress-test-flake-fix.ymlindex 0700f3b19bd..5a34aae309d 100644--- a/.github/workflows/loki-stress-test-flake-fix.yml+++ b/.github/workflows/loki-stress-test-flake-fix.yml@@ -1,10 +1,15 @@name: Loki Visual Stress Test Flake Fixon:+ pull_request:+ types: [opened, synchronize, reopened]+ paths:+ - 'frontend/**/*.stories.tsx'+ - 'enterprise/frontend/**/*.stories.tsx'workflow_dispatch:inputs:- stories_filter:- description: "Regex pattern to filter stories (e.g. 'DataGrid' or 'static-viz|viz')"+ story_files:+ description: "Comma-separated story file paths relative to repo root"type: stringrequired: trueburn_in:@@ -14,22 +19,96 @@ on:default: "50"jobs:+ detect-changed-stories:+ name: Detect changed stories+ runs-on: ubuntu-22.04+ timeout-minutes: 5+ outputs:+ story_files: ${{ steps.detect.outputs.story_files }}+ should_run: ${{ steps.detect.outputs.should_run }}+ steps:+ - name: Detect changed story files+ id: detect+ env:+ GH_TOKEN: ${{ github.token }}+ run: |+ validate_paths() {+ local files="$1"+ for file in $(echo "$files" | tr ',' '\n'); do+ file=$(echo "$file" | xargs) # trim whitespace+ if [[ -z "$file" ]]; then+ continue+ fi+ if [[ ! "$file" =~ ^(frontend/|enterprise/frontend/).+\.stories\. ]]; then+ echo "::error::Invalid story path: $file"+ echo "Paths must start with 'frontend/' or 'enterprise/frontend/' and contain '.stories.'"+ return 1+ fi+ done+ return 0+ }++ if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then+ FILES=$(echo "${{ inputs.story_files }}" | tr ',' '\n' | xargs -n1 | paste -sd',')+ if ! validate_paths "$FILES"; then+ exit 1+ fi+ echo "story_files=$FILES" >> $GITHUB_OUTPUT+ echo "should_run=true" >> $GITHUB_OUTPUT+ exit 0+ fi++ FILES=$( \+ gh pr view ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --json files --jq '.files[].path' \+ | grep '\.stories\.tsx$' \+ | xargs -n1 \+ | sort -u \+ | paste -sd',' \+ )++ if [[ -z "$FILES" ]]; then+ echo "No changed story files found"+ echo "should_run=false" >> $GITHUB_OUTPUT+ exit 0+ fi++ if ! validate_paths "$FILES"; then+ exit 1+ fi++ echo "Changed story files: $FILES"+ echo "story_files=$FILES" >> $GITHUB_OUTPUT+ echo "should_run=true" >> $GITHUB_OUTPUT+workflow-summary:- name: Stress test inputs+ name: Summary+ needs: detect-changed-stories+ if: needs.detect-changed-stories.outputs.should_run == 'true'runs-on: ubuntu-22.04timeout-minutes: 5steps:- name: Generate workflow summaryrun: |- echo '**Inputs:**' >> $GITHUB_STEP_SUMMARY+ echo '## Loki Stress Test' >> $GITHUB_STEP_SUMMARYecho '' >> $GITHUB_STEP_SUMMARY- echo '- `branch`: ${{ github.ref_name }}' >> $GITHUB_STEP_SUMMARY- echo '- `stories_filter`: ${{ inputs.stories_filter }}' >> $GITHUB_STEP_SUMMARY- echo '- `burn_in`: ${{ inputs.burn_in }}' >> $GITHUB_STEP_SUMMARY+ echo '**Branch:** `${{ github.head_ref || github.ref_name }}`' >> $GITHUB_STEP_SUMMARYecho '' >> $GITHUB_STEP_SUMMARY- echo 'triggered by: @${{ github.event.sender.login }}' >> $GITHUB_STEP_SUMMARY+ echo '**Story files:**' >> $GITHUB_STEP_SUMMARY+ echo '${{ needs.detect-changed-stories.outputs.story_files }}' | tr ',' '\n' | while read -r file; do+ echo "- \`$file\`" >> $GITHUB_STEP_SUMMARY+ done+ echo '' >> $GITHUB_STEP_SUMMARY+ echo '**Burn-in:** ${{ inputs.burn_in || 50 }} runs' >> $GITHUB_STEP_SUMMARY+ echo '' >> $GITHUB_STEP_SUMMARY+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then+ echo 'Triggered by PR #${{ github.event.pull_request.number }} from @${{ github.event.pull_request.user.login }}' >> $GITHUB_STEP_SUMMARY+ else+ echo 'Triggered manually by @${{ github.actor }}' >> $GITHUB_STEP_SUMMARY+ fistress-test-loki:+ needs: detect-changed-stories+ if: needs.detect-changed-stories.outputs.should_run == 'true'runs-on: ubuntu-latesttimeout-minutes: 60name: Stress test Loki visual tests@@ -58,15 +137,18 @@ jobs:- name: Compile CLJSrun: NODE_ENV=development yarn build-pure:cljs- - name: Build Storybook (once)+ - name: Build Storybookrun: yarn build-storybook+ env:+ STORYBOOK_STORIES_FILTER: ${{ needs.detect-changed-stories.outputs.story_files }}- - name: Stress-test Loki "${{ inputs.stories_filter }}" ${{ inputs.burn_in }} times+ - name: Stress-test Lokirun: |- BURN_IN=${{ inputs.burn_in }}- STORIES_FILTER='${{ inputs.stories_filter }}'+ BURN_IN=${{ inputs.burn_in || '50' }}+ STORY_FILES='${{ needs.detect-changed-stories.outputs.story_files }}'- echo "Running Loki visual tests $BURN_IN times for stories matching: $STORIES_FILTER"+ echo "Story files: $STORY_FILES"+ echo "Running Loki $BURN_IN times"echo ""FAILED=0@@ -77,8 +159,7 @@ jobs:if yarn test-visual:loki \--reactUri file:./storybook-static \- --verboseRenderer \- --storiesFilter "$STORIES_FILTER"; then+ --verboseRenderer; thenecho "✅ Run $i passed"elseecho "❌ Run $i FAILED"@@ -104,7 +185,6 @@ jobs:run: yarn test-visual:loki-report- name: Upload Artifact- id: artifact-upload-stepif: failure()uses: actions/upload-artifact@v4with:diff --git a/.storybook/main.ts b/.storybook/main.tsindex 07ebb77babc..ec19916cfc1 100644--- a/.storybook/main.ts+++ b/.storybook/main.ts@@ -11,8 +11,15 @@ const mainAppStories = ["../enterprise/frontend/**/*.stories.@(js|jsx|ts|tsx)",];+// Allow filtering to specific story files via env var (used by stress tests)+// STORYBOOK_STORIES_FILTER: comma-separated file paths relative to repo root+// e.g. "frontend/src/.../Button.stories.tsx,frontend/src/.../Alert.stories.tsx"+const stories = process.env.STORYBOOK_STORIES_FILTER+ ? process.env.STORYBOOK_STORIES_FILTER.split(",").map((f) => `../${f}`)+ : mainAppStories;+const config: StorybookConfig = {- stories: mainAppStories,+ stories,staticDirs: ["../resources/frontend_client", "./msw-public"],addons: ["@storybook/addon-webpack5-compiler-babel",