Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/python sync actions #181

Merged
merged 78 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
96eb51d
Add first version of sync action component, update git ignore to Pyth…
davidesner May 6, 2024
0b11406
support globs in curl, empty config for test, tests
davidesner May 7, 2024
c77262f
Install Python and Node
AdamVyborny May 7, 2024
25d63f1
Require symfony/console
AdamVyborny May 7, 2024
8cdccf1
Run python component if sync action
AdamVyborny May 7, 2024
ed96cb6
Test for sync action
AdamVyborny May 7, 2024
d237175
Run python tests in CI
AdamVyborny May 7, 2024
f2349fd
Remove copy of non-existing files from python Dockerfile
AdamVyborny May 7, 2024
5a013ae
Add pip and install requirements
AdamVyborny May 7, 2024
dcfbf76
remove testdox flag from phpunit
AdamVyborny May 7, 2024
57ca6ff
Docker caching in CI
AdamVyborny May 7, 2024
7bce80d
Add run-number to test tag
davidesner May 9, 2024
bfe9803
install curlconverter npm package
davidesner May 9, 2024
40b8bb4
New version of test request actions from bb
davidesner May 10, 2024
9fdd157
change symfony/process to exec
AdamVyborny May 10, 2024
5e688be
Fix python Docker image
davidesner May 10, 2024
2ae24fb
Revert change and pass outputs and return codes
AdamVyborny May 10, 2024
3c80556
method for call
kudj May 10, 2024
e08adab
Remove dockerfile caching
AdamVyborny May 10, 2024
ea5df4e
Display output when assert fails
AdamVyborny May 10, 2024
6c23189
remove tty
AdamVyborny May 10, 2024
274cc28
FIX curl dataType, bring back runid in test tag
davidesner May 10, 2024
974af7e
remove pychache from staging
davidesner May 10, 2024
4f7447f
Merge remote-tracking branch 'origin/feature/python-sync-actions-resp…
davidesner May 10, 2024
124f0db
remove data
davidesner May 10, 2024
4ea8d1c
minor refactor test-Request, infer mapping prep
davidesner May 10, 2024
41ab043
Return dataField as object (curl)
davidesner May 11, 2024
66d4227
requests in list
kudj May 10, 2024
2a5da07
change of make_call to accept list of call configs
kudj May 10, 2024
132faf4
flake
kudj May 11, 2024
ab0a5b0
Minor fixes of test_request, infer_mapping
davidesner May 11, 2024
7397113
Limit child calls to prevent sync timeout
davidesner May 11, 2024
bd6fd42
Job path may be empty for some actions, remove validation
davidesner May 12, 2024
a7d21ef
auth
kudj May 13, 2024
b0283f2
flake
kudj May 13, 2024
99905dd
removing ui params in config
kudj May 14, 2024
442b7d8
Update mapping infer to accept paratemeters, handle duplicates and in…
davidesner May 14, 2024
45997cc
FEATURE perform_function action
davidesner May 14, 2024
8e62fa8
Function as object
davidesner May 14, 2024
cc52079
Fix tests
davidesner May 14, 2024
607b924
codestyle
davidesner May 15, 2024
ac4ee3c
Use PHP functions for absolute backward compatibility
davidesner May 15, 2024
66691e9
Support time placeholders in fucntions
davidesner May 15, 2024
22180fd
CURL command parameter name
davidesner May 15, 2024
7870057
Support userdata
davidesner May 15, 2024
dc28d3c
Fix php curl test
davidesner May 15, 2024
c3e37da
search key only in specified level
kudj May 15, 2024
a465d90
fix request
kudj May 15, 2024
dcd3f7f
FIX time reference in user params
davidesner May 16, 2024
360c006
Merge branch 'feature/python-sync-actions-requests-list' of github.co…
davidesner May 16, 2024
7833e61
Kepp curly brackets in the url on CURL parse to enable placeholder de…
davidesner May 16, 2024
9c23d76
handle parent keys in infer mapping
davidesner May 16, 2024
d06d5e2
Fix parent index
davidesner May 16, 2024
17477cd
logging
kudj May 16, 2024
d8ea852
Temp fix hide header token
davidesner May 16, 2024
b9d7cbf
more universal secret replace
davidesner May 16, 2024
5a0156b
filtering log and response
kudj May 16, 2024
605fcde
config helpers
kudj May 17, 2024
b994a24
funcs
kudj May 17, 2024
08fd7f2
codestyle
davidesner May 20, 2024
e901a1f
codestyle
davidesner May 20, 2024
ffb4dc1
Merge branch 'feature/python-sync-actions-config-helpers' into featur…
davidesner May 20, 2024
73261ba
Return Docker caching in actions
davidesner May 20, 2024
cb6a1e0
Add sync action
davidesner May 20, 2024
7dda285
test calls to mock server
kudj May 20, 2024
eca1716
Login method fix, tests
davidesner May 20, 2024
9bb35ba
Fix perform function
davidesner May 21, 2024
0b58c16
Add ifemtpy function
davidesner May 21, 2024
c5c784f
Function tests
davidesner May 21, 2024
20fc680
Run python tests against php image
davidesner May 21, 2024
baa9981
Add oauth cc method
davidesner May 21, 2024
3af233f
FIX oauth2 cc authorization, tests
davidesner May 21, 2024
65d493a
Return failed response and request
davidesner May 21, 2024
4fe29d3
Run Python functional tests against mock server
davidesner May 21, 2024
c723405
Validate respojnse path
davidesner May 27, 2024
8bfc3fd
Chage position of headers in the test output
davidesner May 28, 2024
91b9d23
Update secret filtering logic, tests
davidesner May 28, 2024
78abe40
Fix basic auth secrets filter
davidesner May 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 67 additions & 37 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,42 @@ jobs:
app_image_tag: ${{ steps.tag.outputs.app_image_tag }}
is_semantic_tag: ${{ steps.tag.outputs.is_semantic_tag }}
steps:
-
name: Check out the repo
uses: actions/checkout@v2
-
name: Print Docker version
- name: Check out the repo
uses: actions/checkout@v4

- name: Print Docker version
run: docker -v
-
name: Docker login
- name: Docker login
if: env.DOCKERHUB_TOKEN
run: docker login --username "$DOCKERHUB_USER" --password "$DOCKERHUB_TOKEN"
-
name: Build image
run: docker build -t $APP_IMAGE .
-
name: Set image tag
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: docker-${{ hashFiles('Dockerfile') }}-${{ github.sha }}
restore-keys: |
docker-${{ hashFiles('Dockerfile') }}
- name: Build and push Docker image with cache
run: |
docker buildx build \
--cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache \
--output=type=docker \
--tag $APP_IMAGE .
- name: Set image tag
id: tag
run: |
TAG="${GITHUB_REF##*/}"
IS_SEMANTIC_TAG=$(echo "$TAG" | grep -q '^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$' && echo true || echo false)
if [ "$IS_SEMANTIC_TAG" = "false" ]; then
TAG="${TAG}-${GITHUB_RUN_NUMBER}"
fi
echo "Tag = '$TAG', is semantic tag = '$IS_SEMANTIC_TAG'"
echo "::set-output name=app_image_tag::$TAG"
echo "::set-output name=is_semantic_tag::$IS_SEMANTIC_TAG"
-
name: Push image to ECR
- name: Push image to ECR
uses: keboola/action-push-to-ecr@master
with:
vendor: ${{ env.KBC_DEVELOPERPORTAL_VENDOR }}
Expand All @@ -58,17 +70,32 @@ jobs:
password: ${{ env.KBC_DEVELOPERPORTAL_PASSWORD }}
tag: ${{ steps.tag.outputs.app_image_tag }}
push_latest: ${{ steps.tag.outputs.is_semantic_tag }}
source_image: ${{ env.APP_IMAGE}}
source_image: ${{ env.APP_IMAGE }}

python-lint:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Build image
working-directory: ./python-sync-actions
run: docker compose build

- name: Run python lint
working-directory: ./python-sync-actions
run: docker compose run dev flake8 . --config=flake8.cfg


tests:
needs: build
needs:
- build
- python-lint
runs-on: ubuntu-latest
steps:
-
name: Check out the repo
uses: actions/checkout@v2
-
name: Pull image from ECR
- name: Check out the repo
uses: actions/checkout@v4
- name: Pull image from ECR
uses: keboola/action-pull-from-ecr@master
with:
vendor: ${{ env.KBC_DEVELOPERPORTAL_VENDOR }}
Expand All @@ -78,19 +105,23 @@ jobs:
tag: ${{ needs.build.outputs.app_image_tag }}
target_image: ${{ env.APP_IMAGE}}
tag_as_latest: true
-
name: Tests
- name: Python Tests
run: docker-compose run --rm ci python -m unittest discover /code/python-sync-actions
- name: Run Python Functional Tests
working-directory: ./python-sync-actions
run: docker compose run test-calls
- name: PHP Tests
run: docker-compose run --rm -v $(pwd)/build:/code/build ci

tests-examples:
needs: build
needs:
- build
- python-lint
runs-on: ubuntu-latest
steps:
-
name: Check out the repo
uses: actions/checkout@v2
-
name: Pull image from ECR
- name: Check out the repo
uses: actions/checkout@v4
- name: Pull image from ECR
uses: keboola/action-pull-from-ecr@master
with:
vendor: ${{ env.KBC_DEVELOPERPORTAL_VENDOR }}
Expand All @@ -100,19 +131,20 @@ jobs:
tag: ${{ needs.build.outputs.app_image_tag }}
target_image: ${{ env.APP_IMAGE}}
tag_as_latest: true
-
name: Test examples
- name: Test examples
run: |
cd doc
./run-samples.sh



tests-in-kbc:
needs: build
needs:
- build
- python-lint
runs-on: ubuntu-latest
steps:
-
name: Run KBC test jobs
- name: Run KBC test jobs
if: env.KBC_STORAGE_TOKEN && env.KBC_TEST_PROJECT_CONFIGS
uses: keboola/action-run-configs-parallel@master
with:
Expand All @@ -130,13 +162,11 @@ jobs:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') && needs.build.outputs.is_semantic_tag == 'true'
steps:
-
name: Set tag in the Deloper Portal
- name: Set tag in the Developer Portal
uses: keboola/action-set-tag-developer-portal@master
with:
vendor: ${{ env.KBC_DEVELOPERPORTAL_VENDOR }}
app_id: ${{ env.KBC_DEVELOPERPORTAL_APP }}
username: ${{ env.KBC_DEVELOPERPORTAL_USERNAME }}
password: ${{ env.KBC_DEVELOPERPORTAL_PASSWORD }}
tag: ${{ needs.build.outputs.app_image_tag }}

8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
vendor/
/data/
/python-sync-actions/data/
.idea/
.tmp
.phpunit.result.cache
Expand All @@ -8,3 +8,9 @@ vendor/
/doc/examples/*/out/tables/*
/build/logs
/tests/phpunit/data/*/out
/data/
# Python specific
/venv
/python-sync-actions/src/test.py
/python-sync-actions/data
__pycache__
95 changes: 95 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,114 @@ WORKDIR /code/

COPY docker/php.ini /usr/local/etc/php/php.ini
COPY docker/composer-install.sh /tmp/composer-install.sh
COPY python-sync-actions/requirements.txt /tmp/requirements.txt


RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
git \
locales \
unzip \
ssh \
netcat \
wget \
build-essential \
libbluetooth-dev \
libssl-dev \
zlib1g-dev \
libncurses5-dev \
libncursesw5-dev \
libreadline-dev \
libsqlite3-dev \
libffi-dev \
uuid-dev \
tk-dev \
liblzma-dev \
gnupg \
&& rm -r /var/lib/apt/lists/* \
&& sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen \
&& locale-gen \
&& chmod +x /tmp/composer-install.sh \
&& /tmp/composer-install.sh

# Set environment variables for Python installation
ENV GPG_KEY 7169605F62C751356D054A26A821E680E5FA6305
ENV PYTHON_VERSION 3.12.3

# Download, verify, and install Python from source
RUN set -eux; \
wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz"; \
wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc"; \
GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$GPG_KEY"; \
gpg --batch --verify python.tar.xz.asc python.tar.xz; \
gpgconf --kill all; \
rm -rf "$GNUPGHOME" python.tar.xz.asc; \
mkdir -p /usr/src/python; \
tar -xvf python.tar.xz --strip-components=1 -C /usr/src/python; \
rm python.tar.xz; \
\
cd /usr/src/python; \
./configure \
--enable-optimizations \
--enable-option-checking=fatal \
--with-system-expat \
--with-lto \
--enable-loadable-sqlite-extensions; \
make -j "$(nproc)"; \
make install; \
\
cd /; \
rm -rf /usr/src/python; \
ldconfig

# Create useful symlinks for Python tools
RUN set -eux; \
for src in idle3 pydoc3 python3 python3-config; do \
dst="$(echo "$src" | tr -d 3)"; \
[ -s "/usr/local/bin/$src" ]; \
[ ! -e "/usr/local/bin/$dst" ]; \
ln -svT "$src" "/usr/local/bin/$dst"; \
done

# Install pip and configure environment variables
ENV PYTHON_PIP_VERSION 24.0
ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/dbf0c85f76fb6e1ab42aa672ffca6f0a675d9ee4/public/get-pip.py
ENV PYTHON_GET_PIP_SHA256 dfe9fd5c28dc98b5ac17979a953ea550cec37ae1b47a5116007395bfacff2ab9

RUN set -eux; \
wget -O get-pip.py "$PYTHON_GET_PIP_URL"; \
echo "$PYTHON_GET_PIP_SHA256 *get-pip.py" | sha256sum -c -; \
python3 get-pip.py --disable-pip-version-check --no-cache-dir --no-compile "pip==$PYTHON_PIP_VERSION"; \
rm -f get-pip.py; \
pip --version

RUN pip install -r /tmp/requirements.txt

# Install Node.js and set up symlinks
RUN set -eux; \
NODE_VERSION="$(curl -fsSL https://nodejs.org/dist/latest/SHASUMS256.txt | head -n1 | awk '{ print $2 }' | awk -F - '{ print $2 }')" \
ARCH= && dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) ARCH='x64';; \
arm64) ARCH='arm64';; \
*) echo "unsupported architecture"; exit 1 ;; \
esac; \
for key in $(curl -sL https://raw.githubusercontent.com/nodejs/docker-node/HEAD/keys/node.keys); do \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key"; \
done; \
curl -fsSLO --compressed "https://nodejs.org/dist/$NODE_VERSION/node-$NODE_VERSION-linux-$ARCH.tar.xz"; \
curl -fsSLO --compressed "https://nodejs.org/dist/$NODE_VERSION/SHASUMS256.txt.asc"; \
gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc; \
grep " node-$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c -; \
tar -xJf "node-$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner; \
rm "node-$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt; \
ln -s /usr/local/bin/node /usr/local/bin/nodejs

# Install curlconverter using npm
RUN npm install --global curlconverter

ENV LANGUAGE=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"symfony/config": "^5.2",
"symfony/console": "^5.2",
"symfony/finder": "^5.2",
"symfony/process": "^5.2",
"symfony/process": "^5.4",
"symfony/validator": "^5.2"
},
"require-dev": {
Expand Down
16 changes: 8 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions python-sync-actions/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM nikolaik/python-nodejs:python3.12-nodejs18
ENV PYTHONIOENCODING utf-8

COPY /src /code/src/
COPY /tests /code/tests/
COPY requirements.txt /code/requirements.txt
COPY flake8.cfg /code/flake8.cfg

# install gcc to be able to build packages - e.g. required by regex, dateparser, also required for pandas
RUN apt-get update && apt-get install -y build-essential curl

# Install curlconverter using npm
RUN npm install --global curlconverter


RUN pip install flake8

RUN pip install -r /code/requirements.txt



WORKDIR /code/


CMD ["python", "-u", "/code/src/component.py"]
Loading
Loading