-
Notifications
You must be signed in to change notification settings - Fork 3
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: add rules engine #481
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #481 +/- ##
==========================================
- Coverage 70.06% 69.97% -0.10%
==========================================
Files 46 47 +1
Lines 2856 2904 +48
Branches 624 630 +6
==========================================
+ Hits 2001 2032 +31
- Misses 670 684 +14
- Partials 185 188 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
f6d6331
to
5ab62ad
Compare
With these rules, is it possible to exclude one or more profiles? For example, I want to deploy all the profiles on my repo except |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some remarks for documentation and use case. I hope I will find time for test this week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Operators in json schema must be updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM !
Very nice improvement. Can't wait to see new variable supported for rules !
0c3bc85
to
9a8bb42
Compare
Quality Gate passedIssues Measures |
Following #481, this PR fixes the case where a profile is not installed because of not matching defined rules but QDT is failing because of Splash Screen job tries to log a `profile.name` that does not exist in that case: ```python 2024-04-18 15:40:56||ERROR||check_path||check_path_exists||145||C:\Users\runneradmin\AppData\Roaming\QGIS\QGIS3\profiles\QDT Only Linux\QGIS\QGIS3.ini doesn't exist. Attempt 2/2. Game over. 2024-04-18 15:40:56||INFO||qgis_ini_handler||__init__||117||The specified file does not exist: C:\Users\runneradmin\AppData\Roaming\QGIS\QGIS3\profiles\QDT Only Linux\QGIS\QGIS3.ini. 2024-04-18 15:40:56||INFO||job_splash_screen||run||135||No profile.json found for profile 'C:\Users\runneradmin\.cache\qgis-deployment-toolbelt\repositories\qdt-demo-scenario\examples\profiles\only_linux' 2024-04-18 15:40:56||ERROR||bouncer||exit_cli_error||43||'NoneType' object has no attribute 'name' Traceback (most recent call last): File "d:\a\qgis-deployment-cli\qgis-deployment-cli\qgis_deployment_toolbelt\commands\deployment.py", line 205, in run job.run() File "d:\a\qgis-deployment-cli\qgis-deployment-cli\qgis_deployment_toolbelt\jobs\job_splash_screen.py", line 143, in run f"{profile_installed.name} ({profile_installed.path_in_qgis})" AttributeError: 'NoneType' object has no attribute 'name' 2024-04-18 15:40:56||ERROR||bouncer||exit_cli_error||44||Please, read the full detailed log: C:\Users\runneradmin\.cache\qgis-deployment-toolbelt\logs\QGISDeploymentToolbelt_0.33.0.log 'NoneType' object has no attribute 'name' 2024-04-18 15:40:57||WARNING||shortcuts||__init__||110||Executable does not exist: C:\Program Files\QGIS 3.34.4\bin\qgis-ltr-bin.exe. Shortcuts might not work. Check and fix your scenario. 2024-04-18 15:40:57||WARNING||shortcuts||__init__||110||Executable does not exist: C:\Program Files\QGIS 3.34.4\bin\qgis-ltr-bin.exe. Shortcuts might not work. Check and fix your scenario. 2024-04-18 15:40:57||WARNING||job_splash_screen||run||162||Profile qdt_demo -C:\Users\runneradmin\AppData\Roaming\QGIS\QGIS3\profiles\qdt_demo\images\splash.png dimensions (1000, 479) do not comply with dimensions recomended by QGIS for splash screen: 600x300. 2024-04-18 15:40:57||ERROR||check_path||check_path_exists||145||C:\Users\runneradmin\AppData\Roaming\QGIS\QGIS3\profiles\QDT Only Linux\QGIS\QGIS3.ini doesn't exist. Attempt 2/2. Game over. 2024-04-18 15:40:57||ERROR||bouncer||exit_cli_error||43||'NoneType' object has no attribute 'name' Traceback (most recent call last): File "d:\a\qgis-deployment-cli\qgis-deployment-cli\qgis_deployment_toolbelt\commands\deployment.py", line 205, in run job.run() File "d:\a\qgis-deployment-cli\qgis-deployment-cli\qgis_deployment_toolbelt\jobs\job_splash_screen.py", line 143, in run f"{profile_installed.name} ({profile_installed.path_in_qgis})" AttributeError: 'NoneType' object has no attribute 'name' 2024-04-18 15:40:57||ERROR||bouncer||exit_cli_error||44||Please, read the full detailed log: C:\Users\runneradmin\.cache\qgis-deployment-toolbelt\logs\QGISDeploymentToolbelt_0.33.0.log 'NoneType' object has no attribute 'name' ```
This PR adds date information to rules context allowing to condition a profile deployment based on current year, month or day. In the following example, the profile is installed only if QDT runs on a Linux operating system and if the current year >= 2023: ```json { "$schema": "https://raw.githubusercontent.com/Guts/qgis-deployment-cli/main/docs/schemas/profile/qgis_profile.json", "name": "QDT Only Linux", "folder_name": "qdt_only_linux", "description": "Demonstrating a QDT profile that's deployed only on Linux.", "author": "Julien Moura", "email": "infos+qdt@oslandia.com", "qgisMinimumVersion": "3.34.0", "qgisMaximumVersion": "3.99.10", "version": "1.0.0", "rules": [ { "name": "Environment", "description": "Profile is configured to run only on Linux.", "conditions": { "all": [ { "path": "$.environment.operating_system_code", "value": "linux", "operator": "equal" }, { "path": "$.date.current_year", "value": 2023, "operator": "greater_than_inclusive" } ] } } ] } ``` Depends on #481
…matically in jobs (#487) This PR is a following up of #481 and #486. After some real-life testing of the profile deployment rules, it became clear that the initial implementation was clumsy. By placing the filtering of profiles based on rules in the qprofiles-synchronizer job alone, we forget that other jobs based on the content of downloaded profiles also need to respect the rules: qplugins-synchronizer, etc. This PR fixes this by moving the rules filtering logic right into the generic job class and make sure that every job which relies on downloaded profiles use the same method to filter on rules.
This PR is a following up of #481. It's mainly a code structure improvement which aims to improve readability, testing and maintainability: - create an object - move it from utils to profiles since it's only related to QDT profiles management - add methods to export as dict and JSON - add unit test - use it in documentation and GenericJob.filter_on_rules Next (spoiler alert): a CLI command to generate the rules context to make the rules writing more handy
This PR adds a mechanism to allow QGIS profile editors to condition their deployment with a minimalist system of rules that can be edited in the
profile.json
file.Featured changes
Example
Other changes
It also initiates a change in the documentation organization to comply with https://documentation.divio.com/.
Related to