Skip to content

migrate all end-to-end highlight example apps #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{js,json,yml}]
charset = utf-8
indent_style = space
indent_size = 2
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.yarn/** linguist-vendored
/.yarn/releases/* binary
/.yarn/plugins/**/* binary
/.pnp.* binary linguist-generated
315 changes: 315 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,315 @@
name: End to End Example Apps

on:
push:
branches: ['main']
pull_request:
types: [opened, synchronize]

concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
e2e-cypress:
name: E2E Client Cypress
timeout-minutes: 60
runs-on: buildjet-8vcpu-ubuntu-2204

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Node.js environment
uses: buildjet/setup-node@v4
with:
node-version: lts/*
cache: 'yarn'

- name: Setup Golang environment
uses: buildjet/setup-go@v5
with:
go-version-file: 'backend/go.mod'
cache-dependency-path: '**/go.sum'

- name: Install poetry
run: pipx install poetry

- name: Install python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'poetry'

- name: Install Doppler CLI
uses: dopplerhq/cli-action@v3

- name: Install dependencies
working-directory: ./e2e/tests
run: poetry install --all-extras

- name: Install ffmpeg
run: |
curl -o ffmpeg.tar.xz https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz
mkdir ~/bin
tar -C ~/bin --strip-components=1 -xf ffmpeg.tar.xz
ls ~/bin

- name: Login to Docker Hub
if: github.event.pull_request.head.repo.full_name == 'highlight/highlight' || github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Start docker containers & run cypress
env:
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
REF: ${{ github.ref }}
REPO: ${{ github.event.pull_request.head.repo.full_name }}
run: |
export RUN_SESSION_SCREENSHOT_LAMBDA=false
if [[ "$REF" != "refs/heads/main" && "$REPO" == "highlight/highlight" ]]; then
export REACT_APP_COMMIT_SHA="${COMMIT_SHA}"
export RUN_SESSION_SCREENSHOT_LAMBDA=true
fi

# start highlight
pushd docker;
source ./env.sh;
./start-infra.sh > /tmp/highlight.log 2>&1;
docker compose exec -e PSQL_HOST -e PSQL_USER -e PSQL_DB postgres bash -c 'psql -h $PSQL_HOST -U $PSQL_USER $PSQL_DB < /root/init.sql' >> /tmp/highlight.log 2>&1;
./run-backend.sh >> /tmp/highlight.log 2>&1 &
yarn install >> /tmp/highlight.log 2>&1;
unset REACT_APP_IN_DOCKER;
yarn build:frontend >> /tmp/highlight.log 2>&1;
yarn workspace @highlight-run/apollo build >> /tmp/highlight.log 2>&1;
yarn workspace @highlight-run/client dev &
yarn workspace highlight.run dev &
yarn workspace @highlight-run/frontend vite preview --port 3000 &
popd;

# run opentelemetry file watcher
pushd e2e/opentelemetry/filelog;
EXAMPLE_LOG_FILE_PATH=/tmp/highlight.log docker compose run -d file-collector;
popd;

# wait for highlight to be ready
yarn dlx wait-on -l -s 3 http://127.0.0.1:3000/index.html http://127.0.0.1:8082/health;

# run cypress tests
yarn cy:run;

# run python functional tests that ensure cypress session is correct
pushd ./e2e/tests
export HIGHLIGHT_OAUTH_CLIENT_ID=abc123
export HIGHLIGHT_OAUTH_CLIENT_SECRET=def456
poetry run pytest -k cypress .
popd

# look for containers that crashed
num_crashed=$(docker ps -a -f status=exited | grep -E '\(' | grep -cvE '\(\d+\)' || true)
if [ "$num_crashed" -gt 0 ]; then
echo "$num_crashed containers crashed"
docker ps -a -f status=exited
exit 1
fi

- name: Dump setup logs on failure
if: failure()
run: cat /tmp/highlight.log

- name: Dump docker container logs on failure
if: failure()
run: |
pushd docker;
docker compose logs;
popd;

pushd e2e/opentelemetry/filelog;
docker compose logs;
popd;

- name: Dump databases on failure
if: failure()
run: |
cd docker;
mkdir backups

docker compose exec postgres bash -c "mkdir /backups";
docker compose exec postgres bash -c "pg_dump -h localhost -U postgres -d postgres > /backups/postgres.sql";
docker compose exec postgres bash -c "psql -h localhost -U postgres -d postgres -c 'select * from sessions;' > /backups/sessions.sql";
docker compose exec postgres bash -c "cat /backups/postgres.sql" > ./backups/postgres.sql 2>&1;
docker compose exec postgres bash -c "cat /backups/sessions.sql" > ./backups/sessions.sql 2>&1;

docker compose exec clickhouse bash -c "mkdir /backups && chmod -R 777 /backups";
docker compose exec clickhouse clickhouse-client --host clickhouse --query "BACKUP DATABASE default TO File('/backups/clickhouse.zip')";
docker compose exec clickhouse bash -c "cat /backups/clickhouse.zip" > ./backups/clickhouse.zip 2>&1;

- name: Save database artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: db-dump
path: docker/backups/*

- name: Save videos
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-videos
path: cypress/videos

e2e-frontend-backend:
name: E2E Frontend / Backend
timeout-minutes: 60
runs-on: buildjet-4vcpu-ubuntu-2204

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup Node.js environment
uses: buildjet/setup-node@v4
with:
node-version: lts/*
cache: 'yarn'

- name: Setup Golang environment
uses: buildjet/setup-go@v5
with:
go-version-file: 'backend/go.mod'
cache-dependency-path: '**/go.sum'

- name: Setup .NET environment
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x

- name: Install poetry
run: pipx install poetry

- name: Install python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'poetry'

- name: Install Doppler CLI
uses: dopplerhq/cli-action@v3

- name: Install dependencies
working-directory: ./e2e/tests
run: poetry install --all-extras

- name: Login to Docker Hub
if: github.event.pull_request.head.repo.full_name == 'highlight/highlight' || github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Start docker containers & run sdk e2e test
run: |
# start highlight
pushd docker;
source ./env.sh;
./start-infra.sh > /tmp/highlight.log 2>&1;
docker compose exec -e PSQL_HOST -e PSQL_USER -e PSQL_DB postgres bash -c 'psql -h $PSQL_HOST -U $PSQL_USER $PSQL_DB < /root/init.sql' >> /tmp/highlight.log 2>&1;
./run-backend.sh >> /tmp/highlight.log 2>&1 &
yarn install >> /tmp/highlight.log 2>&1;
yarn build:sdk >> /tmp/highlight.log 2>&1;
popd;

# run python backend functional tests
pushd ./e2e/tests
export HIGHLIGHT_OAUTH_CLIENT_ID=abc123
export HIGHLIGHT_OAUTH_CLIENT_SECRET=def456
poetry run pytest -k "not cypress" .
popd

# look for containers that crashed
num_crashed=$(docker ps -a -f status=exited | grep -E '\(' | grep -cvE '\(\d+\)' || true)
if [ "$num_crashed" -gt 0 ]; then
echo "$num_crashed containers crashed"
docker ps -a -f status=exited
exit 1
fi

- name: Dump setup logs on failure
if: failure()
run: cat /tmp/highlight.log

- name: Dump docker container logs on failure
if: failure()
run: |
cd docker;
docker compose -f compose.yml -f compose.hobby.yml logs;

- name: Dump databases on failure
if: failure()
run: |
cd docker;
mkdir backups

docker compose exec postgres bash -c "mkdir /backups";
docker compose exec postgres bash -c "pg_dump -h localhost -U postgres postgres > /backups/postgres.sql";
docker compose exec postgres bash -c "cat /backups/postgres.sql" > ./backups/postgres.sql 2>&1;

docker compose exec clickhouse bash -c "mkdir /backups && chmod -R 777 /backups";
docker compose exec clickhouse clickhouse-client --host clickhouse --query "BACKUP DATABASE default TO File('/backups/clickhouse.zip')";
docker compose exec clickhouse bash -c "cat /backups/clickhouse.zip" > ./backups/clickhouse.zip 2>&1;

- name: Save database artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: db-dump
path: docker/backups/*

e2e-docker:
name: E2E Dockerized Apps
timeout-minutes: 60
runs-on: buildjet-4vcpu-ubuntu-2204
strategy:
matrix:
app: ['dotnet', 'dotnet4', 'go', 'python', 'ruby']

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install poetry
run: pipx install poetry

- name: Install python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'poetry'

- name: Install dependencies
working-directory: ./e2e/tests
run: poetry install --all-extras

- name: Login to Docker Hub
if: github.event.pull_request.head.repo.full_name == 'highlight/highlight' || github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Docker
if: github.event.pull_request.head.repo.full_name == 'highlight/highlight' || github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: Vadman97
password: ${{ secrets.GH_DOCKER_TOKEN }}

- name: Start docker containers & run sdk e2e test
working-directory: ./e2e/tests/src
run: poetry run python app_runner.py ${{ matrix.app }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,7 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# python
__pycache__

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "highlight"]
path = highlight
url = https://github.com/highlight/highlight.git
Loading
Loading