Skip to content

On-demand Workflow for WebApp Playwright Tests #1

On-demand Workflow for WebApp Playwright Tests

On-demand Workflow for WebApp Playwright Tests #1

name: WebApp E2E Tests On Demand
#on:
# workflow_dispatch:
# inputs:
# branch:
# description: "Enter the branch to test"
# required: true
# default: "main"
on:
pull_request:
types: [opened, edited, synchronize] # Triggers on PR open, new comits on PR and when the PR description is edited
permissions:
contents: read
jobs:
validate-branch:
runs-on: ubuntu-latest
outputs:
base: ${{ steps.detect-base.outputs.base }}
steps:
- name: Check if branch exists
run: |
echo "Checking if branch '${{ github.event.inputs.branch }}' exists..."
branch_name="${{ github.event.inputs.branch }}"
branch_check=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/branches/$branch_name)
if [[ "$branch_check" != "200" ]]; then
echo "Error: Branch '$branch_name' does not exist (HTTP $branch_check)."
exit 1
fi
echo "Branch '$branch_name' exists."
- uses: actions/checkout@v4
- name: Detect base branch
id: detect-base
run: |
branch="${{ github.event.inputs.branch }}"
echo "Detecting base branch for input branch: $branch"
git fetch origin stable/8.6 stable/8.7 stable/8.8 main "$branch"
base="main"
for candidate in stable/8.6 stable/8.7 stable/8.8 main; do
if git merge-base --is-ancestor origin/$candidate origin/$branch; then
base="$candidate"
break
fi
done
echo "Detected base branch: $base"
echo "base=$base" >> "$GITHUB_OUTPUT"
webapp-e2e-tests:
name: WebApp E2E Tests (Tasklist ${{ matrix.tasklist_mode }} mode)
strategy:
fail-fast: false
matrix:
tasklist_mode: ${{ fromJSON( (needs.validate-branch.outputs.base == 'stable/8.6' || needs.validate-branch.outputs.base == 'stable/8.7') && '["v1"]' || '["v1","v2"]' ) }}
needs: [validate-branch]
runs-on: ubuntu-latest
steps:
- name: Print input and base branch
run: |
echo "Input branch: ${{ github.event.inputs.branch }}"
echo "Base branch: ${{ needs.validate-branch.outputs.base }}"
echo "Tasklist mode: ${{ matrix.tasklist_mode }}"
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Set NON_STANDALONE variable
run: |
base="${{ needs.validate-branch.outputs.base }}"
if [[ "$base" == "stable/8.6" || "$base" == "stable/8.7" ]]; then
echo "NON_STANDALONE=true" >> "$GITHUB_ENV"
else
echo "NON_STANDALONE=false" >> "$GITHUB_ENV"
fi
- name: Start Camunda
run: |
if [[ "$NON_STANDALONE" == "true" ]]; then
echo "Using single services for older branches (8.6/8.7)"
DATABASE=elasticsearch docker compose up -d operate tasklist
else
echo "Using standalone camunda container"
if [[ "${{ matrix.tasklist_mode }}" == "v1" ]]; then
echo "Starting with Tasklist V1 mode enabled"
CAMUNDA_TASKLIST_V2_MODE_ENABLED=false DATABASE=elasticsearch docker compose up -d camunda
else
echo "Starting with default Tasklist V2 mode"
DATABASE=elasticsearch docker compose up -d camunda
fi
fi
working-directory: fiori-app/webapp/config
- name: List running Docker containers
run: docker ps -a
working-directory: fiori-app/webapp/config
- name: Wait for services to be ready
id: wait-for-services
run: |
echo "Checking if services are up..."
ready=false
for i in {1..90}; do
if [[ "$NON_STANDALONE" == "true" ]]; then
tasklist_status=$(curl -s -m 5 http://localhost:8080 || echo "Failed")
operate_status=$(curl -s -m 5 http://localhost:8081 || echo "Failed")
else
tasklist_status=$(curl -s -m 5 http://localhost:8080/tasklist || echo "Failed")
operate_status=$(curl -s -m 5 http://localhost:8080/operate || echo "Failed")
identity_status=$(curl -s -m 5 http://localhost:8080/identity || echo "Failed")
fi
if [[ "$NON_STANDALONE" == "true" ]]; then
if [[ "$tasklist_status" != "Failed" && "$operate_status" != "Failed" ]]; then
echo "Services are ready!"
ready=true
break
fi
else
if [[ "$tasklist_status" != "Failed" && "$operate_status" != "Failed" && "$identity_status" != "Failed" ]]; then
echo "Services are ready!"
ready=true
break
fi
fi
echo "Waiting for services... ($i/90)"
sleep 10
done
if [ "$ready" = true ]; then
echo "ready=true" >> "$GITHUB_OUTPUT"
else
echo "Services failed to start in time."
exit 1
fi
working-directory: fiori-app/webapp/config
- name: Print Docker logs before failing
if: failure()
run: |
if [[ "$NON_STANDALONE" == "true" ]]; then
docker compose logs tasklist
docker compose logs operate
else
docker compose logs camunda
fi
working-directory: fiori-app/webapp/config
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
# - name: Clean install dependencies
# shell: bash
# run: |
# rm -rf node_modules package-lock.json
# npm install
# working-directory: fiori-app/webapp
#
# - name: Import Secrets
# id: secrets
# uses: hashicorp/vault-action@734c523c4fbdb289cdf26dd2dc177f3627d1e140
# with:
# url: ${{ secrets.VAULT_ADDR }}
# method: approle
# roleId: ${{ secrets.VAULT_ROLE_ID }}
# secretId: ${{ secrets.VAULT_SECRET_ID }}
# exportEnv: false
# secrets: |
# secret/data/github.com/organizations/camunda TESTRAIL_QA_EMAIL;
# secret/data/github.com/organizations/camunda TESTRAIL_QA_PSW;
#
# - name: Install Playwright Browsers
# shell: bash
# run: npx playwright install --with-deps chromium
# working-directory: fiori-app/webapp
#
# - name: Python setup
# uses: actions/setup-python@v5
# with:
# python-version: "3.x"
#
# - name: Run tests
# shell: bash
# env:
# LOCAL_TEST: "false"
# CAMUNDA_AUTH_STRATEGY: "BASIC"
# CAMUNDA_BASIC_AUTH_USERNAME: "demo"
# CAMUNDA_BASIC_AUTH_PASSWORD: "demo"
# CAMUNDA_TASKLIST_V2_MODE_ENABLED: ${{ matrix.tasklist_mode == 'v2' && 'true' || 'false' }}
# run: |
# if [[ "$NON_STANDALONE" == "true" ]]; then
# export CORE_APPLICATION_TASKLIST_URL="http://localhost:8080"
# export CORE_APPLICATION_OPERATE_URL="http://localhost:8081"
# export ZEEBE_REST_ADDRESS="http://localhost:8089"
# TEST_ARGS=(--project=chromium)
# else
# export CORE_APPLICATION_URL="http://localhost:8080"
# export ZEEBE_REST_ADDRESS="http://localhost:8080"
# TEST_ARGS=(--project=chromium)
#
# if [[ "${{ matrix.tasklist_mode }}" == "v2" ]]; then
# echo "Running V2 mode tests"
# fi
# else
# echo "Running V1 mode tests"
# fi
# fi
# fi
# echo "Running tests with args: ${TEST_ARGS[*]}"
# npm run test -- "${TEST_ARGS[@]}"
# working-directory: fiori-app/webapp/test/playwrightE2E
#
# - name: Publish test results to TestRail
# if: always()
# shell: bash
# env:
# TESTRAIL_HOST: "https://camunda.testrail.com/"
# TESTRAIL_USERNAME: ${{ steps.secrets.outputs.TESTRAIL_QA_EMAIL }}
# TESTRAIL_KEY: ${{ steps.secrets.outputs.TESTRAIL_QA_PSW }}
# JUNIT_RESULTS_FILE: "fiori-app/webapp/test/playwrightE2E/test-results/junit-report.xml"
# run: |
# pip install trcli
# trcli -y -h "$TESTRAIL_HOST" \
# --project 'C8' \
# --username "$TESTRAIL_USERNAME" \
# --key "$TESTRAIL_KEY" \
# parse_junit --suite-id 34622 \
# --title "On Demand Fiori App Test Run Results - ${{ github.event.inputs.branch }} (Tasklist ${{ matrix.tasklist_mode }} mode) - $(date '+%Y-%m-%d %H:%M:%S')" \
# --close-run \
# -f "$JUNIT_RESULTS_FILE"
#
# - uses: actions/upload-artifact@v4
# if: failure()
# with:
# name: SAP BTP Plugin Fiori App E2E Test Result (Tasklist ${{ matrix.tasklist_mode }} mode)
# path: fiori-app/webapp/test/playwrightE2E/html-report
# retention-days: 10