From 16a4eac35fa69ddf3cd06fe6e86b3f71c9e13ce7 Mon Sep 17 00:00:00 2001 From: Purnama S Rahayu Date: Mon, 14 Oct 2024 19:49:38 +0700 Subject: [PATCH 1/4] add workflow check_query_identifiers and dummy script #339 --- .../workflows/check_query_identifiers.yaml | 43 +++++++++++++++++++ .../check/check_query_identifiers.py | 39 +++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 .github/workflows/check_query_identifiers.yaml create mode 100644 src/scribe_data/check/check_query_identifiers.py diff --git a/.github/workflows/check_query_identifiers.yaml b/.github/workflows/check_query_identifiers.yaml new file mode 100644 index 000000000..99300015d --- /dev/null +++ b/.github/workflows/check_query_identifiers.yaml @@ -0,0 +1,43 @@ +name: check_query_identifiers.yaml +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + format_check: + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + python-version: + - "3.9" + + runs-on: ${{ matrix.os }} + + name: Run Check Query Identifiers + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade uv + uv venv + uv pip install -r requirements.txt + + - name: Activate virtualenv + run: | + . .venv/bin/activate + echo PATH=$PATH >> $GITHUB_ENV + + - name: Run Python script + run: python src/scribe_data/check/check_query_identifiers.py diff --git a/src/scribe_data/check/check_query_identifiers.py b/src/scribe_data/check/check_query_identifiers.py new file mode 100644 index 000000000..a64a048cc --- /dev/null +++ b/src/scribe_data/check/check_query_identifiers.py @@ -0,0 +1,39 @@ +import sys + + +def check_queries(): + # Dummy data simulating query files with incorrect identifiers + incorrect_language_qids = [ + "English/nouns/query_nouns.sparql", + "Spanish/verbs/query_verbs.sparql", + ] + + incorrect_data_type_qids = [ + "English/nouns/query_nouns.sparql", + "French/verbs/query_verbs_1.sparql", + ] + + # Check if there are any incorrect queries + if incorrect_language_qids or incorrect_data_type_qids: + print( + "There are queries that have incorrect language or data type identifiers.\n" + ) + + if incorrect_language_qids: + print("Queries with incorrect languages QIDs are:") + for file in incorrect_language_qids: + print(f"- {file}") + + if incorrect_data_type_qids: + print("\nQueries with incorrect data type QIDs are:") + for file in incorrect_data_type_qids: + print(f"- {file}") + + # Exit with a non-zero status code to indicate failure + sys.exit(1) # Indicate failure + else: + print("All queries are correct.") + + +if __name__ == "__main__": + check_queries() From 94f7cb1f17133d0d00b24a99e5d7ce25e4cd070f Mon Sep 17 00:00:00 2001 From: Purnama S Rahayu Date: Tue, 15 Oct 2024 08:53:30 +0700 Subject: [PATCH 2/4] Update workflow to trigger on future commits --- .github/workflows/check_query_identifiers.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check_query_identifiers.yaml b/.github/workflows/check_query_identifiers.yaml index 99300015d..45b8d7e0a 100644 --- a/.github/workflows/check_query_identifiers.yaml +++ b/.github/workflows/check_query_identifiers.yaml @@ -3,7 +3,9 @@ on: push: branches: [main] pull_request: - branches: [main] + branches: + - main + types: [opened, reopened, synchronize] jobs: format_check: From 26a191849f741dae4838e3f7f102390a998d10dd Mon Sep 17 00:00:00 2001 From: Andrew Tavis McAllister Date: Tue, 15 Oct 2024 22:26:21 +0200 Subject: [PATCH 3/4] Deactivate workflow so it can be brought into other PRs --- .../workflows/check_query_identifiers.yaml | 36 ++++++++--------- .../check/check_query_identifiers.py | 39 ------------------- 2 files changed, 18 insertions(+), 57 deletions(-) delete mode 100644 src/scribe_data/check/check_query_identifiers.py diff --git a/.github/workflows/check_query_identifiers.yaml b/.github/workflows/check_query_identifiers.yaml index 45b8d7e0a..739c5fec3 100644 --- a/.github/workflows/check_query_identifiers.yaml +++ b/.github/workflows/check_query_identifiers.yaml @@ -25,21 +25,21 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - python -m pip install --upgrade uv - uv venv - uv pip install -r requirements.txt - - - name: Activate virtualenv - run: | - . .venv/bin/activate - echo PATH=$PATH >> $GITHUB_ENV - - - name: Run Python script - run: python src/scribe_data/check/check_query_identifiers.py + # - name: Set up Python ${{ matrix.python-version }} + # uses: actions/setup-python@v4 + # with: + # python-version: ${{ matrix.python-version }} + + # - name: Install dependencies + # run: | + # python -m pip install --upgrade uv + # uv venv + # uv pip install -r requirements.txt + + # - name: Activate virtualenv + # run: | + # . .venv/bin/activate + # echo PATH=$PATH >> $GITHUB_ENV + + # - name: Run Python script + # run: python src/scribe_data/check/check_query_identifiers.py diff --git a/src/scribe_data/check/check_query_identifiers.py b/src/scribe_data/check/check_query_identifiers.py deleted file mode 100644 index a64a048cc..000000000 --- a/src/scribe_data/check/check_query_identifiers.py +++ /dev/null @@ -1,39 +0,0 @@ -import sys - - -def check_queries(): - # Dummy data simulating query files with incorrect identifiers - incorrect_language_qids = [ - "English/nouns/query_nouns.sparql", - "Spanish/verbs/query_verbs.sparql", - ] - - incorrect_data_type_qids = [ - "English/nouns/query_nouns.sparql", - "French/verbs/query_verbs_1.sparql", - ] - - # Check if there are any incorrect queries - if incorrect_language_qids or incorrect_data_type_qids: - print( - "There are queries that have incorrect language or data type identifiers.\n" - ) - - if incorrect_language_qids: - print("Queries with incorrect languages QIDs are:") - for file in incorrect_language_qids: - print(f"- {file}") - - if incorrect_data_type_qids: - print("\nQueries with incorrect data type QIDs are:") - for file in incorrect_data_type_qids: - print(f"- {file}") - - # Exit with a non-zero status code to indicate failure - sys.exit(1) # Indicate failure - else: - print("All queries are correct.") - - -if __name__ == "__main__": - check_queries() From d84d8ebc8e87f801ea9fd991a959999e94f72dfc Mon Sep 17 00:00:00 2001 From: Andrew Tavis McAllister Date: Tue, 15 Oct 2024 22:27:39 +0200 Subject: [PATCH 4/4] Remove yaml from workflow name --- .github/workflows/check_query_identifiers.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_query_identifiers.yaml b/.github/workflows/check_query_identifiers.yaml index 739c5fec3..780da47da 100644 --- a/.github/workflows/check_query_identifiers.yaml +++ b/.github/workflows/check_query_identifiers.yaml @@ -1,4 +1,4 @@ -name: check_query_identifiers.yaml +name: check_query_identifiers on: push: branches: [main]