From 9861bd876ffc6317864444ab3e726ec369ddad6d Mon Sep 17 00:00:00 2001 From: Daniil Roman Date: Mon, 3 Mar 2025 13:02:34 +0100 Subject: [PATCH 1/8] Add CI for Python client --- .github/workflows/python-client.yml | 86 +++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/python-client.yml diff --git a/.github/workflows/python-client.yml b/.github/workflows/python-client.yml new file mode 100644 index 0000000000..fe3dc1fed0 --- /dev/null +++ b/.github/workflows/python-client.yml @@ -0,0 +1,86 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Python project with Poetry and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-python + +name: Python CI with Poetry + +on: + push: + branches: [ "main" ] + paths: + - 'regtests/client/python/**' + pull_request: + branches: [ "main" ] + paths: + - 'regtests/client/python/**' + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache Poetry + id: cache-poetry + uses: actions/cache@v3 + with: + path: ~/.cache/pypoetry + key: ${{ runner.os }}-poetry-${{ hashFiles('regtests/client/python/poetry.lock') }} + restore-keys: | + ${{ runner.os }}-poetry- + + - name: Install Poetry + if: steps.cache-poetry.outputs.cache-hit != 'true' + run: | + curl -sSL https://install.python-poetry.org | python3 - + export PATH="$HOME/.local/bin:$PATH" + + - name: Install dependencies + run: | + cd regtests/client/python + poetry install + + - name: Lint with flake8 + run: | + cd regtests/client/python + # stop the build if there are Python syntax errors or undefined names + poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + - name: Test with pytest + run: | + cd regtests/client/python + poetry run pytest \ No newline at end of file From 389f5e6a7963505444b6d49863ab78e5ab247793 Mon Sep 17 00:00:00 2001 From: Daniil Roman Date: Mon, 3 Mar 2025 14:12:58 +0100 Subject: [PATCH 2/8] Increase actions cache version --- .github/workflows/python-client.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-client.yml b/.github/workflows/python-client.yml index fe3dc1fed0..9af50fb2db 100644 --- a/.github/workflows/python-client.yml +++ b/.github/workflows/python-client.yml @@ -45,7 +45,8 @@ jobs: python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: - - uses: actions/checkout@v4 + - name: Checkout Polaris project + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 @@ -54,7 +55,7 @@ jobs: - name: Cache Poetry id: cache-poetry - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.cache/pypoetry key: ${{ runner.os }}-poetry-${{ hashFiles('regtests/client/python/poetry.lock') }} From 210b285cb29dae9c9a8692459c74962992ee4caf Mon Sep 17 00:00:00 2001 From: Daniil Roman Date: Mon, 3 Mar 2025 14:16:46 +0100 Subject: [PATCH 3/8] Get use of working-directory --- .github/workflows/python-client.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/python-client.yml b/.github/workflows/python-client.yml index 9af50fb2db..b1f3d2c1ef 100644 --- a/.github/workflows/python-client.yml +++ b/.github/workflows/python-client.yml @@ -69,19 +69,17 @@ jobs: export PATH="$HOME/.local/bin:$PATH" - name: Install dependencies - run: | - cd regtests/client/python - poetry install + working-directory: regtests/client/python + run: poetry install - name: Lint with flake8 + working-directory: regtests/client/python run: | - cd regtests/client/python # stop the build if there are Python syntax errors or undefined names poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest - run: | - cd regtests/client/python - poetry run pytest \ No newline at end of file + working-directory: regtests/client/python + run: poetry run pytest \ No newline at end of file From 98b2078004ace264a27b8ecb43108a356ce7a295 Mon Sep 17 00:00:00 2001 From: Daniil Roman Date: Mon, 3 Mar 2025 14:17:34 +0100 Subject: [PATCH 4/8] Add EOF line --- .github/workflows/python-client.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-client.yml b/.github/workflows/python-client.yml index b1f3d2c1ef..696a43bc2d 100644 --- a/.github/workflows/python-client.yml +++ b/.github/workflows/python-client.yml @@ -82,4 +82,4 @@ jobs: - name: Test with pytest working-directory: regtests/client/python - run: poetry run pytest \ No newline at end of file + run: poetry run pytest From 5a5c0a504285f0dc4fdeb325858080b778f8614c Mon Sep 17 00:00:00 2001 From: Daniil Roman Date: Tue, 4 Mar 2025 21:22:36 +0100 Subject: [PATCH 5/8] Install Poetry 1.8.5 + remove 3.7, 3.8 Python versions from matrix --- .github/workflows/python-client.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-client.yml b/.github/workflows/python-client.yml index 696a43bc2d..3ab4a91b8e 100644 --- a/.github/workflows/python-client.yml +++ b/.github/workflows/python-client.yml @@ -42,7 +42,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11"] steps: - name: Checkout Polaris project @@ -65,7 +65,7 @@ jobs: - name: Install Poetry if: steps.cache-poetry.outputs.cache-hit != 'true' run: | - curl -sSL https://install.python-poetry.org | python3 - + curl -sSL https://install.python-poetry.org | python3 - --version 1.8.5 export PATH="$HOME/.local/bin:$PATH" - name: Install dependencies From c7e8ec5f613673b190a68e0c24201f1d5dd34947 Mon Sep 17 00:00:00 2001 From: Daniil Roman Date: Tue, 4 Mar 2025 21:28:32 +0100 Subject: [PATCH 6/8] Set SCRIPT_DIR before running pytest --- .github/workflows/python-client.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-client.yml b/.github/workflows/python-client.yml index 3ab4a91b8e..126036a72e 100644 --- a/.github/workflows/python-client.yml +++ b/.github/workflows/python-client.yml @@ -82,4 +82,6 @@ jobs: - name: Test with pytest working-directory: regtests/client/python - run: poetry run pytest + run: | + export SCRIPT_DIR="non-existing-mock-directory" + poetry run pytest From a4d6351cf979071fde829207b420094981510caa Mon Sep 17 00:00:00 2001 From: Daniil Roman Date: Tue, 4 Mar 2025 21:54:08 +0100 Subject: [PATCH 7/8] Relax flake8 rules --- .github/workflows/python-client.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/python-client.yml b/.github/workflows/python-client.yml index 126036a72e..9e64b9814d 100644 --- a/.github/workflows/python-client.yml +++ b/.github/workflows/python-client.yml @@ -75,10 +75,7 @@ jobs: - name: Lint with flake8 working-directory: regtests/client/python run: | - # stop the build if there are Python syntax errors or undefined names - poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + poetry run flake8 --select=E9,F63,F7,F82 --max-line-length=127 --statistics - name: Test with pytest working-directory: regtests/client/python From e1781a4dec672d717e527a78e44c8757bc88541e Mon Sep 17 00:00:00 2001 From: Daniil Roman Date: Sun, 23 Mar 2025 21:33:28 +0100 Subject: [PATCH 8/8] Update after moving python client to root dir --- .github/workflows/python-client.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-client.yml b/.github/workflows/python-client.yml index 9e64b9814d..cb730afc51 100644 --- a/.github/workflows/python-client.yml +++ b/.github/workflows/python-client.yml @@ -30,11 +30,11 @@ on: push: branches: [ "main" ] paths: - - 'regtests/client/python/**' + - 'client/python/**' pull_request: branches: [ "main" ] paths: - - 'regtests/client/python/**' + - 'client/python/**' jobs: build: @@ -58,7 +58,7 @@ jobs: uses: actions/cache@v4 with: path: ~/.cache/pypoetry - key: ${{ runner.os }}-poetry-${{ hashFiles('regtests/client/python/poetry.lock') }} + key: ${{ runner.os }}-poetry-${{ hashFiles('client/python/poetry.lock') }} restore-keys: | ${{ runner.os }}-poetry- @@ -69,16 +69,16 @@ jobs: export PATH="$HOME/.local/bin:$PATH" - name: Install dependencies - working-directory: regtests/client/python + working-directory: client/python run: poetry install - name: Lint with flake8 - working-directory: regtests/client/python + working-directory: client/python run: | poetry run flake8 --select=E9,F63,F7,F82 --max-line-length=127 --statistics - name: Test with pytest - working-directory: regtests/client/python + working-directory: client/python run: | export SCRIPT_DIR="non-existing-mock-directory" poetry run pytest