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

chore: migration from BitBucket #4

Merged
merged 1 commit into from
Jul 8, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/maven-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
run: echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
- name: Publish to Maven Central
if: ${{ !endsWith(steps.artefact_version.outputs.version, '-SNAPSHOT') && github.ref == 'refs/heads/main' }}
run: mvn --batch-mode deploy -P gpg-sign -P nexus-staging
run: mvn --batch-mode deploy -P gpg-sign -P nexus-staging -Dnexus-staging-maven-plugin.autoReleaseAfterClose=false
- name: Publish to GitHub Packages
if: ${{ !endsWith(steps.artefact_version.outputs.version, '-SNAPSHOT') && github.ref == 'refs/heads/main' }}
run: mvn --batch-mode deploy -P gpg-sign -P deploy-github-packages
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ replay_pid*
target/
*.iml
dependency-reduced-pom.xml

src/main/resources/webapp/*-admin/html/about.html
README.html
46 changes: 46 additions & 0 deletions .scripts/convert-readme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

set -e

# Check if a command is installed
function check_command() {
if ! command -v "$1" &> /dev/null; then
echo -e "\033[0;31m $1 is not installed! \033[0m" >&2
echo -e "\033[0;31m Help for About page will not be generated! \033[0m" >&2

if [ -n "$FAIL_ON_CHECK_COMMANDS" ]; then
exit 1
else
exit 0
fi
fi
}

# Check if required commands are installed
check_command jq
check_command curl
check_command awk

INPUT_FILE="${1:-README.md}"
OUTPUT_FILE="${2:-README.html}"

# Convert the markdown file to a JSON payload
JSON_PAYLOAD=$(jq -R -s '{"mode": "gfm", "text": .}' < "$INPUT_FILE")

# Send the JSON payload to the GitHub API
CURL_OUTPUT=$(curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/markdown \
-d "$JSON_PAYLOAD")

# Process the curl output with awk to remove the Build, Installation and Changelog sections
MODIFIED_CONTENT=$(echo "$CURL_OUTPUT" | awk '
/<h2>Build<\/h2>/ {skip=1; next}
/<h2>Polarion configuration<\/h2>/ {skip=0}
/<h2>Changelog<\/h2>/ {skip=1; next}
!skip')

# Write the modified content to the output file
echo "$MODIFIED_CONTENT" > "$OUTPUT_FILE"
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Changelog before migration to conventional commits

| Version | Changes |
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| v1.4.0 | About page help now is generating based on README.md |
| v1.3.1 | Converted JAX-RS controllers, filters and exception mappers to singletons |
| v1.3.0 | About page extended with help and icon |
| v1.2.0 | * Refactoring using field-related features from generic<br/> * Update maven dependencies<br/> * Delimited parameters fix<br/> * Test case result error messages support |
| v1.1.0 | Added mandatory testRunTemplateId parameter |
| v1.0.0 | Initial release |
135 changes: 126 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Polarion ALM extension to <...>
# Cucumber Integration Extension for Polarion ALM

This Polarion extension is designed to integrate BDD process into Polarion.
It provides the almost same functionality as Xray plugin for Jira:
- Cucumber feature tracked as WorkItem attachment and can be edited using Gherkin editor
- Cucumber features can be downloaded as .zip file according to provided criteria
- Execution results can be imported as Test Run into Polarion

This Polarion extension provides possibility to <...>
## Build

This extension can be produced using maven:
Expand All @@ -10,8 +15,8 @@ mvn clean package

## Installation to Polarion

To install the extension to Polarion `ch.sbb.polarion.extension.<extension_name>-<version>.jar`
should be copied to `<polarion_home>/polarion/extensions/ch.sbb.polarion.extension.<extension_name>/eclipse/plugins`
To install the extension to Polarion `ch.sbb.polarion.extension.cucumber-<version>.jar`
should be copied to `<polarion_home>/polarion/extensions/ch.sbb.polarion.extension.cucumber/eclipse/plugins`
It can be done manually or automated using maven build:
```bash
mvn clean install -P install-to-local-polarion
Expand All @@ -22,15 +27,127 @@ Changes only take effect after restart of Polarion.

## Polarion configuration

<...>
### Cucumber feature editor to appear on Test Case page

1. Open a project which Test Case pages should display the editor
2. On the top of the project's navigation pane click ⚙ (Actions) ➙ 🔧 Administration. Project's administration page will be opened.
3. On the administration's navigation pane select Work Items ➙ Form Configuration.
4. On the form configuration page you will see 2 sections: Form Filters and Form Layouts.
5. In the table of Form Layouts section find line Test Case and click 📝 Edit
6. In opened Form Layout Configuration editor find a line with code:
```xml
<field id="description"/>
```
7. Insert following new line after it:
```xml
<extension id="cucumber" label="Cucumber Test"/>
```
8. Save changes by clicking 💾 Save

### Test Run's description to appear on UI

By default, Test Run's UI doesn't display its description (as a custom field). To enable displaying description following needs to be done:
1. Open a project which Test Run Templates needs to be modified.
2. In Navigation, click Test Runs. The Test Runs page opens. The top section of the page displays a table of existing Test Runs.
3. On the right hand side of the toolbar of the Test Runs page, click Manage Templates. The table of Test Runs is replaced by a table of Test Run Templates.
4. Select a template you want to modify.
5. On the toolbar of the detail pane, click ⚙ (Actions) ➙ Customize Test Run Page.
6. You will see a warning block containing text:
> <b>This is a Test Run template</b>, you cannot execute this test. Please create a Test Run first using this template
7. Click ✎ (Pencil) to edit code of this block, on the right hand side of the page you will see following lines of code:
```velocity
#if($testRun.fields().isTemplate().get())
$widgetContext.renderWarning("<b>This is a Test Run template</b>, you cannot execute this test. Please create a Test Run first using this template")
#end
#if($testRun.fields().records().is().empty() && $testRun.fields().selectTestCasesBy().optionId().equals("manualSelection"))
$widgetContext.renderInfo("Select the test cases you want to plan for execution by clicking Operations > Select Test Cases.")
#end
```
8. Add new lines:
```velocity
#if(!$testRun.fields().description().is().empty())
$testRun.fields.description.render().withText()
#end
```
9. Save template by clicking 💾

### Custom fields: `Components`

## Extension Configuration
1. Create an enum containing all acceptable `components` names for selected project:
- go to `Project Administration -> Work Items -> Enumerations`
- use Work Item Type: `--Unspecific--`, Enumeration: `Custom` + provide own name e.g. `components`
- fill all possible values of this enum, e.g. `TA-Adapter`, `DailyTrainDataCalculator`, `ItisGateway`, etc
- save enum configuration
2. Create a custom field for selected project:
- go to `Project Administration -> Testing -> Test Run Custom Fields`
- use ID: `components`, Name: `Components`, Type: Enum (+ select enum name created on step 1) and enable `'Multi'` checkbox
- save configuration
3. Customize Test Run Report to show Components field:
- Test Runs -> on the right hand side of the toolbar of the Test Runs page, click Manage Templates and select a template you want to modify
- Place where it is needed widget "Script - Block" and put following code inside:
```velocity
#if(!$testRun.fields().get("components").is().empty())
<h2>Components</h2>
$testRun.fields().get("components").render()
#end
```
- click 'Save'
- Now 'Components' field would appear on detail page if the field was sent during importing test results

<...>
### Custom fields: `Test Plan`

1. Create a custom field for selected project :
- go to `Project Administration -> Testing -> Test Run Custom Fields`
- use ID: `plans`, Name: `Test Plan`, Type: `Rich Text (multi-line)`
- save configuration
2. Customize Test Run Report to show `Test Plan` field:
- Test Runs -> on the right hand side of the toolbar of the Test Runs page, click Manage Templates and select a template you want to modify
- Place where it is needed widget "Script - Block" and put following code inside:
```velocity
#if(!$testRun.fields().get("plans").is().empty())
<h2>Test plan</h2>
$testRun.fields().get("plans").render()
#end
```
- click 'Save'
- Now 'Test Plan' field would appear on Test Run detail page if the field was sent by maven-plugin. Also if current project contains some plan(s) with the id equal to given value - the value will be transformaed into a link to certain plan.
3. Customize Plan to show links to Test Runs:
- go to `Administration -> Plans -> Plan Custom Fields` and create custom field using ID: `testRunLinks`, Name: `Test Run Links`, Type: `Rich Text (multi-line)`
- go to `Plans` -> select any plan and click ⚙ -> `Customize Plan Report -> Customize Shared Report`
- Place where it is needed widget "Script - Block" and put following code inside:
```velocity
#if(!$plan.fields().get("testRunLinks").is().empty())
<h2>Test runs</h2>
$plan.fields().get("testRunLinks").render()
#end
```
- click 'Save'
- Now 'Test Runs' field should contain links to the Test Runs which had created references to current plan on step 2.

## Usage

<...>
### Custom field: `Team-SBB`

1. Create an enum containing all acceptable team names for selected project:
- go to `Administration -> Work Items -> Enumerations`
- use Work Item Type: `--Unspecific--`, Enumeration: `Custom` + provide own name e.g. `team_sbb`
- fill all possible values of this enum, e.g. `Adler`, `Otter`, `Orca`, etc
- save enum configuration
2. Create a custom field which will keep the value (this step can be made in global configuration, but global fields will be visible only if the local configuration for test runs is deleted https://community.sw.siemens.com/s/question/0D54O00007Fh7iLSAR/do-global-test-run-custom-fields-work-locally):
- go to `Administration -> Testing -> Test Run Custom Fields`
- use ID: `team-sbb`, Name: `Team-SBB`, Type: `Enum` (+ select enum name created on step 1)
3. Customize Test Run Report to show Team-SBB field:
- Test Runs -> on the right hand side of the toolbar of the Test Runs page, click Manage Templates and select a template you want to modify
- Place where it is needed widget "Script - Block" and put following code inside:
```velocity
#if(!$testRun.fields().get("teamSBB").is().empty())
<h2>Team-SBB</h2>
$testRun.fields().get("teamSBB").render()
#end
```
- click 'Save'
- Now 'Team-SBB' field would appear on detail page if the field was sent by maven-plugin
4 changes: 4 additions & 0 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# tells Lombok that this is the root directory and that it shouldn’t search parent directories for more configuration files
config.stopBubbling = true
# tells Lombok to add @lombok.Generated annotation to all generated methods
lombok.addLombokGeneratedAnnotation = true
33 changes: 20 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
<parent>
<groupId>ch.sbb.polarion.extensions</groupId>
<artifactId>ch.sbb.polarion.extension.generic</artifactId>
<version>6.0.2</version>
<version>6.0.3</version>
</parent>

<artifactId>ch.sbb.polarion.extension.extension-name</artifactId>
<version>0.0.0-SNAPSHOT</version>
<artifactId>ch.sbb.polarion.extension.cucumber</artifactId>
<version>1.4.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>... extension of Polarion ALM</name>
<description>This is a Polarion extension which provides ...</description>
<url>https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.extension-name</url>
<name>This Polarion extension is designed to integrate BDD process into Polarion</name>
<description>It provides the almost same functionality as Xray plugin for Jira.</description>
<url>https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.cucumber</url>

<licenses>
<license>
<name>The SBB License, Version 1.0</name>
<url>https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.extension-name/blob/main/LICENSES/SBB.txt</url>
<url>https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.cucumber/blob/main/LICENSES/SBB.txt</url>
</license>
</licenses>

Expand All @@ -33,21 +33,22 @@
</developers>

<scm>
<connection>scm:git:git://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.extension-name.git</connection>
<developerConnection>scm:git:ssh://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.extension-name.git</developerConnection>
<url>http://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.extension-name/tree/main</url>
<connection>scm:git:git://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.cucumber.git</connection>
<developerConnection>scm:git:ssh://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.cucumber.git</developerConnection>
<url>http://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.cucumber/tree/main</url>
</scm>

<issueManagement>
<system>GitHub</system>
<url>https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.extension-name/issues</url>
<url>https://github.com/SchweizerischeBundesbahnen/ch.sbb.polarion.extension.cucumber/issues</url>
</issueManagement>

<properties>
<maven-jar-plugin.Extension-Context>extension-name</maven-jar-plugin.Extension-Context>
<maven-jar-plugin.Automatic-Module-Name>ch.sbb.polarion.extension.extension_name</maven-jar-plugin.Automatic-Module-Name>
<maven-jar-plugin.Extension-Context>cucumber</maven-jar-plugin.Extension-Context>

<web.app.name>${maven-jar-plugin.Extension-Context}</web.app.name>

<cucumber-gherkin.version>28.0.0</cucumber-gherkin.version>
</properties>

<dependencies>
Expand All @@ -56,6 +57,12 @@
<artifactId>ch.sbb.polarion.extension.generic.app</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>io.cucumber</groupId>
<artifactId>gherkin</artifactId>
<version>${cucumber-gherkin.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ch.sbb.polarion.extension.cucumber;

import ch.sbb.polarion.extension.generic.GenericUiServlet;

import java.io.Serial;

public class CucumberIntegrationAdminUiServlet extends GenericUiServlet {

@Serial
private static final long serialVersionUID = 6687845260037475974L;

public CucumberIntegrationAdminUiServlet() {
super("cucumber-admin");
}
}
Loading
Loading