Skip to content

Add e2e test workflow form docker image #4707

Add e2e test workflow form docker image

Add e2e test workflow form docker image #4707

Workflow file for this run

name: E2E Tests
on:
pull_request:
branches-ignore:
- 'weblate-**'
workflow_dispatch:
inputs:
distinct_id:
description: 'for the return-dispatch action'
required: false
control-api:
description: 'custom control-api version'
data-api:
description: 'custom data-api version'
us:
description: 'custom us version'
ui:
description: 'custom ui version'
default: 'release'
env:
CONTROL_API_VERSION: ${{github.event.inputs.control-api}}
DATA_API_VERSION: ${{github.event.inputs.data-api}}
US_VERSION: ${{github.event.inputs.us}}
UI_VERSION: ${{github.event.inputs.ui}}
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
run-e2e:
name: Install Datalens and Run E2E Tests
runs-on: ubuntu-22.04
steps:
- name: echo distinct ID ${{ github.event.inputs.distinct_id }}
run: echo ${{ github.event.inputs.distinct_id }}
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
cache-dependency-path: ./package-lock.json
- name: Get last version config
run: |
VERSION_CONFIG=$(curl -s https://api.github.com/repos/datalens-tech/datalens/contents/versions-config.json | jq -r '.content' | base64 -d)
if [ "${{ env.UI_VERSION }}" == "release" ]; then
UI_VERSION=$(echo "${VERSION_CONFIG}" | jq -r '.uiVersion')
echo "UI_VERSION=$UI_VERSION" >> "$GITHUB_ENV"
fi
if [ -z "${{ env.US_VERSION }}" ]; then
US_VERSION=$(echo "${VERSION_CONFIG}" | jq -r '.usVersion')
echo "US_VERSION=$US_VERSION" >> "$GITHUB_ENV"
fi
if [ -z "${{ env.CONTROL_API_VERSION }}" ]; then
CONTROL_API_VERSION=$(echo "${VERSION_CONFIG}" | jq -r '.controlApiVersion')
echo "CONTROL_API_VERSION=$CONTROL_API_VERSION" >> "$GITHUB_ENV"
fi
if [ -z "${{ env.DATA_API_VERSION }}" ]; then
DATA_API_VERSION=$(echo "${VERSION_CONFIG}" | jq -r '.dataApiVersion')
echo "DATA_API_VERSION=$DATA_API_VERSION" >> "$GITHUB_ENV"
fi
env:
US_VERSION: ${{ env.US_VERSION }}
CONTROL_API_VERSION: ${{ env.CONTROL_API_VERSION }}
DATA_API_VERSION: ${{ env.DATA_API_VERSION }}
UI_VERSION: ${{ env.UI_VERSION }}
- name: Check docker compose Config
working-directory: ./tests
run: npm run test:docker:check
env:
US_VERSION: ${{ env.US_VERSION }}
CONTROL_API_VERSION: ${{ env.CONTROL_API_VERSION }}
DATA_API_VERSION: ${{ env.DATA_API_VERSION }}
UI_VERSION: ${{ env.UI_VERSION }}
- name: Build docker ui image with cache
if: ${{ env.UI_VERSION == '' }}
uses: docker/[email protected]
with:
network: host
context: .
push: false
load: true
tags: e2e-datalens-ui:pr
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Up docker compose and install local deps for test
if: ${{ env.UI_VERSION == '' }}
working-directory: ./tests
run: |
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
npm run test:docker:up-no-build && cd .. && npm ci && npm run test:install:chromium & wait
env:
US_VERSION: ${{ env.US_VERSION }}
CONTROL_API_VERSION: ${{ env.CONTROL_API_VERSION }}
DATA_API_VERSION: ${{ env.DATA_API_VERSION }}
- name: Run tests local from repo
if: ${{ env.UI_VERSION == '' }}
run: npm run test:e2e:opensource
env:
NO_AUTH: true
E2E_RETRY_TIMES: 1
E2E_DOMAIN: http://localhost:8080
- name: Run tests from builded docker image
if: ${{ env.UI_VERSION != '' }}
working-directory: ./tests
run: |
npm run test:e2e:docker
env:
US_VERSION: ${{ env.US_VERSION }}
CONTROL_API_VERSION: ${{ env.CONTROL_API_VERSION }}
DATA_API_VERSION: ${{ env.DATA_API_VERSION }}
UI_VERSION: ${{ env.UI_VERSION }}
- name: Copy tests report from docker run
if: always()
working-directory: ./tests
run: |
if [ -z "${{ env.UI_VERSION }}" ]; then
echo "skip export report from docker run..."
else
echo "export report from docker run"
rm -rf ./artifacts
npm run test:e2e:docker:report
fi
env:
US_VERSION: ${{ env.US_VERSION }}
CONTROL_API_VERSION: ${{ env.CONTROL_API_VERSION }}
DATA_API_VERSION: ${{ env.DATA_API_VERSION }}
UI_VERSION: ${{ env.UI_VERSION }}
- name: Run docker compose down
if: always()
working-directory: ./tests
run: |
npm run test:docker:down
env:
US_VERSION: ${{ env.US_VERSION }}
CONTROL_API_VERSION: ${{ env.CONTROL_API_VERSION }}
DATA_API_VERSION: ${{ env.DATA_API_VERSION }}
UI_VERSION: ${{ env.UI_VERSION }}
- name: Save report link and pr number
if: always()
run: |
mkdir -p ./tests/artifacts
echo "reports/${{ github.head_ref || github.ref_name }}/${{ github.run_id }}/${{ github.run_attempt }}" > ./tests/artifacts/report-link
echo "${{ github.event.pull_request.number }}" > ./tests/artifacts/report-pr
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: ./tests/artifacts/
retention-days: 30