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

Fix using str as issue type with create_issue when issue type with that name exists in many projects #1448

Conversation

dblanchette
Copy link
Contributor

Fixes #1444

#1445 does solve the issue when providing the ID, but it is still not possible, as it was before, to provide a string like so:

jira.create_issue(
    fields={
        "project": "PROJECTKEY",
        "issuetype": "User Story",
        "summary": "test",
    }
)

This is because issue_type_by_name does not take the project into consideration and thus will only work if the issuetype name exists only once across all projects in the Jira instance.

This situation is more frequent when using the team-managed projects that use their own issue types instead of sharing the standard ones.

I was not able to setup CI unfortunately, but I tested by calling my new code from another project which exhibited #1444

Copy link
Contributor

@adehad adehad left a comment

Choose a reason for hiding this comment

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

Awesome stuff, one minor comment

I'll also try and write up a test case for this before we merge (want to set a better standard in this project moving forward)

There is a devcontainer that might help you automagically get setup with CI in case you want to have a go too.

@adehad adehad added feature and removed bug labels Aug 8, 2022
@github-actions github-actions bot added the bug label Aug 8, 2022
@dblanchette
Copy link
Contributor Author

I am sharing my experience in setting up the CI for your information/posterity below. I am on Ubuntu 20.04

It's great that you are working on improving the project quality. Thank you very much for the quick replies and work.

I am running the container with docker run -it -p 2990:2990 --name jira addono/jira-software-standalone (Removed -d to see what was going on). The instance freezes up after a while.

As for running tox, I get weird errors

configuration error: `project` must contain ['name'] properties
/home/dblanchette/repos/jira/.tox/py310/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py:125: _InvalidFile: The given `pyproject.toml` file is invalid and would be ignored.
    !!


    ############################
    # Invalid `pyproject.toml` #
    ############################

    Any configurations in `pyproject.toml` will be ignored.
    Please note that future releases of setuptools will halt the build process
    if an invalid file is given.

    To prevent setuptools from considering `pyproject.toml` please
    DO NOT include the `[project]` or `[tool.setuptools]` tables in your file.
    

!!
    
  if _skip_bad_config(project_table, orig_setuptools_table, dist)

Also:

jira 3.3.3.dev3+g81d5127.d20220808 requires defusedxml, which is not installed.
jira 3.3.3.dev3+g81d5127.d20220808 requires packaging, which is not installed.
jira 3.3.3.dev3+g81d5127.d20220808 requires requests, which is not installed.
jira 3.3.3.dev3+g81d5127.d20220808 requires requests-oauthlib, which is not installed.
jira 3.3.3.dev3+g81d5127.d20220808 requires requests-toolbelt, which is not installed.
jira 3.3.3.dev3+g81d5127.d20220808 requires typing-extensions, which is not installed.

(I thought tox would install requirements by itself)

And then:

ERROR: InvocationError for command /home/dblanchette/repos/jira/.tox/py310/bin/python -m pip check (exited with code 1)
On branch fix/create-issue-issue-type-exists-several-projects
Your branch is up to date with 'coveord/fix/create-issue-issue-type-exists-several-projects'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   tox.ini

no changes added to commit (use "git add" and/or "git commit -a")
ERROR: Git reported dirty status. Git should never report dirty status at the end of testing, regardless if status is passed, failed or aborted.

This seems weird to me as it is normal that I have modified files since I am working on the code. This happens even if I run tox after checking out the repo without changing anything else.

I was able to run the tests in the following manner:

  • sudo apt install libkrb5-dev (I was getting an error with krb5-config otherwise)
  • Commented out git clean -xdf jira tests and python -m pip check in tox.ini, under testenv.commands
  • Added python -m pip install -r constraints.txt after the lines I commented out above

After that, I was able to run the Jira instance container, wait for it to boot and then tox -e py39 -- tests/resources/test_issue.py -k test_create_issue_with_issue_type_name

@dblanchette dblanchette requested a review from adehad August 9, 2022 17:36
@dblanchette
Copy link
Contributor Author

I don't know why CI is failing, it does not seem related to my changes

Copy link
Contributor

@adehad adehad left a comment

Choose a reason for hiding this comment

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

I don't know why CI is failing, it does not seem related to my changes

yup don't worry about that, just a problem with github itself, we can't share secrets to pull requests so that fails

Test case looks good, ideally we would want a case where we have two issue types for different projects, but we don't have python functions for that yet, so just some technical debt we have for now

Thanks for sharing you troubles with the devcontainer, I really need to get to writing a page on using it, can I confirm if those dependencies needed to be installed inside the container?

@adehad adehad merged commit fdebf2e into pycontribs:main Aug 9, 2022
@dblanchette
Copy link
Contributor Author

Thanks for merging!

Thanks for sharing you troubles with the devcontainer, I really need to get to writing a page on using it, can I confirm if those dependencies needed to be installed inside the container?

Are we talking about the same thing? I just ran the container jira addono/jira-software-standalone manually on the side. The dependencies I installed were for the Python environment, tox did not seem to want to cooperate.

@adehad
Copy link
Contributor

adehad commented Aug 9, 2022

Sorry my bad, I was thinking of: https://github.com/pycontribs/jira/blob/main/.devcontainer/Dockerfile

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.

Issue type '{name}' appears more than once on create_issue
2 participants