Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

mcobbett maven uses common code #115

Merged
merged 10 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
30 changes: 29 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,32 @@ MANIFEST.MF
/bin/
*.versionsBackup
temp/
.vscode/
.vscode/


.gradle
**/build/
!src/**/build/
bin/
wrapper/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache

# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties


.settings
.project
.classpath

*.phd
*.dmp
velocity.log*
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ Environment variable over-rides:
- `DEBUG` - Optional. Defaults to 0 (off)
- `GPG_PASSPHRASE` - Used to sign and verify artifacts during the build

## How to use the plugin

### Building a test catalog for a Java bundle
## How to use the plugin
Here we discuss how to use the maven plugin when building Galasa test projects.

### Building a test catalog for a Java bundle

This goal causes a test catalog to be constructed for all the tests in the child bundles of this maven project.

Expand Down Expand Up @@ -78,7 +80,7 @@ Input Parameters/Properties:
- `galasa.test.stream` required. A string.
- `galasa.token` optional. An access token for the galasa ecosystem, if that ecosytem is using authentication.
- `galasa.bootstrap` required. A URL to the ecosystem.
- `galasa.skip.bundletestcatalog` optional. A boolean. If set to true, the test catalog is not deployed to the Galasa server.
- `galasa.skip.bundletestcatalog` optional. A boolean. Controls whether the test catalog build is skipped. If set to true then no test catalog is built, so the test catalog is not deployed to the Galasa server.
- `galasa.skip.deploytestcatalog` optional. A boolean. If set to true, the test catalog is not deployed to the Galasa server.

For example:
Expand Down
32 changes: 11 additions & 21 deletions build-locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,16 @@ blue=$(tput setaf 25)
# Headers and Logging
#
#-----------------------------------------------------------------------------------------
underline() { printf "${underline}${bold}%s${reset}\n" "$@"
}
h1() { printf "\n${underline}${bold}${blue}%s${reset}\n" "$@"
}
h2() { printf "\n${underline}${bold}${white}%s${reset}\n" "$@"
}
debug() { printf "${white}%s${reset}\n" "$@"
}
info() { printf "${white}➜ %s${reset}\n" "$@"
}
success() { printf "${green}✔ %s${reset}\n" "$@"
}
error() { printf "${red}✖ %s${reset}\n" "$@"
}
warn() { printf "${tan}➜ %s${reset}\n" "$@"
}
bold() { printf "${bold}%s${reset}\n" "$@"
}
note() { printf "\n${underline}${bold}${blue}Note:${reset} ${blue}%s${reset}\n" "$@"
}
underline() { printf "${underline}${bold}%s${reset}\n" "$@" ;}
h1() { printf "\n${underline}${bold}${blue}%s${reset}\n" "$@" ;}
h2() { printf "\n${underline}${bold}${white}%s${reset}\n" "$@" ;}
debug() { printf "${white}%s${reset}\n" "$@" ;}
info() { printf "${white}➜ %s${reset}\n" "$@" ;}
success() { printf "${green}✔ %s${reset}\n" "$@" ;}
error() { printf "${red}✖ %s${reset}\n" "$@" ;}
warn() { printf "${tan}➜ %s${reset}\n" "$@" ;}
bold() { printf "${bold}%s${reset}\n" "$@" ;}
note() { printf "\n${underline}${bold}${blue}Note:${reset} ${blue}%s${reset}\n" "$@" ;}

#-----------------------------------------------------------------------------------------
# Main logic.
Expand All @@ -87,7 +77,7 @@ fi

# Over-rode SOURCE_MAVEN if you want to build from a different maven repo...
if [[ -z ${SOURCE_MAVEN} ]]; then
export SOURCE_MAVEN=https://development.galasa.dev/main/maven-repo/obr/
export SOURCE_MAVEN=https://development.galasa.dev/main/maven-repo/gradle/
info "SOURCE_MAVEN repo defaulting to ${SOURCE_MAVEN}."
info "Set this environment variable if you want to over-ride this value."
else
Expand Down
198 changes: 198 additions & 0 deletions galasa-maven-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
# Maven Plugin for building Galasa

This repository is an extension to Maven2 and includes goals that are used to build OSGI bundles and test catalogs for Galasa. The OSGI bundle repositories contain all the project information, configuration details and dependencies that are needed for building and running Galasa projects. The test catalog is used to manage Galasa test cases - attributes associated with test cases that are held in the catalog can used to schedule test runs.

## How to build locally
Use the `build-locally.sh` script to build this code locally.

Environment variable over-rides:

- `LOGS_DIR` - Optional. Where logs are placed. Defaults to creating a temporary directory.
- `SOURCE_MAVEN` - Optional. Where a maven repository is from which the build will draw artifacts.
- `DEBUG` - Optional. Defaults to 0 (off)
- `GPG_PASSPHRASE` - Used to sign and verify artifacts during the build

## How to use the plugin

### Building a test catalog for a Java bundle
techcobweb marked this conversation as resolved.
Show resolved Hide resolved

This goal causes a test catalog to be constructed for all the tests in the child bundles of this maven project.

Goal: `bundletestcat`

Phase: `package`

Input Parameters/Properties:
- `galasa.skip.bundletestcatalog` required.

Output:
A test catalog file is generated holding references to all the test classes.

Example:
```
<plugin>
<groupId>dev.galasa</groupId>
<artifactId>galasa-maven-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<id>build-testcatalog</id>
<phase>package</phase>
<goals>
<goal>bundletestcat</goal>
</goals>
</execution>
</executions>
</plugin>
```

### Building an OBR resource

Input Parameters/Properties:
- `galasa.obr.url.type` property = "obrUrlType" optional
- `includeSelf` optional. Default value is `false`

### Publishing a test catalog to the Galasa ecosystem/server

Goal: `deploytestcat`

Phase: `deploy`

Input Parameters/Properties:
- `galasa.test.stream` required. A string.
- `galasa.token` optional. An access token for the galasa ecosystem, if that ecosytem is using authentication.
- `galasa.bootstrap` required. A URL to the ecosystem.
- `galasa.skip.bundletestcatalog` optional. A boolean. If set to true, the test catalog is not deployed to the Galasa server.
- `galasa.skip.deploytestcatalog` optional. A boolean. If set to true, the test catalog is not deployed to the Galasa server.
techcobweb marked this conversation as resolved.
Show resolved Hide resolved

For example:
```
<plugin>
<groupId>dev.galasa</groupId>
<artifactId>galasa-maven-plugin</artifactId>
<extensions>true</extensions>
<executions>
...
<execution>
<id>deploy-testcatalog</id>
<phase>deploy</phase>
<goals>
<goal>deploytestcat</goal>
</goals>
</execution>
...
</executions>
</plugin>
```

#### Passing a secret token into a maven plugin. Method 1: using ${GALASA_TOKEN}

The `galasa.token` maven property is used by this plugin.
You can set it using the following in your pom.xml like this:

```
<properties>
...
<galasa.token>${GALASA_TOKEN}</galasa.token>
...
</properties>
```

This allows you to call maven and pass the value from the command-line
```
mvn clean install deploy "-DGALASA_TOKEN=${GALASA_TOKEN}"
```

This assumes you have `GALASA_TOKEN` set in your environment.

Note: This method allows the caller of the command-line to pass in
whatever value they want, from an environment variable (`GALASA_TOKEN` in this case)
or from any other value.

This may be useful if you are deploying to multiple Galasa server environments,
or switching between tokens used to contact the Galasa Ecosystem.

#### Passing a secret token into a maven plugin. Method 2: using ${env.GALASA_TOKEN}
The `galasa.token` maven property is used by this plugin.
You can set it using the following in your pom.xml like this:

```
<properties>
...
<galasa.token>${env.GALASA_TOKEN}</galasa.token>
...
</properties>
```

This allows you to set the GALASA_TOKEN as an environment variable, and
the maven plugin for Galasa can pick up the value from the environment.

Note: This causes a tighter 'binding' between your environment and the maven
build, so all parties using this code need to use the same environment variable
name.

### Supressing the deploy of the test catalog
Use the `galasa.skip.bundletestcatalog` or `galasa.skip.deploytestcatalog` to control whether
the deploy of the test catalog is skipped.

If either of these flags is true, then the publication of the test catalog to the Galasa
ecosystem will be supressed.

For example, to skip both the building of the test catalog and the deployment of it, you can
add this to your pom.xml:
```
<properties>
...
<galasa.skip.bundletestcatalog>true</galasa.skip.bundletestcatalog>
<galasa.skip.deploytestcatalog>true</galasa.skip.deploytestcatalog>
...
</properties>
```

Or you could pass a `-D` parameter on the command-line:
```
mvn deploy -Dgalasa.skip.deploytestcatalog=true
```

### Merging two test catalogs

Input Parameters/Properties:
- `galasa.skip.bundletestcatalog` optional. A boolean.
- `galasa.build.job` optional. A string.

### Building a gherkin test catalog for Gherkin features

Input Parameters/Properties:
- `galasa.skip.gherkintestcatalog` required. A boolean.


### Building a .zip of gherkin tests

This goal builds a zip file containing all the gherkin feature files.

Goal: `gherkinzip`

Phase: `package`

Input Parameters/Properties:
- `galasa.skip.gherkinzip` required. A boolean.


### Calculating a git commit hash

For example:
```
<plugin>
<groupId>dev.galasa</groupId>
<artifactId>galasa-maven-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<id>process-resources</id>
<goals>
<goal>gitcommithash</goal>
</goals>
</execution>
</executions>
</plugin>
```
Loading
Loading