From a4113bf2ad397441abb3aa32392e925992065a41 Mon Sep 17 00:00:00 2001 From: agl29 Date: Thu, 24 Oct 2024 12:43:49 +0530 Subject: [PATCH] [pytest] Add warning for PRs missing unit test file changes --- .github/workflows/commitflow-py3.yml | 18 ++++++++++++++++++ .../notebook/src/notebook/connectors/trino.py | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/.github/workflows/commitflow-py3.yml b/.github/workflows/commitflow-py3.yml index d17c0699a39..ed63f76d43b 100644 --- a/.github/workflows/commitflow-py3.yml +++ b/.github/workflows/commitflow-py3.yml @@ -70,6 +70,24 @@ jobs: name: test-reports-${{ matrix.python-version }} path: test-reports + - name: Check and comment if no unit test files are modified + if: matrix.python-version == '3.11' + run: | + git fetch origin master + changed_files=$(git diff --name-only origin/master) + + if echo "$changed_files" | grep -qE '(^test|_test\.py|^tests|_tests\.py|.test)'; then + echo "✅ Unit test files were modified." + else + echo "⚠️ No unit test files modified." + + curl -X POST \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + -d '{"body":"⚠️ No unit test files modified. Please ensure that changes are properly tested. ⚠️"}' \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" + fi + - name: run python lints run: | PYTHONWARNINGS=always ./build/env/bin/hue runruff check diff --git a/desktop/libs/notebook/src/notebook/connectors/trino.py b/desktop/libs/notebook/src/notebook/connectors/trino.py index 921b1ce0b7c..149090b22bb 100644 --- a/desktop/libs/notebook/src/notebook/connectors/trino.py +++ b/desktop/libs/notebook/src/notebook/connectors/trino.py @@ -289,6 +289,13 @@ def close_statement(self, notebook, snippet): return {'status': 0} def close_session(self, session): + catalogs = self._show_catalogs() + databases = [] + + for catalog in catalogs: + query_client = TrinoQuery(self.trino_request, 'SHOW SCHEMAS FROM ' + catalog) + response = query_client.execute() + databases += [f'{catalog}.{item}' for sublist in response.rows for item in sublist] # Avoid closing session on page refresh or editor close for now pass