From 9ac176ac8057c0f5a305eb5c73efec91bd71ab56 Mon Sep 17 00:00:00 2001 From: Sebastien Quioc Date: Thu, 19 Feb 2026 17:27:42 +0100 Subject: [PATCH 1/5] refactor(CI): move poetry commands in a dedicated Github Action --- .github/actions/test-with-poetry/action.yaml | 40 ++++++++++++++++++++ .github/workflows/build-modules.yml | 33 ++-------------- 2 files changed, 44 insertions(+), 29 deletions(-) create mode 100644 .github/actions/test-with-poetry/action.yaml diff --git a/.github/actions/test-with-poetry/action.yaml b/.github/actions/test-with-poetry/action.yaml new file mode 100644 index 000000000..b6446bd34 --- /dev/null +++ b/.github/actions/test-with-poetry/action.yaml @@ -0,0 +1,40 @@ +name: Test with poetry +description: Test an automation module with Poetry project manager + +inputs: + module: + description: "The module to test" + required: true + +runs: + using: "composite" + steps: + - name: Install Poetry + run: | + pip install poetry + poetry config virtualenvs.in-project true + + - name: Install Dependencies + id: install-dependencies + run: | + poetry install + working-directory: ${{ inputs.module }} + + - name: Execute Black + uses: psf/black@stable + with: + options: "--check --verbose" + src: ./"${{ inputs.module }}" + + - name: Execute Mypy + run: | + poetry run pip install mypy + mkdir -p .mypy_cache + poetry run mypy --install-types --non-interactive --ignore-missing-imports --show-column-numbers --hide-error-context . + working-directory: "${{ inputs.module }}" + + - name: Execute Python tests + id: execute-tests + run: | + poetry run python -m pytest --junit-xml=junit.xml --cov-report term --cov-report xml:coverage.xml --cov . --cov-config pyproject.toml + working-directory: "${{ inputs.module }}" diff --git a/.github/workflows/build-modules.yml b/.github/workflows/build-modules.yml index f140f11f5..ca89fb163 100644 --- a/.github/workflows/build-modules.yml +++ b/.github/workflows/build-modules.yml @@ -59,37 +59,12 @@ jobs: uses: actions/setup-python@v4 id: setup-python with: - python-version: '3.11' + python-version: "3.11" - - name: Install Poetry - run: | - pip install poetry - poetry config virtualenvs.in-project true - - - name: Install Dependencies - id: install-dependencies - run: | - poetry install - working-directory: ${{ matrix.module }} - - - name: Execute Black - uses: psf/black@stable + - name: Test with Poetry + uses: ./.github/actions/test-with-poetry with: - options: "--check --verbose" - src: ./"${{ matrix.module }}" - - - name: Execute Mypy - run: | - poetry run pip install mypy - mkdir -p .mypy_cache - poetry run mypy --install-types --non-interactive --ignore-missing-imports --show-column-numbers --hide-error-context . - working-directory: "${{ matrix.module }}" - - - name: Execute Python tests - id: execute-tests - run: | - poetry run python -m pytest --junit-xml=junit.xml --cov-report term --cov-report xml:coverage.xml --cov . --cov-config pyproject.toml - working-directory: "${{ matrix.module }}" + module: ${{ matrix.module }} - name: Upload Event uses: actions/upload-artifact@v4 From 1945196f7e674164319c5ae41ce3d4fe4cd81ab8 Mon Sep 17 00:00:00 2001 From: Sebastien Quioc Date: Thu, 19 Feb 2026 17:27:59 +0100 Subject: [PATCH 2/5] chore(CI): lint --- .github/actions/test-with-poetry/action.yaml | 4 ++++ .github/workflows/build-modules.yml | 17 ++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/actions/test-with-poetry/action.yaml b/.github/actions/test-with-poetry/action.yaml index b6446bd34..ec0198b20 100644 --- a/.github/actions/test-with-poetry/action.yaml +++ b/.github/actions/test-with-poetry/action.yaml @@ -10,12 +10,14 @@ runs: using: "composite" steps: - name: Install Poetry + shell: bash run: | pip install poetry poetry config virtualenvs.in-project true - name: Install Dependencies id: install-dependencies + shell: bash run: | poetry install working-directory: ${{ inputs.module }} @@ -27,6 +29,7 @@ runs: src: ./"${{ inputs.module }}" - name: Execute Mypy + shell: bash run: | poetry run pip install mypy mkdir -p .mypy_cache @@ -35,6 +38,7 @@ runs: - name: Execute Python tests id: execute-tests + shell: bash run: | poetry run python -m pytest --junit-xml=junit.xml --cov-report term --cov-report xml:coverage.xml --cov . --cov-config pyproject.toml working-directory: "${{ inputs.module }}" diff --git a/.github/workflows/build-modules.yml b/.github/workflows/build-modules.yml index ca89fb163..8a1383644 100644 --- a/.github/workflows/build-modules.yml +++ b/.github/workflows/build-modules.yml @@ -2,7 +2,7 @@ name: Build Modules on: pull_request: - types: [ opened, synchronize, reopened ] + types: [opened, synchronize, reopened] push: branches: - main @@ -15,7 +15,6 @@ env: IMAGE_PREFIX_NAME: sekoia-io jobs: - find-modules: name: Find modules in repo runs-on: ubuntu-latest @@ -167,13 +166,13 @@ jobs: if: always() steps: - - name: Success - if: ${{ !(contains(needs.*.result, 'failure')) || needs.find-modules.outputs.matrix == '[]' }} - run: exit 0 - - name: Failure - if: ${{ contains(needs.*.result, 'failure') && needs.find-modules.outputs.matrix != '[]' }} - run: | - exit 1 + - name: Success + if: ${{ !(contains(needs.*.result, 'failure')) || needs.find-modules.outputs.matrix == '[]' }} + run: exit 0 + - name: Failure + if: ${{ contains(needs.*.result, 'failure') && needs.find-modules.outputs.matrix != '[]' }} + run: | + exit 1 deploy-module: name: Deploy modules From 71f3858cf883617039cb0efd27b0f1fb87196848 Mon Sep 17 00:00:00 2001 From: Sebastien Quioc Date: Thu, 19 Feb 2026 17:33:36 +0100 Subject: [PATCH 3/5] chore(CI): add the test-with-uv action --- .github/actions/test-with-uv/action.yaml | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/actions/test-with-uv/action.yaml diff --git a/.github/actions/test-with-uv/action.yaml b/.github/actions/test-with-uv/action.yaml new file mode 100644 index 000000000..d4e7c0b9f --- /dev/null +++ b/.github/actions/test-with-uv/action.yaml @@ -0,0 +1,44 @@ +name: Test with uv +description: Test an automation module with uv project manager + +inputs: + module: + description: "The module to test" + required: true + +runs: + using: "composite" + steps: + - name: Install uv + uses: astral-sh/setup-uv@v6 + with: + enable-cache: true + activate-environment: true + + - name: Install Dependencies + id: install-dependencies + shell: bash + run: | + uv sync + working-directory: ${{ inputs.module }} + + - name: Execute Black + uses: psf/black@stable + with: + options: "--check --verbose" + src: ./"${{ inputs.module }}" + + - name: Execute Mypy + shell: bash + run: | + uv pip install mypy + mkdir -p .mypy_cache + uv run mypy --install-types --non-interactive --ignore-missing-imports --show-column-numbers --hide-error-context . + working-directory: ${{ inputs.module }} + + - name: Execute Python tests + id: execute-tests + shell: bash + run: | + uv run pytest --junit-xml=junit.xml --cov-report term --cov-report xml:coverage.xml --cov . --cov-config pyproject.toml + working-directory: ${{ inputs.module }} From bab7a22bdde6838bc058f42b4261dec4557c3220 Mon Sep 17 00:00:00 2001 From: Sebastien Quioc Date: Thu, 19 Feb 2026 17:42:24 +0100 Subject: [PATCH 4/5] chore(CI): update build-modules workflow to handle both poetry and uv projects --- .github/workflows/build-modules.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/build-modules.yml b/.github/workflows/build-modules.yml index 8a1383644..0ca28a1e7 100644 --- a/.github/workflows/build-modules.yml +++ b/.github/workflows/build-modules.yml @@ -60,11 +60,31 @@ jobs: with: python-version: "3.11" + - name: Detect package manager + id: detect-pm + run: | + if [ -f "${MODULE_PATH}/uv.lock" ]; then + echo "package_manager=uv" >> $GITHUB_OUTPUT + echo "Detected uv project" + else + echo "package_manager=poetry" >> $GITHUB_OUTPUT + echo "Defaulting to Poetry" + fi + env: + MODULE_PATH: ${{ matrix.module }} + - name: Test with Poetry + if: steps.detect-pm.outputs.package_manager == 'poetry' uses: ./.github/actions/test-with-poetry with: module: ${{ matrix.module }} + - name: Test with uv + if: steps.detect-pm.outputs.package_manager == 'uv' + uses: ./.github/actions/test-with-uv + with: + module: ${{ matrix.module }} + - name: Upload Event uses: actions/upload-artifact@v4 with: From 45b0c869e83ca3bb5c4102806cf05e245b93ff4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Quioc?= Date: Mon, 23 Feb 2026 14:07:26 +0100 Subject: [PATCH 5/5] Update .github/actions/test-with-uv/action.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/actions/test-with-uv/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/test-with-uv/action.yaml b/.github/actions/test-with-uv/action.yaml index d4e7c0b9f..2495d5465 100644 --- a/.github/actions/test-with-uv/action.yaml +++ b/.github/actions/test-with-uv/action.yaml @@ -19,7 +19,7 @@ runs: id: install-dependencies shell: bash run: | - uv sync + uv sync --frozen working-directory: ${{ inputs.module }} - name: Execute Black