Skip to content
CI/CD Inventory

galaxyproject/galaxy-visualizations (opens in new tab)

1 workflow

Triggers

pull_request

Jobs

Jobs for Test Visualizations
Job Runs on Steps Actions used
discover ubuntu-latest 2
actions/checkout@v5
test ubuntu-latest 8
actions/checkout@v5 actions/setup-node@v5 actions/cache@v4 actions/setup-python@v6
test-playwright ubuntu-latest 16
actions/checkout@v5 actions/setup-node@v5 actions/cache@v4 actions/cache@v4 actions/setup-python@v6 actions/upload-artifact@v4 actions/upload-artifact@v4
Raw YAML
name: Test Visualizations

on:
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  discover:
    runs-on: ubuntu-latest
    outputs:
      packages: ${{ steps.set-packages.outputs.packages }}
      playwright_packages: ${{ steps.set-packages.outputs.playwright_packages }}
    steps:
      - uses: actions/checkout@v5
      
      - name: Discover packages with tests
        id: set-packages
        run: |
          echo "Scanning packages for test scripts..."

          regular_packages=()
          playwright_packages=()
          no_test_script=()
          for dir in packages/*/; do
            pkg=$(basename "$dir")
            if [ -f "$dir/package.json" ]; then
              test_script=$(jq -r ".scripts.test // \"\"" "$dir/package.json")
              if [ -n "$test_script" ]; then
                # Check for Playwright in test script or dependencies
                if [[ "$test_script" == *"playwright"* ]] || \
                   jq -e '.devDependencies | has("@playwright/test") or has("playwright")' "$dir/package.json" > /dev/null 2>&1; then
                  playwright_packages+=("$pkg")
                else
                  regular_packages+=("$pkg")
                fi
              else
                no_test_script+=("$pkg")
              fi
            fi
          done
          packages=$(printf '%s\n' "${regular_packages[@]}" | jq -R -s -c 'split("\n") | map(select(length > 0))')
          echo "packages=$packages" >> $GITHUB_OUTPUT
          
          playwright_packages_json=$(printf '%s\n' "${playwright_packages[@]}" | jq -R -s -c 'split("\n") | map(select(length > 0))')
          echo "playwright_packages=$playwright_packages_json" >> $GITHUB_OUTPUT
          
          echo ""
          echo "✅ Regular packages with test script (${#regular_packages[@]}):"
          printf '  - %s\n' "${regular_packages[@]}"
          echo ""
          echo "✅ Playwright packages with test script (${#playwright_packages[@]}):"
          printf '  - %s\n' "${playwright_packages[@]}"
          echo ""
          echo "❌ Packages without test script (${#no_test_script[@]}):"
          printf '  - %s\n' "${no_test_script[@]}"

  test:
    needs: discover
    if: needs.discover.outputs.packages != '[]'
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        package: ${{ fromJson(needs.discover.outputs.packages) }}
    
    steps:
      - uses: actions/checkout@v5

      - name: Setup Node.js
        uses: actions/setup-node@v5
        with:
          node-version: 20

      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: packages/${{ matrix.package }}/node_modules
          key: ${{ runner.os }}-node-${{ matrix.package }}-${{ hashFiles(format('packages/{0}/package-lock.json', matrix.package)) }}
          restore-keys: |
            ${{ runner.os }}-node-${{ matrix.package }}-

      - name: Check for requirements.txt
        id: check-python
        working-directory: packages/${{ matrix.package }}
        run: |
          if [ -f requirements.txt ]; then
            echo "has_requirements=true" >> $GITHUB_OUTPUT
          else
            echo "has_requirements=false" >> $GITHUB_OUTPUT
          fi

      - name: Setup Python
        if: steps.check-python.outputs.has_requirements == 'true'
        uses: actions/setup-python@v6
        with:
          python-version: '3.13'
          cache: pip
          cache-dependency-path: packages/${{ matrix.package }}/requirements.txt

      - name: Install Python dependencies
        if: steps.check-python.outputs.has_requirements == 'true'
        working-directory: packages/${{ matrix.package }}
        run: pip install -r requirements.txt

      - name: Install Node dependencies
        working-directory: packages/${{ matrix.package }}
        run: npm install

      - name: Run tests
        working-directory: packages/${{ matrix.package }}
        run: npm test

  test-playwright:
    needs: discover
    if: needs.discover.outputs.playwright_packages != '[]'
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        package: ${{ fromJson(needs.discover.outputs.playwright_packages) }}
    
    steps:
      - uses: actions/checkout@v5

      - name: Setup Node.js
        uses: actions/setup-node@v5
        with:
          node-version: 20

      - name: Cache Node dependencies
        uses: actions/cache@v4
        with:
          path: packages/${{ matrix.package }}/node_modules
          key: ${{ runner.os }}-node-${{ matrix.package }}-${{ hashFiles(format('packages/{0}/package-lock.json', matrix.package)) }}
          restore-keys: |
            ${{ runner.os }}-node-${{ matrix.package }}-

      - name: Cache Playwright browsers
        uses: actions/cache@v4
        with:
          path: ~/.cache/ms-playwright
          key: ${{ runner.os }}-playwright-${{ hashFiles(format('packages/{0}/package-lock.json', matrix.package)) }}
          restore-keys: |
            ${{ runner.os }}-playwright-

      - name: Check for requirements.txt
        id: check-python
        working-directory: packages/${{ matrix.package }}
        run: |
          if [ -f requirements.txt ]; then
            echo "has_requirements=true" >> $GITHUB_OUTPUT
          else
            echo "has_requirements=false" >> $GITHUB_OUTPUT
          fi

      - name: Setup Python
        if: steps.check-python.outputs.has_requirements == 'true'
        uses: actions/setup-python@v6
        with:
          python-version: '3.13'
          cache: pip
          cache-dependency-path: packages/${{ matrix.package }}/requirements.txt

      - name: Install Python dependencies
        if: steps.check-python.outputs.has_requirements == 'true'
        working-directory: packages/${{ matrix.package }}
        run: pip install -r requirements.txt

      - name: Install Node dependencies
        working-directory: packages/${{ matrix.package }}
        run: npm install

      - name: Install Playwright browsers
        working-directory: packages/${{ matrix.package }}
        run: npx playwright install --with-deps chromium

      - name: Build
        working-directory: packages/${{ matrix.package }}
        run: npm run build

      - name: Start Server in background
        working-directory: packages/${{ matrix.package }}
        run: |
          nohup npm run dev > server.log 2>&1 &
          echo $! > server.pid

      - name: Wait for Server to be ready
        run: |
          echo "Waiting for server to be ready..."
          ports=(5173 8000 8080)
          for i in {1..60}; do
            for port in "${ports[@]}"; do
              if curl -s http://localhost:$port > /dev/null 2>&1; then
                echo "✅ Server is ready on port $port!"
                exit 0
              fi
            done
            echo "Attempt $i/60..."
            sleep 2
          done
          echo "❌ Server failed to start!"
          cat packages/${{ matrix.package }}/server.log
          exit 1

      - name: Run Playwright Tests
        working-directory: packages/${{ matrix.package }}
        run: npm test

      - name: Stop Server
        if: always()
        working-directory: packages/${{ matrix.package }}
        run: |
          if [ -f server.pid ]; then
            kill $(cat server.pid) 2>/dev/null || true
            rm server.pid
          fi

      - name: Upload Playwright Report
        if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: playwright-report-${{ matrix.package }}
          path: packages/${{ matrix.package }}/playwright-report/
          retention-days: 7

      - name: Upload Test Results
        if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: playwright-test-results-${{ matrix.package }}
          path: packages/${{ matrix.package }}/test-results/
          retention-days: 7

Last fetched: