From 735f09479600511b82c3a529da2a451455c8089a 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 +- .../{{action_slug}}/Dockerfile.jinja | 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 | 2 +- test_action/post-script.sh | 1 + test_action/pre-script.sh | 4 +++ test_action/pyproject.toml | 10 +++++++ testing_action/Dockerfile | 14 ---------- testing_action/requirements.txt | 1 - testing_action/script.sh | 2 -- 17 files changed, 78 insertions(+), 21 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 (97%) 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/pyaction/action_template/{{action_slug}}/Dockerfile.jinja b/pyaction/action_template/{{action_slug}}/Dockerfile.jinja index b8655b6..7a3afb3 100644 --- a/pyaction/action_template/{{action_slug}}/Dockerfile.jinja +++ b/pyaction/action_template/{{action_slug}}/Dockerfile.jinja @@ -17,7 +17,7 @@ COPY . . 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 +RUN uv sync --no-cache # running the post-script.sh RUN [ -f /action/post-script.sh ] && sh /action/post-script.sh || true 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..7a6c84f --- /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 pre-script.sh ] && sh pre-script.sh || true + +# Install project dependencies first for better caching +RUN uv sync + +# running the post-script.sh +RUN [ -f post-script.sh ] && sh 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 97% rename from testing_action/main.py rename to test_action/main.py index 978886d..f0e4ed1 100644 --- a/testing_action/main.py +++ b/test_action/main.py @@ -7,7 +7,7 @@ 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..a83991f --- /dev/null +++ b/test_action/post-script.sh @@ -0,0 +1 @@ +echo "this is a post script running" diff --git a/test_action/pre-script.sh b/test_action/pre-script.sh new file mode 100644 index 0000000..f744884 --- /dev/null +++ b/test_action/pre-script.sh @@ -0,0 +1,4 @@ +echo "this is a pre script running (installing git)" + +apt update +apt install -y git diff --git a/test_action/pyproject.toml b/test_action/pyproject.toml new file mode 100644 index 0000000..18b085a --- /dev/null +++ b/test_action/pyproject.toml @@ -0,0 +1,10 @@ +[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"] + +[project.optional-dependencies] +dev = ["pyaction[cli] @ 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