Skip to content

Playwright UI Tests

Playwright UI Tests #2

Workflow file for this run

name: Playwright UI Tests
on:
push:
branches:
- "main"
# paths:
# - "web/**"
pull_request:
branches:
- "*"
# paths:
# - "web/**"
env:
COLUMNS: 150
ZO_ROOT_USER_EMAIL: [email protected]
ZO_ROOT_USER_PASSWORD: Complexpass#123
ZO_BASE_URL: http://localhost:5080
INGESTION_URL: http://localhost:5080
ORGNAME: default
ZO_QUICK_MODE_NUM_FIELDS: 5
ZO_QUICK_MODE_STRATEGY: first
ZO_ALLOW_USER_DEFINED_SCHEMAS: true
ZO_INGEST_ALLOWED_UPTO: 5
ZO_FEATURE_QUERY_EXCLUDE_ALL: false
ZO_USAGE_BATCH_SIZE: 200
ZO_USAGE_PUBLISH_INTERVAL: 2
ZO_USAGE_REPORTING_ENABLED: true
jobs:
build_binary:
name: build_binary
runs-on:
labels: ubicloud-standard-8
steps:
- name: Remove unused tools
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Clone the current repo
uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-10-24
targets: x86_64-unknown-linux-gnu
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "21.12"
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Build frontend code
env:
NODE_OPTIONS: "--max-old-space-size=8192"
VITE_COVERAGE: "true"
COVERAGE: "true"
run: cd web && npm install && npm run build
- name: Build and run binary
run: cargo build --release --target x86_64-unknown-linux-gnu
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: debug-binary
path: target/x86_64-unknown-linux-gnu/release/openobserve
retention-days: 1
ui_integration_tests:
name: playwright_ui_integration_tests
needs: [build_binary]
runs-on:
labels: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.42.1-jammy
options: --user root
strategy:
matrix:
browser: [chrome]
testfilename:
[
"sanity.spec.js",
"alerts.spec.js",
"schema.spec.js",
"logspage.spec.js",
"logsqueries.spec.js",
"logsquickmode.spec.js",
"multiselect-stream.spec.js",
"pipelines.spec.js",
"dashboards/dashboardtype.spec.js",
"dashboards/dashboard.spec.js",
"dashboards/visualize.spec.js",
"unflattened.spec.js",
"secondsPrecisionAdded.spec.js",
"dashboards/visualization-vrl.spec.js",
"dashboards/dashboard-transpose.spec.js",
"dashboards/dashboard-general-setting.spec.js",
"dashboards/dashboard-variables-setting.spec.js",
"dashboards/dashboard-tabs-setting.spec.js",
"reportsUpdated.spec.js",
"join.spec.js",
"changeOrg.spec.js",
"serviceAccount.spec.js",
"enrichment.spec.js",
]
steps:
- name: Clone the current repo
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Start OpenObserve
run: chmod +x ./debug-binary/openobserve && ./debug-binary/openobserve > o2.log 2>&1 &
- name: Wait for start
run: sleep 15
- name: Ensure we are getting a reply from the server
run: curl http://localhost:5080/web/login
- name: Create coverage json folder
run: mkdir -p tests/ui-testing/.nyc_output
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies and run ui-tests
run: |
touch .env
echo "ZO_ROOT_USER_EMAIL=${ZO_ROOT_USER_EMAIL}" >> .env
echo "ZO_ROOT_USER_PASSWORD=${ZO_ROOT_USER_PASSWORD}" >> .env
echo "ZO_BASE_URL=${ZO_BASE_URL}" >> .env
echo "INGESTION_URL=${INGESTION_URL}" >> .env
echo "ORGNAME=${ORGNAME}" >> .env
mv .env tests/ui-testing
cd tests/ui-testing && npm ci && npx playwright test ./playwright-tests/${{ matrix.testfilename }}
# - name: Check OpenObserve logs
# if: always()
# run: cat o2.log
- name: Sanitize Test Filename
shell: bash
run: |
# Assign the matrix variable to a Bash variable
SANITIZED_FILENAME="${{ matrix.testfilename }}"
# Replace all '/' characters with '_'
SANITIZED_FILENAME="${SANITIZED_FILENAME//\//_}"
# Export as a GitHub Actions environment variable
echo "SANITIZED_FILENAME=$SANITIZED_FILENAME" >> $GITHUB_ENV
- name: Upload Coverage Data
uses: actions/upload-artifact@v4
with:
name: playwright-coverage-${{ env.SANITIZED_FILENAME }}
path: tests/ui-testing/.nyc_output
include-hidden-files: true
- name: Generate Coverage Report
run: cd tests/ui-testing && npx nyc report
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
generate_coverage_report:
name: Generate Coverage Report
needs: [build_binary, ui_integration_tests]
runs-on: ubuntu-latest
if: always()
steps:
- name: Clone the current repo
uses: actions/checkout@v4
- name: Download Playwright Coverage Data
uses: actions/download-artifact@v4
with:
pattern: playwright-coverage-* # Match all artifacts with this prefix
path: merged-coverage
merge-multiple: true
- name: Verify Downloaded Files
run: ls -R merged-coverage # Check the structure and contents
- name: Move Coverage Files to .nyc_output
run: |
mkdir -p tests/ui-testing/.nyc_output
mv merged-coverage/* tests/ui-testing/.nyc_output/ || echo "No files to move"
- name: Generate Coverage Report
run: cd tests/ui-testing && npm ci && npx nyc report
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: tests/ui-testing/coverage-report
retention-days: 30