From 18cc0901eae60fe3aaff90954f9524b067420988 Mon Sep 17 00:00:00 2001 From: Sadra Yahyapour Date: Tue, 19 Nov 2024 07:46:01 +0330 Subject: [PATCH] brand new testing action --- .github/workflows/testing_action.yml | 2 +- {testing_action => test_action}/.dockerignore | 2 +- test_action/.github/workflows/test.yml | 17 ++++++++++++ test_action/.gitignore | 16 ++++++++++++ test_action/Dockerfile | 26 +++++++++++++++++++ {testing_action => test_action}/README.md | 0 {testing_action => test_action}/action.yml | 0 .../glorious/__init__.py | 0 .../glorious/pattern.py | 0 {testing_action => test_action}/main.py | 6 ++--- test_action/post-script.sh | 0 test_action/pre-script.sh | 2 ++ test_action/pyproject.toml | 7 +++++ testing_action/Dockerfile | 14 ---------- testing_action/requirements.txt | 1 - testing_action/script.sh | 2 -- 16 files changed, 73 insertions(+), 22 deletions(-) rename {testing_action => test_action}/.dockerignore (97%) create mode 100644 test_action/.github/workflows/test.yml create mode 100644 test_action/.gitignore create mode 100644 test_action/Dockerfile rename {testing_action => test_action}/README.md (100%) rename {testing_action => test_action}/action.yml (100%) rename {testing_action => test_action}/glorious/__init__.py (100%) rename {testing_action => test_action}/glorious/pattern.py (100%) rename {testing_action => test_action}/main.py (91%) create mode 100644 test_action/post-script.sh create mode 100644 test_action/pre-script.sh create mode 100644 test_action/pyproject.toml delete mode 100644 testing_action/Dockerfile delete mode 100644 testing_action/requirements.txt delete mode 100644 testing_action/script.sh diff --git a/.github/workflows/testing_action.yml b/.github/workflows/testing_action.yml index 952402d..79cfebe 100644 --- a/.github/workflows/testing_action.yml +++ b/.github/workflows/testing_action.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v4 - name: Using the testing action - uses: ./testing_action + uses: ./test_action id: action with: test_name: TEST NAME diff --git a/testing_action/.dockerignore b/test_action/.dockerignore similarity index 97% rename from testing_action/.dockerignore rename to test_action/.dockerignore index fc209b2..bef9b9e 100644 --- a/testing_action/.dockerignore +++ b/test_action/.dockerignore @@ -21,4 +21,4 @@ CONTRIBUTING.md CHANGELOG.md LICENSE Dockerfile -Makefile \ No newline at end of file +Makefile diff --git a/test_action/.github/workflows/test.yml b/test_action/.github/workflows/test.yml new file mode 100644 index 0000000..08c3adb --- /dev/null +++ b/test_action/.github/workflows/test.yml @@ -0,0 +1,17 @@ +name: Testing + +on: + push: + branches: + - main + +jobs: + Test: + runs-on: ubuntu-latest + name: Testing the action + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Running the action + uses: ./ diff --git a/test_action/.gitignore b/test_action/.gitignore new file mode 100644 index 0000000..6d54f31 --- /dev/null +++ b/test_action/.gitignore @@ -0,0 +1,16 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ diff --git a/test_action/Dockerfile b/test_action/Dockerfile new file mode 100644 index 0000000..9a169aa --- /dev/null +++ b/test_action/Dockerfile @@ -0,0 +1,26 @@ +# setting the base-image +FROM python:3.12-slim + +# Copy only the necessary binaries from uv +COPY --from=ghcr.io/astral-sh/uv:0.5.1 /uv /uvx /bin/ + +# Set environment variable early to take advantage of layer caching +ENV UV_PROJECT_ENVIRONMENT="/usr/local/" + +# Set the working directory to /action +WORKDIR /action + +# importing the action +COPY . . + +# running the pre-script.sh +RUN [ -f /action/pre-script.sh ] && sh /action/pre-script.sh || true + +# Install project dependencies first for better caching +RUN uv sync --frozen --no-cache + +# running the post-script.sh +RUN [ -f /action/post-script.sh ] && sh /action/post-script.sh || true + +# Specify the command to run main.py with uv +CMD [ "uv", "run", "main.py" ] diff --git a/testing_action/README.md b/test_action/README.md similarity index 100% rename from testing_action/README.md rename to test_action/README.md diff --git a/testing_action/action.yml b/test_action/action.yml similarity index 100% rename from testing_action/action.yml rename to test_action/action.yml diff --git a/testing_action/glorious/__init__.py b/test_action/glorious/__init__.py similarity index 100% rename from testing_action/glorious/__init__.py rename to test_action/glorious/__init__.py diff --git a/testing_action/glorious/pattern.py b/test_action/glorious/pattern.py similarity index 100% rename from testing_action/glorious/pattern.py rename to test_action/glorious/pattern.py diff --git a/testing_action/main.py b/test_action/main.py similarity index 91% rename from testing_action/main.py rename to test_action/main.py index 978886d..663a363 100644 --- a/testing_action/main.py +++ b/test_action/main.py @@ -1,13 +1,13 @@ -from glorious.pattern import rainbowfier - from pyaction import PyAction from pyaction.workflow import annotations from pyaction.workflow.stream import WorkflowContext +from .glorious.pattern import rainbowfier + workflow = PyAction() -@workflow.action() +@workflow.action def testing_action(test_name: str, test_age: int) -> None: annotations.warning("This is a warning annotation!") annotations.notice("This is a notice annotation!") diff --git a/test_action/post-script.sh b/test_action/post-script.sh new file mode 100644 index 0000000..e69de29 diff --git a/test_action/pre-script.sh b/test_action/pre-script.sh new file mode 100644 index 0000000..7af6b19 --- /dev/null +++ b/test_action/pre-script.sh @@ -0,0 +1,2 @@ +apt update +apt install -y git diff --git a/test_action/pyproject.toml b/test_action/pyproject.toml new file mode 100644 index 0000000..2ab0d7d --- /dev/null +++ b/test_action/pyproject.toml @@ -0,0 +1,7 @@ +[project] +name = "test-action" +version = "0.0.1" +description = "An action for testing the latest changes of PyAction's main branch" +readme = "README.md" +requires-python = ">=3.12" +dependencies = ["pyaction @ git+https://github.com/lnxpy/pyaction#main"] diff --git a/testing_action/Dockerfile b/testing_action/Dockerfile deleted file mode 100644 index f772b8e..0000000 --- a/testing_action/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -# setting the base-image -FROM python:3.12-slim - -# importing the action -COPY . /action - -# running the script.sh -RUN [ -f /action/script.sh ] && sh /action/script.sh || true - -# installing the requirements -RUN pip install -U pip -r /action/requirements.txt - -# running the main.py file -CMD [ "python", "/action/main.py" ] diff --git a/testing_action/requirements.txt b/testing_action/requirements.txt deleted file mode 100644 index c53f960..0000000 --- a/testing_action/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pyaction @ git+https://github.com/lnxpy/pyaction@main diff --git a/testing_action/script.sh b/testing_action/script.sh deleted file mode 100644 index e08f88b..0000000 --- a/testing_action/script.sh +++ /dev/null @@ -1,2 +0,0 @@ -apt update -apt install -y git \ No newline at end of file