-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: port conflict for chromium browser session
- Loading branch information
1 parent
3f48baf
commit 03d1f9b
Showing
138 changed files
with
80 additions
and
7,361 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,62 @@ | ||
VERSION 0.7 | ||
|
||
# Define a base target for dependencies | ||
deps: | ||
FROM mcr.microsoft.com/playwright:v1.41.0-jammy | ||
WORKDIR /wallet-automation | ||
|
||
RUN apt-get update && apt-get -y install libnss3 libatk-bridge2.0-0 libdrm-dev libxkbcommon-dev libgbm-dev libasound-dev libatspi2.0-0 libxshmfence-dev | ||
RUN apt-get install -y postgresql-client | ||
RUN apt-get update && apt-get install -y xvfb | ||
# Consolidate RUN commands to reduce layers and ensure cleaner installation | ||
RUN apt-get update && apt-get install -y \ | ||
libnss3 libatk-bridge2.0-0 libdrm-dev libxkbcommon-dev libgbm-dev libasound-dev libatspi2.0-0 libxshmfence-dev postgresql-client xvfb python3.11 python3-pip && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
#Java is needed for allure | ||
# Uncomment and adjust Java installation if needed | ||
# RUN apt-get update && \ | ||
# apt-get install -y openjdk-8-jdk && \ | ||
# apt-get install -y ant && \ | ||
# apt-get install -y openjdk-8-jdk ant && \ | ||
# apt-get clean && \ | ||
# rm -rf /var/lib/apt/lists/ && \ | ||
# rm -rf /var/cache/oracle-jdk8-installer; | ||
# rm -rf /var/lib/apt/lists/* /var/cache/oracle-jdk8-installer; | ||
# ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/ | ||
|
||
COPY package.json . | ||
COPY package-lock.json . | ||
|
||
RUN npm install | ||
ENV PATH /app/node_modules/.bin:$PATH | ||
ENV PATH "/wallet-automation/node_modules/.bin:$PATH" | ||
|
||
# Define a source target that builds upon deps | ||
src: | ||
FROM +deps | ||
|
||
COPY playwright.config.ts . | ||
|
||
# Define a docker target that builds upon src | ||
docker: | ||
FROM +src | ||
ARG tag="latest" | ||
|
||
# ENV EVENT_DB_URL postgres://postgres:postgres@postgres/CatalystEventDev | ||
# ENV MODERATION_FRONTEND_URL http://frontend:80/ | ||
# ENV VITE_API_URL http://backend:8000/api | ||
# Uncomment and adjust environment variables as necessary | ||
# ENV EVENT_DB_URL "postgres://postgres:postgres@postgres/CatalystEventDev" | ||
# ENV MODERATION_FRONTEND_URL "http://frontend:80/" | ||
# ENV VITE_API_URL "http://backend:8000/api" | ||
|
||
SAVE IMAGE voices-tests:$tag | ||
|
||
# Define a test target that builds upon deps | ||
test: | ||
FROM +deps | ||
COPY . . | ||
RUN xvfb-run npx playwright test | ||
RUN xvfb-run npx playwright test typhon-wallet-download.spec.ts | ||
RUN sleep 2 | ||
RUN python3 convert-to-zip.py | ||
RUN sleep 2 | ||
RUN xvfb-run -a npx playwright test typhon-wallet-registration.spec.ts | ||
|
||
# test-local-setup: | ||
# BUILD ../backend+publish | ||
# BUILD github.com/input-output-hk/catalyst-core/containers/event-db-migrations+publish --data='' --tag='latest' | ||
# BUILD ../moderation-tool-frontend+publish | ||
# BUILD +docker | ||
# Uncomment and adjust local setup and e2e-test targets as necessary | ||
|
||
# Define a target for docker-compose configuration | ||
docker-compose: | ||
FROM scratch | ||
|
||
COPY docker-compose.yml . | ||
SAVE ARTIFACT docker-compose.yml | ||
|
||
# e2e-test: | ||
# FROM earthly/dind:alpine | ||
|
||
# COPY +docker-compose/docker-compose.yml . | ||
# WITH DOCKER --compose docker-compose.yml \ | ||
# --pull postgres:14 \ | ||
# --load migrations:latest=(github.com/input-output-hk/catalyst-core/containers/event-db-migrations+publish --data='' --tag='latest') \ | ||
# --load voices-backend:latest=(../backend+publish) \ | ||
# --load moderation-tool-frontend:latest=(../moderation-tool-frontend+publish) \ | ||
# --load test:latest=(+docker) \ | ||
# --service postgres \ | ||
# --service migrations \ | ||
# --service backend \ | ||
# --service frontend | ||
# RUN docker run --network=default_default test:latest npm test | ||
# END |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,62 @@ | ||
import os | ||
import sys | ||
import zipfile | ||
from glob import glob | ||
from datetime import datetime | ||
|
||
# Function to find the most recent .crx file in a given directory | ||
def find_most_recent_crx(directory): | ||
crx_files = glob(os.path.join(directory, '*.crx')) | ||
if not crx_files: | ||
return None | ||
latest_file = max(crx_files, key=os.path.getmtime) | ||
return latest_file | ||
|
||
# Get the directory of the current script (__dirname equivalent) | ||
script_dir = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
# Resolve the 'extensions' path relative to the script's directory | ||
extensions_dir = os.path.join(script_dir, 'typhon/extensions') | ||
|
||
def crx_to_zip(crx_file_path, zip_file_path=None): | ||
if not zip_file_path: | ||
# If no zip file path is provided, use the same location and name as the crx file | ||
zip_file_path = os.path.splitext(crx_file_path)[0] + '.zip' | ||
# If no zip file path is provided, use the 'extensions' directory | ||
base_name = os.path.basename(os.path.splitext(crx_file_path)[0]) | ||
zip_file_path = os.path.join(extensions_dir, base_name + '.zip') | ||
|
||
with open(crx_file_path, 'rb') as crx_file: | ||
# Read the CRX file's header (first 16 bytes) | ||
crx_header = crx_file.read(16) | ||
|
||
# The actual zip content starts after the header, so we can skip the header | ||
# Skip the CRX file's header (first 16 bytes) | ||
crx_file.read(16) | ||
# The actual zip content starts after the header | ||
zip_content = crx_file.read() | ||
|
||
# Save the zip content to a new zip file | ||
with open(zip_file_path, 'wb') as zip_file: | ||
zip_file.write(zip_content) | ||
|
||
print(f"converted CRX to ZIP: {zip_file_path}") | ||
print(f"Converted CRX to ZIP: {zip_file_path}") | ||
return zip_file_path | ||
|
||
def unzip_file(zip_path, extract_to=None): | ||
if extract_to is None: | ||
extract_to = os.path.dirname(zip_path) | ||
|
||
extract_to = extensions_dir | ||
if not os.path.exists(extract_to): | ||
os.makedirs(extract_to) | ||
|
||
with zipfile.ZipFile(zip_path, 'r') as zip_ref: | ||
zip_ref.extractall(extract_to) | ||
print(f"Extracted all files in {zip_path} to {extract_to}") | ||
|
||
# Combine the operations | ||
if __name__ == "__main__": | ||
if len(sys.argv) != 2: | ||
print("Usage: python script.py <path_to_crx_file>") | ||
download_dir = extensions_dir # Or any other directory where .crx files are downloaded | ||
|
||
# Ensure the 'extensions' directory exists | ||
if not os.path.exists(download_dir): | ||
os.makedirs(download_dir) | ||
|
||
crx_path = find_most_recent_crx(download_dir) | ||
if crx_path is None: | ||
print(f"No .crx files found in {download_dir}.") | ||
sys.exit(1) | ||
|
||
crx_path = sys.argv[1] | ||
zip_path = crx_to_zip(crx_path) # Convert CRX to ZIP | ||
unzip_file(zip_path) # Unzip the converted file |
Oops, something went wrong.