From e75e7ecb25af045bca29513102af733db5648765 Mon Sep 17 00:00:00 2001 From: soustruh Date: Mon, 14 Jul 2025 18:14:20 +0200 Subject: [PATCH 1/2] =?UTF-8?q?run=20integration=20tests=20in=20pipeline?= =?UTF-8?q?=20=F0=9F=AA=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/push.yml | 45 +++++++++++++++++++++++++++++++++++--- docker-compose.yml | 12 +++++----- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 1f195b7..014985f 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -110,7 +110,7 @@ jobs: path: /tmp/${{ env.KBC_DEVELOPERPORTAL_APP }}.tar tests: - name: Run Tests + name: Run Unit Tests runs-on: ubuntu-latest needs: - push_event_info @@ -125,14 +125,52 @@ jobs: name: ${{ env.KBC_DEVELOPERPORTAL_APP }} path: /tmp - - name: Load Image & Run Tests + - name: Load Image & Run Unit Tests run: | docker load --input /tmp/${{ env.KBC_DEVELOPERPORTAL_APP }}.tar docker image ls -a docker run ${{ env.KBC_DEVELOPERPORTAL_APP }}:latest uv run --active flake8 . --config=flake8.cfg - echo "Running unit-tests..." + echo "Running unit tests..." docker run ${{ env.KBC_DEVELOPERPORTAL_APP }}:latest uv run --active python -m unittest discover + tests-integration: + name: Run Integration Tests + runs-on: ubuntu-latest + needs: + - push_event_info + - build + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: ${{ env.KBC_DEVELOPERPORTAL_APP }} + path: /tmp + + - name: Load Image & Run Integration Tests + run: | + echo "Running integration tests..." + docker load --input /tmp/${{ env.KBC_DEVELOPERPORTAL_APP }}.tar + docker image ls -a + + cd ${{ github.workspace }} + mkdir data + chmod 777 data + + for i in {1..8}; do + FILENAME=$(ls tests/config-${i}*.json) + echo "Running integration test with ${FILENAME}..." + + cp "${FILENAME}" data/config.json + chmod 666 data/config.json + docker run -v ./data:/data -u 1000:1000 --rm ${{ env.KBC_DEVELOPERPORTAL_APP }}:latest + done + tests-kbc: name: Run KBC Tests needs: @@ -160,6 +198,7 @@ jobs: needs: - push_event_info - tests + - tests-integration - tests-kbc env: DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/docker-compose.yml b/docker-compose.yml index 7c74e25..2e9ebb8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,18 +3,18 @@ services: dev: build: . volumes: - - ./:/code - - ./data:/data + - ./data:/data environment: - KBC_DATADIR=/data + + # use to run flake8 and unittests checks test: - # Use to run flake8 and unittests checks build: . + user: 1000:1000 volumes: - - ./:/code - ./data:/data environment: - - KBC_DATADIR=./data + - KBC_DATADIR=/data command: - /bin/sh - - /code/scripts/build_n_test.sh \ No newline at end of file + - /code/scripts/build_n_test.sh From 4ea1f8ee476c11b7c757c4ca9c7353f01911dae2 Mon Sep 17 00:00:00 2001 From: soustruh Date: Tue, 15 Jul 2025 02:21:43 +0200 Subject: [PATCH 2/2] =?UTF-8?q?brief=20description=20of=20the=20venv=20par?= =?UTF-8?q?ameter=20+=20updated=20examples=20=F0=9F=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 857e2ba..a533c6a 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,9 @@ This component lets you run your own Python code directly within Keboola, with s - `code`: Custom code entered in a text field (default). - `git`: Custom repository. - `user_properties`: Object containing custom configuration parameters. The key names prefixed with `#` will be encrypted upon saving. +- `venv`: String with one of the following values: + - `3.12`, `3.13` (default), `3.14` – Run your code in an isolated environment containing just the packages of your choice and the respective Python version. + - `base` – Run your code in a shared environment (contains many pre-installed packages in legacy versions) - `git`: Object containing configuration of the git repository, which shall be cloned and run (`"source": "git"` only). - `code`: JSON encoded Python code to run (`"source": "code"` only). - `packages`: Array of extra packages to be installed (`"source": "code"` only). *If you're not sure whether you need to install certain package or not, you can run the command `uv pip list` via subprocess (see the example below).* @@ -58,6 +61,7 @@ Contents of the `config.json` file: { "parameters": { "source": "git", + "venv": "3.13", "git": { "url": "https://github.com/keboola/component-custom-python-example-repo-1.git", "branch": "main", @@ -91,6 +95,8 @@ The above code in the `config.json` file format for local testing: ```json { "parameters": { + "source": "code", + "venv": "base", "code": "import datetime\nimport subprocess\n\nprint(\"Hello world!\")\nprint(\"Current date and time:\", datetime.datetime.now())\nprint(\"See the full list of preinstalled packages:\")\n\nsubprocess.check_call([\"uv\", \"pip\", \"list\"])\n", "packages": [] } @@ -115,6 +121,8 @@ The above code in the `config.json` file format for local testing: ```json { "parameters": { + "source": "code", + "venv": "3.13", "code": "from keboola.component import CommonInterface\n\nci = CommonInterface()\n# access user parameters\nprint(ci.configuration.parameters)", "packages": [], "user_properties": {