(ci/cd) Introduce playwright #50
Workflow file for this run
This file contains 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: E2E tests | |
on: | |
pull_request: | |
types: | |
- synchronize | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
test: | |
permissions: | |
actions: write | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
- name: Set Node and pnpm versions | |
id: versions | |
working-directory: ./e2e | |
shell: bash | |
run: | | |
NODE_VERSION=$(jq -r '.engines.node' package.json) | |
PNPM_VERSION=$(jq -r '.engines.pnpm' package.json) | |
echo "NODE_VERSION=$NODE_VERSION" >> $GITHUB_OUTPUT | |
echo "PNPM_VERSION=$PNPM_VERSION" >> $GITHUB_OUTPUT | |
- name: Setup node.js | |
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 | |
with: | |
node-version: ${{ steps.versions.outputs.NODE_VERSION }} | |
- name: Setup pnpm | |
uses: pnpm/action-setup@c3b53f6a16e57305370b4ae5a540c2077a1d50dd # v2.2.4 | |
with: | |
version: ${{ steps.versions.outputs.PNPM_VERSION }} | |
run_install: false | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
- name: Setup pnpm cache | |
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1 | |
with: | |
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Check Docker Compose version | |
run: docker-compose --version | |
- name: Set up JDK | |
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3.12.0 | |
with: | |
java-version: 20 | |
distribution: "temurin" | |
cache: maven | |
- name: Build Klaw | |
run: docker-scripts/klaw-docker.sh --dev-ui-tests | |
- name: Check Container Logs | |
run: docker logs klaw-core | |
- name: Log Container Network Address | |
id: container_ip | |
shell: bash | |
run: | | |
container_name="klaw-core" | |
container_info=$(docker inspect -f '{{range $key, $value := .NetworkSettings.Ports}}{{$key}}:{{$value}} {{end}}' "$container_name") | |
container_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container_name") | |
if [ -n "$container_ip" ]; then | |
echo "Container is running at IP address: $container_ip" | |
echo "CONTAINER_IP=$container_ip" >> $GITHUB_OUTPUT | |
echo "CONTAINER_PORT=$container_port" >> $GITHUB_OUTPUT | |
else | |
echo "Container not found or not running" | |
fi | |
- name: Check if Klaw is reachable | |
run: curl "${CONTAINER_IP}:${CONTAINER_PORT}" | |
- name: Install dependencies | |
working-directory: ./e2e | |
run: pnpm install | |
- name: Install Playwright browsers | |
working-directory: ./e2e | |
run: pnpm playwright install --with-deps chromium | |
- name: Run Playwright tests | |
working-directory: ./e2e | |
run: BASE_URL=${{ steps.containerIp.outputs.CONTAINER_IP }}:9097 pnpm test | |
- name: Upload Playwright artifacts | |
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 | |
if: always() | |
with: | |
name: playwright-report | |
path: playwright-report/ | |
retention-days: 5 | |
- name: Teardown Klaw | |
if: always() | |
run: docker-scripts/klaw-docker.sh --destroy |