Skip to content

GHA-212 Fix CI tests for get-jira-release-notes after JET taxonomy migration #122

GHA-212 Fix CI tests for get-jira-release-notes after JET taxonomy migration

GHA-212 Fix CI tests for get-jira-release-notes after JET taxonomy migration #122

name: Test Get Jira Release Notes Action
on:
workflow_call:
pull_request:
paths:
- 'get-jira-release-notes/**'
- '.github/workflows/test-get-jira-release-notes.yml'
push:
branches:
- branch-*
paths:
- 'get-jira-release-notes/**'
- '.github/workflows/test-get-jira-release-notes.yml'
workflow_dispatch:
jobs:
unit-tests:
name: Run Unit Tests on get-jira-release-notes Module
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.10'
- name: Install dependencies
run: |
cd get-jira-release-notes
pip install -r requirements.txt
pip install pytest pytest-cov
- name: Run unit tests
run: |
cd get-jira-release-notes
python -m pytest test_get_jira_release_notes.py -v --cov=get_jira_release_notes --cov-report=term-missing
test-action-inputs:
name: Test Action Input Handling and Environment Variable Outputs
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Test action with missing inputs and env vars (should fail)
id: test_missing_all
continue-on-error: true
uses: ./get-jira-release-notes
- name: Verify missing inputs test failed
if: steps.test_missing_all.outcome == 'success'
run: |
echo "Expected action to fail with missing inputs and env vars, but it succeeded"
exit 1
- name: Test action with only env vars
id: test_env_vars
continue-on-error: true
uses: ./get-jira-release-notes
env:
JIRA_PROJECT_KEY: 'TEST'
JIRA_VERSION_NAME: '1.0.0'
# This should fail due to missing Jira credentials, but validation should pass
- name: Test action with mixed inputs (input overrides env)
id: test_mixed
continue-on-error: true
uses: ./get-jira-release-notes
with:
jira-project-key: 'OVERRIDE' # This should override JIRA_PROJECT_KEY
env:
JIRA_PROJECT_KEY: 'TEST'
JIRA_VERSION_NAME: '1.0.0'
# This should fail due to missing Jira credentials, but validation should pass
- name: Test environment variable outputs (mock test)
run: |
# Create a mock script that simulates the Python output
cat > mock_output.py << 'EOF'
print("jira-release-url=https://test.atlassian.net/projects/TEST/versions/123/tab/release-report-all-issues")
print("jira-release-issue-filter-url=https://test.atlassian.net/issues/?jql=fixVersion%3D123")
print("release-notes<<EOF")
print("# Release notes - Test Project - 1.0.0")
print("")
print("### Bug")
print("[TEST-1](https://test.atlassian.net/browse/TEST-1) Fix test issue")
print("")
print("EOF")
EOF
# Test the tee + sed pipeline
python mock_output.py | tee test_output.txt | sed 's/^jira-release-url=/JIRA_RELEASE_URL=/' | sed 's/^jira-release-issue-filter-url=/JIRA_RELEASE_ISSUE_FILTER_URL=/' | sed 's/^release-notes<</RELEASE_NOTES<</' > test_env.txt
# Verify outputs were created correctly
echo "=== GitHub Output format ==="
cat test_output.txt
echo ""
echo "=== Environment Variable format ==="
cat test_env.txt
# Verify transformations
if grep -q "JIRA_RELEASE_URL=https://test.atlassian.net" test_env.txt; then
echo "✅ JIRA_RELEASE_URL transformation works"
else
echo "❌ JIRA_RELEASE_URL transformation failed"
exit 1
fi
if grep -q "JIRA_RELEASE_ISSUE_FILTER_URL=https://test.atlassian.net/issues" test_env.txt; then
echo "✅ JIRA_RELEASE_ISSUE_FILTER_URL transformation works"
else
echo "❌ JIRA_RELEASE_ISSUE_FILTER_URL transformation failed"
exit 1
fi
if grep -q "RELEASE_NOTES<<EOF" test_env.txt; then
echo "✅ RELEASE_NOTES transformation works"
else
echo "❌ RELEASE_NOTES transformation failed"
exit 1
fi
- name: Test action parameter validation
run: |
echo "✅ Action correctly validates required parameters and handles env vars"
test-default-issue-categories:
name: Test Action Integration with Default Issue Categories
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get release notes from a sandbox project
id: test-sandbox
uses: ./get-jira-release-notes
with:
jira-project-key: 'SONARIAC'
jira-version-name: '1.52'
use-jira-sandbox: 'true'
- name: Output results
run: |
echo "Jira Release URL: ${{ steps.test-sandbox.outputs.jira-release-url }}"
echo "Jira Release Issue Filter URL: ${{ steps.test-sandbox.outputs.jira-release-issue-filter-url }}"
echo "Release Notes:"
echo "${{ steps.test-sandbox.outputs.release-notes }}"
echo "Jira Release Notes:"
echo "${{ steps.test-sandbox.outputs.jira-release-notes }}"
- name: Verify Jira Release URL
run: |
if [[ "${{ steps.test-sandbox.outputs.jira-release-url }}" != https://sonarsource-sandbox-608.atlassian.net/projects/SONARIAC/versions/*/tab/release-report-all-issues ]]; then
echo "❌ Jira Release URL format is incorrect"
exit 1
else
echo "✅ Jira Release URL format is correct"
fi
- name: Verify Jira Release Issue Filter URL
run: |
if [[ "${{ steps.test-sandbox.outputs.jira-release-issue-filter-url }}" != https://sonarsource-sandbox-608.atlassian.net/issues/?jql=fixVersion%3D23819 ]]; then
echo "❌ Jira Release Issue Filter URL is incorrect"
echo "Expected: https://sonarsource-sandbox-608.atlassian.net/issues/?jql=fixVersion%3D23819"
echo "Got: ${{ steps.test-sandbox.outputs.jira-release-issue-filter-url }}"
exit 1
else
echo "✅ Jira Release Issue Filter URL is correct"
fi
- name: Verify Release Notes Content
run: |
if grep -q "### Feature" <<< "${{ steps.test-sandbox.outputs.release-notes }}"; then
echo "✅ Release Notes contain default issue categories"
else
echo "❌ Release Notes are missing some default issue categories"
exit 1
fi
if grep -q "### Maintenance" <<< "${{ steps.test-sandbox.outputs.release-notes }}"; then
echo "❌ Release Notes should not contain Maintenance category with default settings"
exit 1
else
echo "✅ Release Notes correctly exclude Maintenance category"
fi
- name: Verify Jira Release Notes Content
run: |
if grep -q "h3. Feature" <<< "${{ steps.test-sandbox.outputs.jira-release-notes }}"; then
echo "✅ Jira Release Notes contain default issue category"
else
echo "❌ Jira Release Notes are missing some default issue categories"
exit 1
fi
if grep -q "h3. Maintenance" <<< "${{ steps.test-sandbox.outputs.jira-release-notes }}"; then
echo "❌ Jira Release Notes should not contain Maintenance category with default settings"
exit 1
else
echo "✅ Jira Release Notes correctly exclude Maintenance category"
fi
test-custom-issue-categories:
name: Test Action Integration with Custom Issue Categories
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get release notes from a sandbox project with custom issue types
id: test-sandbox-custom
uses: ./get-jira-release-notes
with:
jira-project-key: 'SONARIAC'
jira-version-name: '1.52'
use-jira-sandbox: 'true'
issue-types: 'Maintenance,Bug,Security'
- name: Output results
run: |
echo "Jira Release URL: ${{ steps.test-sandbox-custom.outputs.jira-release-url }}"
echo "Release Notes:"
echo "${{ steps.test-sandbox-custom.outputs.release-notes }}"
echo "Jira Release Notes:"
echo "${{ steps.test-sandbox-custom.outputs.jira-release-notes }}"
- name: Verify Release Notes Content
run: |
if grep -q "### Maintenance" <<< "${{ steps.test-sandbox-custom.outputs.release-notes }}"; then
echo "✅ Release Notes contain Maintenance category as specified"
else
echo "❌ Release Notes are missing Maintenance category"
exit 1
fi
if grep -q "### Feature" <<< "${{ steps.test-sandbox-custom.outputs.release-notes }}"; then
echo "❌ Release Notes should not contain Feature category with custom settings"
exit 1
else
echo "✅ Release Notes correctly exclude Feature category"
fi
- name: Verify Jira Release Notes Content
run: |
if grep -q "h3. Maintenance" <<< "${{ steps.test-sandbox-custom.outputs.jira-release-notes }}"; then
echo "✅ Jira Release Notes contain Maintenance category as specified"
else
echo "❌ Jira Release Notes are missing Maintenance category"
exit 1
fi
if grep -q "h3. Feature" <<< "${{ steps.test-sandbox-custom.outputs.jira-release-notes }}"; then
echo "❌ Jira Release Notes should not contain Feature category with custom settings"
exit 1
else
echo "✅ Jira Release Notes correctly exclude Feature category"
fi
test-default-issue-categories-deprecated-taxonomy:
name: Test Action Integration with Default Issue Categories on project with deprecated Jira taxonomy
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get release notes from a sandbox project
id: test-sandbox
uses: ./get-jira-release-notes
with:
jira-project-key: 'SONARPHP'
jira-version-name: '3.49'
use-jira-sandbox: 'true'
- name: Output results
run: |
echo "Jira Release URL: ${{ steps.test-sandbox.outputs.jira-release-url }}"
echo "Jira Release Issue Filter URL: ${{ steps.test-sandbox.outputs.jira-release-issue-filter-url }}"
echo "Release Notes:"
echo "${{ steps.test-sandbox.outputs.release-notes }}"
echo "Jira Release Notes:"
echo "${{ steps.test-sandbox.outputs.jira-release-notes }}"
- name: Verify Jira Release URL
run: |
if [[ "${{ steps.test-sandbox.outputs.jira-release-url }}" != https://sonarsource-sandbox-608.atlassian.net/projects/SONARPHP/versions/*/tab/release-report-all-issues ]]; then
echo "❌ Jira Release URL format is incorrect"
exit 1
else
echo "✅ Jira Release URL format is correct"
fi
- name: Verify Jira Release Issue Filter URL
run: |
if [[ "${{ steps.test-sandbox.outputs.jira-release-issue-filter-url }}" != https://sonarsource-sandbox-608.atlassian.net/issues/?jql=fixVersion%3D22169 ]]; then
echo "❌ Jira Release Issue Filter URL is incorrect"
echo "Expected: https://sonarsource-sandbox-608.atlassian.net/issues/?jql=fixVersion%3D22169"
echo "Got: ${{ steps.test-sandbox.outputs.jira-release-issue-filter-url }}"
exit 1
else
echo "✅ Jira Release Issue Filter URL is correct"
fi
- name: Verify Release Notes Content
run: |
if grep -q "### Feature" <<< "${{ steps.test-sandbox.outputs.release-notes }}"; then
echo "✅ Release Notes contain default issue categories"
else
echo "❌ Release Notes are missing some default issue categories"
exit 1
fi
if grep -q "### Maintenance" <<< "${{ steps.test-sandbox.outputs.release-notes }}"; then
echo "❌ Release Notes should not contain Maintenance category with default settings (no such issues in SONARPHP 3.49)"
exit 1
else
echo "✅ Release Notes correctly exclude Maintenance category"
fi
- name: Verify Jira Release Notes Content
run: |
if grep -q "h3. Feature" <<< "${{ steps.test-sandbox.outputs.jira-release-notes }}"; then
echo "✅ Jira Release Notes contain default issue category"
else
echo "❌ Jira Release Notes are missing some default issue categories"
exit 1
fi
if grep -q "h3. Maintenance" <<< "${{ steps.test-sandbox.outputs.jira-release-notes }}"; then
echo "❌ Jira Release Notes should not contain Maintenance category with default settings (no such issues in SONARPHP 3.49)"
exit 1
else
echo "✅ Jira Release Notes correctly exclude Maintenance category"
fi
test-custom-issue-categories-deprecated-taxonomy:
name: Test Action Integration with Custom Issue Categories on project with deprecated Jira taxonomy
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get release notes from a sandbox project with custom issue types
id: test-sandbox-custom
uses: ./get-jira-release-notes
with:
jira-project-key: 'SONARPHP'
jira-version-name: '3.49'
use-jira-sandbox: 'true'
issue-types: 'Feature,Bug,Maintenance'
- name: Output results
run: |
echo "Jira Release URL: ${{ steps.test-sandbox-custom.outputs.jira-release-url }}"
echo "Release Notes:"
echo "${{ steps.test-sandbox-custom.outputs.release-notes }}"
echo "Jira Release Notes:"
echo "${{ steps.test-sandbox-custom.outputs.jira-release-notes }}"
- name: Verify Release Notes Content
run: |
if grep -q "### Feature" <<< "${{ steps.test-sandbox-custom.outputs.release-notes }}"; then
echo "✅ Release Notes contain Feature category as specified"
else
echo "❌ Release Notes are missing Feature category"
exit 1
fi
if grep -q "### Improvement" <<< "${{ steps.test-sandbox-custom.outputs.release-notes }}"; then
echo "❌ Release Notes should not contain Improvement category with custom settings"
exit 1
else
echo "✅ Release Notes correctly exclude Improvement category"
fi
- name: Verify Jira Release Notes Content
run: |
if grep -q "h3. Feature" <<< "${{ steps.test-sandbox-custom.outputs.jira-release-notes }}"; then
echo "✅ Jira Release Notes contain Feature category as specified"
else
echo "❌ Jira Release Notes are missing Feature category"
exit 1
fi
if grep -q "h3. Improvement" <<< "${{ steps.test-sandbox-custom.outputs.jira-release-notes }}"; then
echo "❌ Jira Release Notes should not contain Improvement category with custom settings"
exit 1
else
echo "✅ Jira Release Notes correctly exclude Improvement category"
fi