Run tests for 2 Grafana versions #476
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - test-old-grafana | |
| pull_request: | |
| branches: | |
| - main | |
| - test-old-grafana | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| grafana: ['9.5.0', '11.6.1'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js environment | |
| uses: actions/setup-node@v4.3.0 | |
| with: | |
| node-version: "14.x" | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Build and test frontend | |
| run: yarn build | |
| - name: Setup Go environment | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.22" | |
| - name: Test backend | |
| uses: magefile/mage-action@v3 | |
| with: | |
| version: latest | |
| args: coverage | |
| - name: Build backend | |
| uses: magefile/mage-action@v3 | |
| with: | |
| version: latest | |
| args: buildAll | |
| - name: Setup services (Trino, Grafana, Keycloak) | |
| run: | | |
| docker network create trino | |
| echo "Starting Keycloak..." | |
| docker run --rm --detach \ | |
| --name keycloak \ | |
| --net trino \ | |
| --publish 18080:8080 \ | |
| --env KC_BOOTSTRAP_ADMIN_USERNAME=admin \ | |
| --env KC_BOOTSTRAP_ADMIN_PASSWORD=admin \ | |
| --volume "$(pwd)/test-data/test-keycloak-realm.json:/opt/keycloak/data/import/realm.json" \ | |
| quay.io/keycloak/keycloak:26.1.4 \ | |
| start-dev --import-realm | |
| echo "Waiting for Keycloak to be ready..." | |
| while true; do | |
| if curl -s http://localhost:18080/realms/master | grep -q "realm"; then | |
| echo "Keycloak is ready!" | |
| break | |
| fi | |
| echo "Waiting for Keycloak..." | |
| sleep 5 | |
| done | |
| echo "Starting Trino..." | |
| docker run --rm --detach \ | |
| --name trino \ | |
| --net trino \ | |
| --volume "$(pwd)/test-data/test-trino-config.properties:/etc/trino/config.properties" \ | |
| --volume "$(pwd)/test-data/tpch.properties:/etc/trino/catalog/tpch.properties" \ | |
| trinodb/trino:468 | |
| echo "Waiting for Trino to be ready..." | |
| TIMEOUT=120 | |
| ELAPSED=0 | |
| while true; do | |
| if docker exec trino trino --execute "SELECT 1" &>/dev/null; then | |
| echo "Trino is ready!" | |
| break | |
| fi | |
| if [ $ELAPSED -ge $TIMEOUT ]; then | |
| echo "Timeout waiting for Trino to be ready" | |
| docker logs trino | |
| exit 1 | |
| fi | |
| echo "Waiting for Trino... ($ELAPSED/$TIMEOUT seconds)" | |
| sleep 5 | |
| ELAPSED=$((ELAPSED + 5)) | |
| done | |
| echo "Verifying TPCH catalog is available..." | |
| docker exec trino trino --execute "SHOW CATALOGS" || echo "Warning: Could not verify catalogs" | |
| echo "Starting Grafana..." | |
| docker run --rm --detach \ | |
| --name grafana \ | |
| --net trino \ | |
| --publish 3000:3000 \ | |
| --volume "$(pwd):/var/lib/grafana/plugins/trino" \ | |
| --env "GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=trino-datasource" \ | |
| grafana/grafana:${{ matrix.grafana }} | |
| echo "Waiting for Grafana to be ready..." | |
| TIMEOUT=120 | |
| ELAPSED=0 | |
| while true; do | |
| if curl -s http://localhost:3000/api/health | grep -q "ok"; then | |
| echo "Grafana is ready!" | |
| break | |
| fi | |
| if [ $ELAPSED -ge $TIMEOUT ]; then | |
| echo "Timeout waiting for Grafana to be ready" | |
| docker logs grafana | |
| exit 1 | |
| fi | |
| echo "Waiting for Grafana... ($ELAPSED/$TIMEOUT seconds)" | |
| sleep 5 | |
| ELAPSED=$((ELAPSED + 5)) | |
| done | |
| - name: End to end test | |
| env: | |
| GRAFANA_VERSION: ${{ matrix.grafana }} | |
| run: | | |
| npx tsc -p tsconfig.json --noEmit | |
| npx playwright install | |
| npx playwright test | |
| - uses: actions/upload-artifact@v4 | |
| if: ${{ !cancelled() }} | |
| with: | |
| name: playwright-report-${{ matrix.grafana }} | |
| path: playwright-report/ | |
| retention-days: 5 | |
| - name: Dump logs | |
| if: always() | |
| run: | | |
| echo "::group::Trino logs" | |
| docker logs trino | |
| echo "::endgroup::" | |
| echo "::group::Keycloak logs" | |
| docker logs keycloak | |
| echo "::endgroup::" | |
| echo "::group::Grafana logs" | |
| docker logs grafana | |
| echo "::endgroup::" |