Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions create-jira-release-ticket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ This action depends on:
| `short-description` | A short description for the release | Yes | - |
| `jira-project-key` | The key of the Jira project (e.g., SONARIAC). Can also be set via `JIRA_PROJECT_KEY` environment variable | No* | - |
| `version` | The version being released (e.g., 11.44.2), or leave empty to use the release version | No | - |
| `due-date` | Due date of the release in `yyyy-mm-dd` format, for example '2029-12-24' | No | - |
| `use-jira-sandbox` | Use the sandbox server instead of the production Jira. Can also be controlled via `USE_JIRA_SANDBOX` environment variable | No | `false` |
| `documentation-status` | Status of the documentation | No | `N/A` |
| `rule-props-changed` | Whether rule properties have changed (`Yes` or `No`) | No | `No` |
Expand Down
30 changes: 20 additions & 10 deletions create-jira-release-ticket/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ inputs:
description: 'The key of the project (e.g., SONARIAC). Required if JIRA_PROJECT_KEY env var is not set.'
version:
description: 'The version being released (e.g., 11.44.2), or leave empty to use the release version.'
due-date:
description: 'Due date of the release, for example "2029-12-24".'
use-jira-sandbox:
description: "Use the sandbox server instead of the production Jira."
documentation-status:
Expand Down Expand Up @@ -73,8 +75,15 @@ runs:
env:
JIRA_USER: ${{ fromJSON(steps.secrets.outputs.vault).JIRA_USER }}
JIRA_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).JIRA_TOKEN }}
JIRA_PROD_URL: "https://sonarsource.atlassian.net/"
JIRA_SANDBOX_URL: "https://sonarsource-sandbox-608.atlassian.net/"
PROJECT_NAME: ${{ inputs.project-name }}
RELEASE_VERSION: ${{ inputs.version || env.RELEASE_VERSION }}
SHORT_DESCRIPTION: ${{ inputs.short-description }}
DUE_DATE: ${{ inputs.due-date }}
JIRA_URL: ${{ ((inputs.use-jira-sandbox || env.USE_JIRA_SANDBOX) == 'true') && 'https://sonarsource-sandbox-608.atlassian.net/' || 'https://sonarsource.atlassian.net/' }}
DOCUMENTATION_STATUS: ${{ inputs.documentation-status }}
RULE_PROPS_CHANGED: ${{ inputs.rule-props-changed }}
JIRA_RELEASE_URL: ${{ inputs.jira-release-url || env.JIRA_RELEASE_URL }}
SONARLINT_CHANGELOG: ${{ inputs.sonarlint-changelog }}
run: |
PROJECT_KEY="${{ inputs.jira-project-key || env.JIRA_PROJECT_KEY }}"

Expand All @@ -85,14 +94,15 @@ runs:

python ${{ github.action_path }}/create_release_ticket.py \
--project-key="$PROJECT_KEY" \
--project-name="${{ inputs.project-name }}" \
--version="${{ inputs.version || env.RELEASE_VERSION }}" \
--short-description="${{ inputs.short-description }}" \
--jira-url="${{ ((inputs.use-jira-sandbox || env.USE_JIRA_SANDBOX) == 'true') && env.JIRA_SANDBOX_URL || env.JIRA_PROD_URL }}" \
--documentation-status="${{ inputs.documentation-status }}" \
--rule-props-changed="${{ inputs.rule-props-changed }}" \
--jira-release-url="${{ inputs.jira-release-url || env.JIRA_RELEASE_URL }}" \
--sonarlint-changelog="${{ inputs.sonarlint-changelog }}" >> $GITHUB_OUTPUT
--project-name="$PROJECT_NAME" \
--version="$RELEASE_VERSION" \
--due-date="$DUE_DATE" \
--short-description="$SHORT_DESCRIPTION" \
--jira-url="$JIRA_URL" \
--documentation-status="$DOCUMENTATION_STATUS" \
--rule-props-changed="$RULE_PROPS_CHANGED" \
--jira-release-url="$JIRA_RELEASE_URL" \
--sonarlint-changelog="$SONARLINT_CHANGELOG" >> $GITHUB_OUTPUT

- name: Start Progress on Release Ticket
if: ${{ inputs.start-progress == 'true' }}
Expand Down
2 changes: 2 additions & 0 deletions create-jira-release-ticket/create_release_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def create_release_ticket(jira_client, args, link_to_release_notes):
'project': 'REL',
'issuetype': 'Ask for release',
'summary': f'{args.project_name} {args.version}',
'duedate': args.due_date,
CUSTOM_FIELDS['SHORT_DESCRIPTION']: args.short_description,
CUSTOM_FIELDS['LINK_TO_RELEASE_NOTES']: link_to_release_notes,
CUSTOM_FIELDS['DOCUMENTATION_STATUS']: args.documentation_status,
Expand Down Expand Up @@ -107,6 +108,7 @@ def main():
help="Whether rule properties have changed.")
parser.add_argument("--jira-release-url", default="", help="The URL to the Jira release notes page.")
parser.add_argument("--sonarlint-changelog", default="", help="The SonarLint changelog content.")
parser.add_argument("--due-date", default="", help="Due date of the release, for example '2029-12-24'.")

args = parser.parse_args()

Expand Down
6 changes: 5 additions & 1 deletion create-jira-release-ticket/test_create_release_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def test_create_release_ticket_with_all_fields(self):
args.documentation_status = 'Ready'
args.rule_props_changed = 'Yes'
args.sonarlint_changelog = 'Test changelog'
args.due_date = '2029-12-24'

release_url = 'https://jira.com/release/notes'

Expand All @@ -85,6 +86,7 @@ def test_create_release_ticket_with_all_fields(self):
self.assertEqual(call_args['project'], 'REL')
self.assertEqual(call_args['issuetype'], 'Ask for release')
self.assertEqual(call_args['summary'], 'TestProject 1.2.3')
self.assertEqual(call_args['duedate'], '2029-12-24')
self.assertEqual(call_args['customfield_10146'], 'Test release') # SHORT_DESCRIPTION
self.assertEqual(call_args['customfield_10145'], release_url) # LINK_TO_RELEASE_NOTES
self.assertEqual(call_args['customfield_10147'], 'Ready') # DOCUMENTATION_STATUS
Expand Down Expand Up @@ -163,11 +165,12 @@ def test_main_successful_ticket_creation(self, mock_stderr, mock_stdout, mock_cr
'--project-name', 'Test Project',
'--version', '1.0.0',
'--short-description', 'Test release',
'--due-date', '2029-12-24',
Comment thread
Krosovok marked this conversation as resolved.
Resolved
'--jira-url', 'https://sandbox.jira.com',
'--jira-release-url', 'https://sandbox.jira.com/release/notes',
'--documentation-status', 'Ready',
'--rule-props-changed', 'Yes',
'--sonarlint-changelog', 'Some changelog'
'--sonarlint-changelog', 'Some changelog',
])
@patch('create_release_ticket.get_jira_instance')
@patch('create_release_ticket.create_release_ticket')
Expand Down Expand Up @@ -201,6 +204,7 @@ def test_main_with_all_parameters(self, mock_stderr, mock_stdout, mock_create_ti
self.assertEqual(args.documentation_status, 'Ready')
self.assertEqual(args.rule_props_changed, 'Yes')
self.assertEqual(args.sonarlint_changelog, 'Some changelog')
self.assertEqual(args.due_date, '2029-12-24')

stderr_output = mock_stderr.getvalue()
self.assertIn('Using release URL: https://sandbox.jira.com/release/notes', stderr_output)
Expand Down
Loading