From 986f7446bfdc6fc38ec5f232c2fc81dda2dfc774 Mon Sep 17 00:00:00 2001 From: Thephaseless Date: Wed, 11 Dec 2024 00:21:07 +0000 Subject: [PATCH] github actions shared lib fix --- Dockerfile | 5 ++++- cmd.sh | 6 +++++- github_actions_fix.sh | 12 ++++++++++++ test.sh | 7 +++++++ 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100755 github_actions_fix.sh create mode 100755 test.sh diff --git a/Dockerfile b/Dockerfile index 29de371..183a2d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,13 +23,16 @@ RUN curl -LsSf https://astral.sh/uv/install.sh | sh COPY pyproject.toml uv.lock ./ RUN uv sync +COPY github_actions_fix.sh ./ +RUN ./github_actions_fix.sh + COPY . . RUN cd .venv/lib/*/site-packages/seleniumbase/drivers && ln -s /usr/bin/chromedriver uc_driver FROM base AS test RUN uv sync --group test -RUN . .venv/bin/activate && pytest --retries 2 -n auto --xvfb +RUN ./test.sh FROM base diff --git a/cmd.sh b/cmd.sh index 2a04dec..055348e 100755 --- a/cmd.sh +++ b/cmd.sh @@ -1,3 +1,7 @@ #!/bin/sh -. .venv/bin/activate && python3 main.py \ No newline at end of file +if [ -f ld_fix.sh ]; then + . ./ld_fix.sh +fi + +uv run main.py \ No newline at end of file diff --git a/github_actions_fix.sh b/github_actions_fix.sh new file mode 100755 index 0000000..572b06a --- /dev/null +++ b/github_actions_fix.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# Source .venv +. .venv/bin/activate + +# Fix for actions LD_LIBRARY_PATH env +touch ld_fix.sh +PYTHON_PATH=$(which python3) +PYTHON_DIR=$(dirname $PYTHON_PATH) +echo "export LD_LIBRARY_PATH=$PYTHON_DIR/../lib" >> ld_fix.sh +echo "export PATH=$PYTHON_DIR:\$PATH" >> ld_fix.sh +chmod +x ld_fix.sh \ No newline at end of file diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..6bffd2c --- /dev/null +++ b/test.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +if [ -f ./ld_fix.sh ]; then + . ./ld_fix.sh +fi + +uv run pytest --retries 2 -n auto --xvfb \ No newline at end of file