-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add Dashboard Support: #72 Add dashboard related actions #73
Add Dashboard Support: #72 Add dashboard related actions #73
Conversation
Added `create_dashboard` action.
* Added `add_gadget` action. Allows the user to add a gadget to an existing dashboard.
…Action * Added `update_dashboard` action. It accepts parameters for the update, fetches the dashboard by `id`, runs the `update` method on the `dashboard` resource and returns it's `raw` result (`json` result from the API)
* Added `update_gadget` action to allow a user to modify an existing gadget on a dashboard.
…Action * Added an action to delete dashboards by `id`. The `jira` library only returns the raw `requests` response in this case. The return is a dictionary containing the response status code and any text that was included with the response. The action fails if any status code other than 204 is produced.
* Added `remove_gadget` action to allow users to delete gadgets from dashboards.
* The `get_gadgets` action just pulls the available list of gadgets from the `jira` instance. This commit also includes a fix to the description of the `remove_gadget` yaml.
This is more in keeping with the API.
…ets` Action * The `get_dashboard_gadgets` action differs from the `get_available_gadgets` action in that, it targets a specific dashboard and returns only the gadgets present on that dashboard.
…tion * Added the `copy_dashboard` action. * Updated some descriptions in `update_dashboard` and `create_dashboard` yaml files.
* Added `get_dashboard_item_property_keys`. This returns a list of dashboard item property keys which are used to identify metadata stores on a given dashboard item (gadget).
…perty` Action * Added `get_dashboard_item_property` action. This gets a dashboard item (gadget) property by key. Typically these hold user specified metadata, or in the case of some gadgets the `config` key can be sent a payload to configure an otherwise unconfigured gadget.
…perty` Action * Allows the user to set the values of item properties on a given dashboard item (gadget). An example of this would be a configuration for a dashboard gadget that is configured with a `Filter Result` module.
…property` * Added `delete_dashboard_item_property`. Allows the user to delete a dashboard item property (like a config object on a filter module on a gadget).
…erty` * Added `update_dashboard_item_property` action. This differs from `set_dashboard_item_property` in that, it updates the existing object attributes, instead of simply replacing them. Good for updating specific fields on gadget configuration items.
…_refresh` * Added `update_dashboard_automatic_refresh` action. This let's the user set how often the dashboard refreshes in minutes.
Added tests for all of the new actions. Included some new fixtures as well for those tests. The report is as follows: ``` (st2) root@e74c68fe6ffa:/opt/stackstorm/packs.dev/jira# st2-run-pack-tests -j -t -c -p /opt/stackstorm/packs.dev/jira Running tests for pack: jira Activating virtualenv in /tmp/st2-pack-tests-virtualenvs/jira... ::/opt/stackstorm/packs.dev/jira/sensors/:/opt/stackstorm/packs.dev/jira/actions/:/opt/stackstorm/packs.dev/jira/actions/lib/:/opt/stackstorm/packs.dev/jira/etc/ WARNING: You are using pip version 20.3.3; however, version 24.0 is available. You should consider upgrading via the '/tmp/st2-pack-tests-virtualenvs/jira/bin/python -m pip install --upgrade pip' command. Running tests... test_add_gadget (tests.test_action_add_gadget.AddGadgetTests) ... passed test_copy_dashboard (tests.test_action_copy_dashboard.CopyDashboardTests) ... passed test_create_dashboard (tests.test_action_create_dashboard.CreateDashboardTests) ... passed test_delete_dashboard (tests.test_action_delete_dashboard.DeleteDashboardTests) ... passed test_delete_dashboard_item_property (tests.test_action_delete_dashboard_item_property.DeleteDashboardItemPropertyTest) ... passed test_get_available_gadgets (tests.test_action_get_available_gadgets.GetAvailableGadgetsTests) ... passed test_get_dashboard_gadgets (tests.test_action_get_dashboard_gadgets.GetDashboardGadgetsTest) ... passed test_get_dashboard_item_property (tests.test_action_get_dashboard_item_property.GetDashboardItemPropertyTests) ... passed test_get_dashboard_item_property_keys (tests.test_action_get_dashboard_item_property_keys.GetDashboardItemPropertyKeysTests) ... passed test_remove_gadget (tests.test_action_remove_gadget.RemoveGadgetTests) ... passed test_run_with_invalid_action (tests.test_action_run.RunTestCase) ... passed test_run_with_jira_exception (tests.test_action_run.RunTestCase) ... passed test_run_without_exception (tests.test_action_run.RunTestCase) ... passed test_transition_name_to_id (tests.test_action_run.RunTestCase) ... passed test_get_dashboard_item_property (tests.test_action_set_dashboard_item_property.SetDashboardItemPropertyTests) ... passed test_update_dashboard (tests.test_action_update_dashboard.UpdateDashboardTests) ... passed test_update_dashboard_automatic_refresh (tests.test_action_update_dashboard_automatic_refresh.UpdateJiraDashboardAutomaticRefreshActionDashboardTests) ... passed test_set_dashboard_item_property (tests.test_action_update_dashboard_property.UpdateDashboardItemPropertyTests) ... passed test_update_gadget (tests.test_action_update_gadget.UpdateGadgetTests) ... passed test_poll (tests.test_sensor_jira_sensor.JIRASensorTestCase) ... passed test_poll (tests.test_sensor_jira_sensor_for_apiv2.JIRASensorForAPIv2TestCase) ... passed TEST RESULT OUTPUT: Name Stmts Miss Cover ------------------------------------------------------------------- actions/add_field_value.py 8 8 0% actions/add_gadget.py 8 0 100% actions/attach_file_to_issue.py 10 10 0% actions/attach_files_to_issue.py 11 11 0% actions/bulk_link_issue.py 27 27 0% actions/comment_issue.py 8 8 0% actions/copy_dashboard.py 8 0 100% actions/create_dashboard.py 8 0 100% actions/create_issue.py 14 14 0% actions/delete_dashboard.py 8 0 100% actions/delete_dashboard_item_property.py 8 0 100% actions/get_available_gadgets.py 6 0 100% actions/get_dashboard_gadgets.py 6 0 100% actions/get_dashboard_item_property.py 6 0 100% actions/get_dashboard_item_property_keys.py 6 0 100% actions/get_issue.py 8 8 0% actions/get_issue_attachments.py 11 11 0% actions/get_issue_comments.py 11 11 0% actions/get_issue_links.py 8 8 0% actions/lib/__init__.py 0 0 100% actions/lib/base.py 41 21 49% actions/lib/formatters.py 57 57 0% actions/lib/utils.py 4 0 100% actions/link_issue.py 6 6 0% actions/remove_gadget.py 9 0 100% actions/run.py 21 3 86% actions/search_issues.py 10 10 0% actions/set_dashboard_item_property.py 6 0 100% actions/transition_issue.py 6 6 0% actions/update_dashboard.py 9 0 100% actions/update_dashboard_automatic_refresh.py 7 0 100% actions/update_dashboard_item_property.py 7 0 100% actions/update_field_value.py 8 8 0% actions/update_gadget.py 10 0 100% sensors/jira_sensor.py 97 45 54% sensors/jira_sensor_for_apiv2.py 96 45 53% ------------------------------------------------------------------- TOTAL 574 317 45% [success] 16.58% tests.test_action_run.RunTestCase.test_run_without_exception: 0.0253s [success] 6.88% tests.test_action_add_gadget.AddGadgetTests.test_add_gadget: 0.0105s [success] 5.61% tests.test_action_delete_dashboard_item_property.DeleteDashboardItemPropertyTest.test_delete_dashboard_item_property: 0.0086s [success] 5.45% tests.test_action_update_gadget.UpdateGadgetTests.test_update_gadget: 0.0083s [success] 5.38% tests.test_action_create_dashboard.CreateDashboardTests.test_create_dashboard: 0.0082s [success] 5.22% tests.test_action_get_available_gadgets.GetAvailableGadgetsTests.test_get_available_gadgets: 0.0080s [success] 5.22% tests.test_action_copy_dashboard.CopyDashboardTests.test_copy_dashboard: 0.0080s [success] 5.09% tests.test_action_update_dashboard_property.UpdateDashboardItemPropertyTests.test_set_dashboard_item_property: 0.0078s [success] 5.06% tests.test_action_delete_dashboard.DeleteDashboardTests.test_delete_dashboard: 0.0077s [success] 4.80% tests.test_action_set_dashboard_item_property.SetDashboardItemPropertyTests.test_get_dashboard_item_property: 0.0073s [success] 4.76% tests.test_action_get_dashboard_gadgets.GetDashboardGadgetsTest.test_get_dashboard_gadgets: 0.0073s [success] 4.68% tests.test_action_get_dashboard_item_property.GetDashboardItemPropertyTests.test_get_dashboard_item_property: 0.0071s [success] 4.66% tests.test_action_remove_gadget.RemoveGadgetTests.test_remove_gadget: 0.0071s [success] 4.64% tests.test_action_update_dashboard_automatic_refresh.UpdateJiraDashboardAutomaticRefreshActionDashboardTests.test_update_dashboard_automatic_refresh: 0.0071s [success] 4.45% tests.test_action_update_dashboard.UpdateDashboardTests.test_update_dashboard: 0.0068s [success] 4.09% tests.test_action_get_dashboard_item_property_keys.GetDashboardItemPropertyKeysTests.test_get_dashboard_item_property_keys: 0.0063s [success] 2.27% tests.test_action_run.RunTestCase.test_transition_name_to_id: 0.0035s [success] 2.25% tests.test_action_run.RunTestCase.test_run_with_jira_exception: 0.0034s [success] 1.90% tests.test_action_run.RunTestCase.test_run_with_invalid_action: 0.0029s [success] 0.51% tests.test_sensor_jira_sensor_for_apiv2.JIRASensorForAPIv2TestCase.test_poll: 0.0008s [success] 0.50% tests.test_sensor_jira_sensor.JIRASensorTestCase.test_poll: 0.0008s ----------------------------------------------------------------------------- 21 tests run in 0.159 seconds (21 tests passed) ``` All changes are covered at 100%.
* Updated `CHANGES.md` * Updated `README.md` * Bumped `pack` version. * Committed missed addition to `test/lib/actions.py`
The changes necessary for these pack updates have been merged into the `jira` package and that package has had a release to `pypi`.
@floatingstatic Hey there! The changes I made were pulled into the |
@jpavlav Looks good. It seems CI is stuck. Let me see if I can figure out how to fix that so we can merge. Thanks! |
@jpavlav i think the github action workflow was disabled. I enabled it but wondering if you might be able to try a force-push to see if it will run after the next push. |
@floatingstatic These are failing because these tests are attempting to run on |
Looks like there is a PR open to address this: |
Thanks, yeah I asked someone from TSC to have a look. Unfortunately my access is somewhat limited as maintainer. |
It looks like the jira requirement is too high for python3.6. |
@nzlosh Yeah, but as |
Oh heh, looks like you're the one who authored that change @nzlosh 😄 |
Yes, Python 3.6 is currently a sore point. We're dropping support in St2 v3.9, but for now St2 3.8.1 (current stable) supports py3.6 / 3.8 instances running in the wild. You can pull py3.6 now but it may cause some users to be unable to upgrade the pack until they move onto a new version of St2. I'd recommend bumping the pack version to 4.0 to signal break changes for some users. |
@floatingstatic I'll go ahead and bump the pack version and then maybe push that up with a change to point the workflow at the branch that kicks 3.6 out. Does that sound alright? |
Had to update some tests/class references/method calls to match the final interface over in the `jira` lib. * `Gadget` renamed to `DashboardGadget`. * `gadgets` method renamed to `all_dashboard_gadgets`. * Update `%s/update_dashboard_automatic_refresh_seconds/update_dashboard/automatic_refresh_minutes`
@jpavlav sounds good. We can bump the pack to 3.0.0. |
The latest versions of the `jira` library require `python >= 3.8`. In light of the fact that `StackStorm` is going to shed support for `python3.6` (which is EOL https://www.python.org/downloads/release/python-360/) this pack is updating to stop testing `3.6` and bumping the pack to the next major version to signal a potentially breaking change.
Cutting this down to the lowest common denominator in terms of working tests for `StackStorm`. `3.11` is breaking on installing some dev dependencies: ``` ERROR: Command errored out with exit status 1: command: /home/runner/virtualenv/bin/python /home/runner/virtualenv/lib/python3.11/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmp_5anenlq cwd: /tmp/pip-install-mj_5c6wi/pyyaml_3973c6602d81416aa8ada0b8d43f48a5 Complete output (54 lines): running egg_info writing lib3/PyYAML.egg-info/PKG-INFO writing dependency_links to lib3/PyYAML.egg-info/dependency_links.txt writing top-level names to lib3/PyYAML.egg-info/top_level.txt Traceback (most recent call last): File "/home/runner/virtualenv/lib/python3.11/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module> main() File "/home/runner/virtualenv/lib/python3.11/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main json_out['return_val'] = hook(**hook_input['kwargs']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/runner/virtualenv/lib/python3.11/site-packages/pip/_vendor/pep517/_in_process.py", line 114, in get_requires_for_build_wheel return hook(config_settings) ^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel return self._get_build_requires(config_settings, requirements=['wheel']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires self.run_setup() File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup exec(code, locals()) File "<string>", line 271, in <module> File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/__init__.py", line 104, in setup return distutils.core.setup(**attrs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup return run_commands(dist) ^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands dist.run_commands() File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands self.run_command(cmd) File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/dist.py", line 967, in run_command super().run_command(command) File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/command/egg_info.py", line 321, in run self.find_sources() File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/command/egg_info.py", line 329, in find_sources mm.run() File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/command/egg_info.py", line 550, in run self.add_defaults() File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/command/egg_info.py", line 588, in add_defaults sdist.add_defaults(self) File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/command/sdist.py", line 102, in add_defaults super().add_defaults() File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/_distutils/command/sdist.py", line 251, in add_defaults self._add_defaults_ext() File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/_distutils/command/sdist.py", line 336, in _add_defaults_ext self.filelist.extend(build_ext.get_source_files()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<string>", line 201, in get_source_files File "/tmp/pip-build-env-e17od6z2/overlay/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 107, in __getattr__ raise AttributeError(attr) AttributeError: cython_sources ---------------------------------------- ERROR: Command errored out with exit status 1: /home/runner/virtualenv/bin/python /home/runner/virtualenv/lib/python3.11/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmp_5anenlq Check the logs for full command output. WARNING: You are using pip version 20.3.3; however, version 24.0 is available. You should consider upgrading via the '/home/runner/virtualenv/bin/python -m pip install --upgrade pip' command. ```
…rt Paths This PR updates the CHANGES.md to include the deprecation of `python 3.6`. Further, it updates the paths to the `utils` function `remove_empty_attributes`. The test set up puts the
Turns out the `.gitignore` ignores the `lib/` dir. This applies to the `lib` dir within the `actions` dir. Caused me to miss the fact that I didn't actually commit the `utils.py` file.
@nzlosh I do not have access to the repo settings page to remove python 3.6 status check as a requirement for merging. Can you assist? Thanks! |
I just realized the `release.yaml` GHA also uses the upstream `pack-build_and_test` workflow. It would have failed when an attempt was released because of our now deprecating `python 3.6`. Updating this to mirror the `build_and_test.yaml` workflow.
@floatingstatic I've bumped the test requirement from 3.6 to 3.8. You're clear to merge |
Thanks @floatingstatic and @nzlosh ! |
I realize there are a lot of changes here, but each commit should represent a much more digestible bit of code changes for review.
create_dashboard
actionadd_gadget
action. Allows the user to add a gadget to anexisting dashboard.
update_dashboard
action. It accepts parameters for the update,fetches the dashboard by
id
, runs theupdate
method on thedashboard
resource and returns it'sraw
result (json
result fromthe API)
update_gadget
action to allow a user to modify an existinggadget on a dashboard.
id
. Thejira
library onlyreturns the raw
requests
response in this case. The return is adictionary containing the response status code and any text that was
included with the response. The action fails if any status code other
than 204 is produced.
remove_gadget
action to allow users to delete gadgets fromdashboards.
get_gadgets
action just pulls the available list of gadgets fromthe
jira
instance. This commit also includes a fix to the descriptionof the
remove_gadget
yaml.get_dashboard_gadgets
action differs from theget_available_gadgets
action in that, it targets a specific dashboardand returns only the gadgets present on that dashboard.
copy_dashboard
action.update_dashboard
andcreate_dashboard
yaml files.
get_dashboard_item_property_keys
. This returns a list ofdashboard item property keys which are used to identify metadata stores
on a given dashboard item (gadget).
get_dashboard_item_property_keys
. This returns a list ofdashboard item property keys which are used to identify metadata stores
on a given dashboard item (gadget).
dashboard item (gadget). An example of this would be a configuration for
a dashboard gadget that is configured with a
Filter Result
module.delete_dashboard_item_property
. Allows the user to delete adashboard item property (like a config object on a filter module on a
gadget).
update_dashboard_item_property
action. This differs fromset_dashboard_item_property
in that, it updates the existing objectattributes, instead of simply replacing them. Good for updating specific
fields on gadget configuration items.
update_dashboard_automatic_refresh
action. This let's the userset how often the dashboard refreshes in minutes.
Added tests for all of the new actions. Included some new fixtures as
well for those tests. The report is as follows:
All changes are covered at 100%.
CHANGES.md
README.md
pack
version.test/lib/actions.py