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/test coverage integration functional performance #67

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1ba505f
Implemented SPARQL in model index functionalities.
Aug 21, 2024
2c2e23b
Implemented CI/CD pipeline and updated code to pass pre-commit hooks.
Aug 27, 2024
bf21fbe
Fixed TypeError in failed tests.
Aug 28, 2024
d687c43
Added webhook setup in GitHub Actions workflow.
Aug 29, 2024
f85d82b
Corrected webhook alignment.
Aug 29, 2024
c951ecb
Refactored and optimized unit tests in shared_test.py and auth_client…
Aug 29, 2024
39a6e52
Refactored and updated remaining tests in auth_client_test.py
Aug 30, 2024
d43bd9a
Fixed test failing in CI.
MeenaBana Aug 30, 2024
d3da58f
Achieved 100% code coverage for ModelIndex class.
MeenaBana Aug 30, 2024
f445dbf
Enhanced OPC_UA test suite for improved code coverage.
MeenaBana Aug 30, 2024
ae27ec7
Enhanced OPC_UA class and added comprehensive unit tests.
MeenaBana Sep 2, 2024
f4b0ba7
Added new test cases in OPCUA class.
MeenaBana Sep 3, 2024
9a0f3a2
Refactored OPC UA tests for improved clarity and reduced redundancy.
MeenaBana Sep 5, 2024
6fc8f71
Enhanced OPC UA tests and improved code coverage.
MeenaBana Sep 9, 2024
1d85886
Achieved 100% code coverage for the OPC UA class.
MeenaBana Sep 9, 2024
f24468f
Refactored DWH tests for better coverage.
MeenaBana Sep 10, 2024
b2d3221
Refactored and optimized DB class tests.
MeenaBana Sep 10, 2024
97cbff9
Refactored and expanded test coverage for Db class.
MeenaBana Sep 11, 2024
9682de8
Refactored Db class tests for better compatibility.
MeenaBana Sep 12, 2024
5de56e0
Refactored Db class implementation and tests for IDWH interface.
MeenaBana Sep 13, 2024
d63ddde
Refactored tests and fixtures.
MeenaBana Sep 16, 2024
4308870
Updated notebooks to read environment variables from .env file.
MeenaBana Sep 26, 2024
9ea30c9
Refactored tests and added fixtures.
MeenaBana Sep 26, 2024
8cd4e3f
Refactored ModelIndex tests and fixed assertions.
MeenaBana Sep 27, 2024
fea128a
Adjusted test configurations to address test failures.
MeenaBana Sep 27, 2024
6a8cad3
Resolved issues with test failures in the CI/CD pipeline.
MeenaBana Sep 27, 2024
b23ad3b
Fixed test failure by updating token assertions and format.
MeenaBana Sep 27, 2024
c2ba3fc
Ensured timezone-aware comparison for token expiration.
MeenaBana Sep 27, 2024
15e1ffe
Added more detailed assertions with error messages.
MeenaBana Sep 27, 2024
6b91887
Added debugging to auth client test.
MeenaBana Sep 27, 2024
d94f337
Addressed failing test error in CI/CD pipeline.
MeenaBana Sep 27, 2024
39c67a4
Updated README with pre-commit hook details.
MeenaBana Sep 27, 2024
33651c7
Resolved merge conflicts in PR.
MeenaBana Sep 27, 2024
b0a6ec8
Fixed failing tests after resolving merge conflicts.
MeenaBana Sep 29, 2024
c68d3e5
Added isort for sorting Import statements.
MeenaBana Sep 30, 2024
6d364b6
Implement PR feedback.
MeenaBana Sep 30, 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
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ exclude_lines =
# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:

show_missing = True
87 changes: 87 additions & 0 deletions .github/workflows/ci-cd-webhook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CI/CD and Webhook

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12

- name: Create virtual environment
run: python -m venv .venv

- name: Activate virtual environment
run: source .venv/bin/activate

- name: Install dependencies
run: pip install -r requirements.txt

- name: Run pre-commit checks
run: pre-commit run --all-files

webhook:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Google Cloud CLI
run: |
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
sudo apt-get install apt-transport-https ca-certificates gnupg
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update && sudo apt-get install google-cloud-cli

- name: Authenticate with Google Cloud
run: |
echo '${{ secrets.GCP_SA_KEY }}' > sa-key.json
gcloud auth activate-service-account sa-git-data-sources@tgs-prediktor-dev-598e.iam.gserviceaccount.com --key-file=sa-key.json
rm sa-key.json

- name: Generate and send identity token
run: |
IDENTITY_TOKEN=$(gcloud auth print-identity-token --audiences="https://us-central1-tgs-prediktor-dev-598e.cloudfunctions.net/git_webhook_to_bigquery")
WEBHOOK_URL="https://us-central1-tgs-prediktor-dev-598e.cloudfunctions.net/git_webhook_to_bigquery"

prepare_payload() {
local event_type="$1"
jq -n \
--arg event "$event_type" \
--arg repository "${{ github.repository }}" \
--arg url "https://github.com/${{ github.repository }}" \
--arg actor "${{ github.actor }}" \
--arg ref "${{ github.ref }}" \
--argjson payload "$2" \
'{
event: $event,
repository: { name: $repository, url: $url },
actor: $actor,
ref: $ref,
payload: $payload
}'
}

case "${{ github.event_name }}" in
push)
PAYLOAD=$(prepare_payload "push" "$(echo '${{ toJson(github.event) }}' | jq '{commits: .commits, before: .before, after: .after, pusher: .pusher}')")
;;
pull_request)
PAYLOAD=$(prepare_payload "pull_request" "$(echo '${{ toJson(github.event.pull_request) }}' | jq '{number: .number, title: .title, state: .state, body: .body}')")
;;
*)
PAYLOAD=$(prepare_payload "${{ github.event_name }}" "{}")
;;
esac

curl -H "Authorization: Bearer $IDENTITY_TOKEN" \
-H "Content-Type: application/json" \
-d "$PAYLOAD" \
$WEBHOOK_URL
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ jobs:
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
Expand All @@ -61,7 +61,7 @@ jobs:
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
branch: gh-pages
2 changes: 1 addition & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ jobs:

- name: Test with tox
run: |
tox
tox
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ venv*/
# data folders
*data*/
*json
*parquet
*parquet
50 changes: 50 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
default_language_version:
python: python3.12

repos:
MeenaBana marked this conversation as resolved.
Show resolved Hide resolved
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: requirements-txt-fixer
- id: debug-statements
- id: name-tests-test

- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
- id: docformatter
args: ["--in-place"]

- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
hooks:
- id: autoflake
args: ["--remove-all-unused-imports", "--in-place"]

- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
args: ["--line-length", "79"]

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
args: ["--ignore=E501,W503"]

- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
args: ["-x", "tests/*"]

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.9.0
hooks:
- id: isort
args: ["--profile", "black", "--line-length", "79"]
75 changes: 60 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,80 @@ source .venv/bin/activate
pip install -r requirements.txt
```

## Pre-commit Hooks

To ensure code quality and maintain a consistent coding standard, pre-commit hooks have been added to the repository. All the pre-commit checks must be passed before committing your changes. Follow the instructions below to install and use them.

4. Activate pre-commit hooks
After installing the requirements, activate the pre-commit hooks by running:

```
pre-commit install
```

5. Run pre-commit hooks manually
It's recommended to run the pre-commit hooks before making a commit to catch issues early. Use the following command to run all the hooks manually:

```
pre-commit run --all-files
```

6. Stage your changes
After making the required changes and ensuring they pass the pre-commit hooks, add the changes to the staging area before creating a commit:

```
git add .
```

## isort for Import Sorting

To maintain a clean and organized codebase, we use isort to automatically sort Python import statements according to PEP 8 standards.

7. Run isort

Run `isort` manually to sort the imports in the project using the command:

```
isort .
```

However, applying these changes could lead to conflicts. To verify the import order without making any modifications, use the following command:

```
isort . --check-only
```

The `isort` configuration is managed in the `pyproject.toml` file to ensure it integrates well with black and other tools.


## Run and build

4. Run tests
8. Run tests

```
tox
```

5. Do your changes
Add your changes and create a new PR to be approved.
9. Make your changes and submit a new PR for approval.

6. Build
10. Build

```
tox -e build
```

## Changes

7. Please apply your changes. If they will facilitate the work of the person using pyPrediktorMapClient, especially the new features you've implemented, ensure that you describe your changes comprehensively and provide guidance in the README.md file under the chapter `Manual - How to Use` (check below).
11. Please apply your changes. If they will facilitate the work of the person using pyPrediktorMapClient, especially the new features you've implemented, ensure that you describe your changes comprehensively and provide guidance in the README.md file under the chapter `Manual - How to Use` (check below).

8. Commit your changes to a new branch, push and create a new pull request for review.
12. Commit your changes to a new branch, push and create a new pull request for review.

## Publish on PyPi

9. Open [https://pypi.org/](https://pypi.org/) and log in.
10. Open [https://pypi.org/manage/account/](https://pypi.org/manage/account/) and generate a new API token but only if you don't have one already. Keep the API key on your local machine because once generated it will be visible only once. Delete API keys that are no longer used!
11. In your code editor, open the root directory of the current project and clean the content of folder `dist`.
12. Create a new tag and push it to the GitHub repository. For instance, if the latest tag is `0.6.7` the new tag should be `0.6.8`. Alternatively, if the changes are major, you can set the new tag to `0.7.0`.
13. Open [https://pypi.org/](https://pypi.org/) and log in.
14. Open [https://pypi.org/manage/account/](https://pypi.org/manage/account/) and generate a new API token but only if you don't have one already. Keep the API key on your local machine because once generated it will be visible only once. Delete API keys that are no longer used!
15. In your code editor, open the root directory of the current project and clean the content of folder `dist`.
16. Create a new tag and push it to the GitHub repository. For instance, if the latest tag is `0.6.7` the new tag should be `0.6.8`. Alternatively, if the changes are major, you can set the new tag to `0.7.0`.

Use the following commands to create the tag and to publish it.

Expand All @@ -77,13 +122,13 @@ git tag 0.6.8
git push origin 0.6.8
```

13. Create a new build. Be aware that `tox.ini` file is configured in a way to get latest tag from the repository. That tag is going to be used to label the new build.
17. Create a new build. Be aware that `tox.ini` file is configured in a way to get latest tag from the repository. That tag is going to be used to label the new build.

```
tox -e build
```

14. Be sure that twine is installed. If not, run the following command:
18. Be sure that twine is installed. If not, run the following command:

```
python3 -m pip install twine
Expand All @@ -95,19 +140,19 @@ or
python -m pip install twine
```

15. Publish the build on PyPi:
19. Publish the build on PyPi:

```
python3 -m twine upload -u __token__ -p API_KEY dist/*
```

Replace API_KEY with the API key you generated earlier or a key you already have.

16. Check if the new version has been release - [Release history](https://pypi.org/project/pyPrediktorMapClient/#history).
20. Check if the new version has been release - [Release history](https://pypi.org/project/pyPrediktorMapClient/#history).

Once that's done, we have to publish a new release in the GitHub repository.

17. Open the list of released published on the [GitHub repository](https://github.com/PrediktorAS/pyPrediktorMapClient/releases). Draft a new release by pressing "Draft a new release".
21. Open the list of released published on the [GitHub repository](https://github.com/PrediktorAS/pyPrediktorMapClient/releases). Draft a new release by pressing "Draft a new release".

Use the newly created tag which in our example is 0.6.8. Add detailed descrption about the new changes.

Expand Down
11 changes: 7 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
# serve to show the default.

import os
import sys
import shutil
import sphinx_rtd_theme
import sys

# -- Path setup --------------------------------------------------------------

Expand Down Expand Up @@ -44,7 +43,9 @@
try:
import sphinx

cmd_line = f"sphinx-apidoc --implicit-namespaces -f -o {output_dir} {module_dir}"
cmd_line = (
f"sphinx-apidoc --implicit-namespaces -f -o {output_dir} {module_dir}"
)

args = cmd_line.split(" ")
if tuple(sphinx.__version__.split(".")) >= ("1", "7"):
Expand Down Expand Up @@ -106,7 +107,9 @@
version = ""

if not version or version.lower() == "unknown":
version = os.getenv("READTHEDOCS_VERSION", "unknown") # automatically set by RTD
version = os.getenv(
"READTHEDOCS_VERSION", "unknown"
) # automatically set by RTD

release = version

Expand Down
Loading
Loading