Skip to content

Commit

Permalink
Upgrading plugin to use latest Gradle Apis (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
haroon-sheikh authored Oct 28, 2023
1 parent cf97459 commit 9f3afdc
Show file tree
Hide file tree
Showing 77 changed files with 1,676 additions and 1,189 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: monthly
- package-ecosystem: maven
directory: "plugin/"
schedule:
interval: monthly
34 changes: 23 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
name: Build

on: [push, pull_request]
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v1
- name: Set up JDK
uses: actions/setup-java@v1
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: '12.x.x'

distribution: 'temurin'
java-version: '11'
- uses: getgauge/setup-gauge@master
with:
gauge-plugins: java, html-report, xml-report
- uses: gradle/gradle-build-action@v2
with:
gradle-version: '8.2'
- name: Build with Gradle on ubuntu
if: matrix.os != 'windows-latest'
run: ./gradlew clean build

run: |
./gradlew plugin:build
./gradlew gaugeValidate gaugeDevRepeat
- name: Build with Gradle on windows
if: matrix.os == 'windows-latest'
run: ./gradlew.bat clean build
run: |
.\gradlew.bat plugin:build
.\gradlew.bat gaugeDevRepeat
18 changes: 9 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ jobs:
GRADLE_PUBLISHKEY: '${{ secrets.GRADLE_PUBLISHKEY }}'
GRADLE_SECRET: '${{ secrets.GRADLE_SECRET }}'
steps:
- uses: actions/checkout@v1
- name: Set up JDK
uses: actions/setup-java@v1
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: '12.x.x'

distribution: 'temurin'
java-version: '11'
- uses: gradle/gradle-build-action@v2
with:
gradle-version: '8.2'
- name: Build artifacts
run: |
./gradlew clean build
run: ./gradlew plugin:build
- name: Upload to gradle portal
run: |
./gradlew publishPlugins -Pgradle.publish.key=$GRADLE_PUBLISHKEY -Pgradle.publish.secret=$GRADLE_SECRET
./gradlew plugin:publishPlugins -Pgradle.publish.key=$GRADLE_PUBLISHKEY -Pgradle.publish.secret=$GRADLE_SECRET
16 changes: 9 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ build/
report*
log*
repo
sample/libs
sample/report*
sample/log*
sample/.gauge
local.properties
plugin/out
sample/out
bin/
**/build/
.java-version
.classpath
.project

sample/libs
sample/reports
sample/logs
sample/.gauge
local.properties
plugin/out
sample/out

.settings/org.eclipse.buildship.core.prefs
plugin/.settings/org.eclipse.buildship.core.prefs
sample/.settings/org.eclipse.buildship.core.prefs
106 changes: 57 additions & 49 deletions Readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,21 @@ Maven Central & Bintray; with out-of-date versions available on the Gradle Plugi

You can use this plugin on a new project via a Gauge [project template](https://docs.gauge.org/latest/installation.html#project-templates):

```
```bash
gauge init java_gradle
```

### Using the plugins DSL

If you have an existing project and you would like to add the plugin manually you can add it like the below
If you have an existing project, and you would like to add the plugin manually you can add it like the below


````groovy
```groovy
plugins {
id 'java'
id 'org.gauge' version '1.8.0'
id 'org.gauge' version '2.0.0'
}
group = 'my-gauge-tests'
version = '1.0-SNAPSHOT'
description = "My Gauge Tests"
repositories {
mavenCentral()
}
Expand All @@ -55,33 +50,28 @@ gauge {
additionalFlags = '--verbose'
gaugeRoot = '/opt/gauge'
}
````
```

### Using legacy plugin 'apply' style

* apply plugin `gauge`
* update the `buildscript` to add the Gradle plugins repo and classpath
* apply plugin `org.gauge`

````groovy
apply plugin: 'java'
apply plugin: 'gauge'
group = "my-gauge-tests"
version = "1.0-SNAPSHOT"
description = "My Gauge Tests"
```groovy
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath "gradle.plugin.org.gauge.gradle:gauge-gradle-plugin:1.8.0"
classpath("org.gauge.gradle:gauge-gradle-plugin:2.0.0")
}
}
apply plugin: 'java'
apply plugin: 'org.gauge'
repositories {
mavenCentral()
}
Expand All @@ -97,32 +87,46 @@ gauge {
nodes = 2
env = 'dev'
tags = 'tag1'
additionalFlags = '--verbose'
additionalFlags = '--simple-console --verbose'
gaugeRoot = '/opt/gauge'
// additional environment variables to pass onto the gauge process
environmentVariables = ["gauge_reports_dir": "custom/reports/", "logs_directory": "custom/logs/"]
}
````
```

## Usage

### Validating

```bash
gradle gaugeValidate
```

### Running
````

```bash
gradle gauge
````
#### Execute list of specs
```

#### Execute list of specs

```bash
gradle gauge -PspecsDir="specs/first.spec specs/second.spec"
```

#### Execute specs in parallel
```

```bash
gradle gauge -PinParallel=true -PspecsDir=specs
```
#### Execute specs by tags
```

```bash
gradle gauge -Ptags="!in-progress" -PspecsDir=specs
```
#### Specifying execution environment
```

```bash
gradle gauge -Penv="dev" -PspecsDir=specs
```

Expand All @@ -131,20 +135,22 @@ Note : Pass specsDir parameter as the last one.
### All additional Properties
The following plugin properties can be additionally set:

|Property name|Usage|Description|
|-------------|-----|-----------|
|specsDir| -PspecsDir=specs| Gauge specs directory path. Required for executing specs|
|tags | -Ptags="tag1 & tag2" |Filter specs by specified tags expression|
|inParallel| -PinParallel=true | Execute specs in parallel|
|nodes | -Pnodes=3 | Number of parallel execution streams. Use with ```parallel```|
|env | -Penv=qa | gauge env to run against |
|additionalFlags| -PadditionalFlags="--verbose" | Add additional gauge flags to execution|
|gaugeRoot| -PgaugeRoot="/opt/gauge" | Path to gauge installation root|
| Property name | Usage | Description |
|-----------------|--------------------------------|---------------------------------------------------------------|
| specsDir | -PspecsDir=specs | Gauge specs directory path. Required for executing specs |
| tags | -Ptags="tag1 & tag2" | Filter specs by specified tags expression |
| inParallel | -PinParallel=true | Execute specs in parallel |
| nodes | -Pnodes=3 | Number of parallel execution streams. Use with ```parallel``` |
| env | -Penv=qa | gauge env to run against |
| additionalFlags | -PadditionalFlags="--verbose" | Add additional gauge flags to execution separated by space |
| dir | -Pdir="/path/to/gauge/project" | Path to gauge project directory |
| gaugeRoot | -PgaugeRoot="/opt/gauge" | Path to gauge installation root |

### Adding/configuring custom Gauge tasks
It is possible to define new custom Gauge tasks specific for different environments. For example,

````groovy
```groovy
import org.gauge.gradle.GaugeTask
task gaugeDev(type: GaugeTask) {
doFirst {
Expand All @@ -153,7 +159,7 @@ task gaugeDev(type: GaugeTask) {
inParallel = true
nodes = 2
env = 'dev'
additionalFlags = '--verbose'
additionalFlags = '--simple-console --verbose'
}
}
}
Expand All @@ -165,23 +171,25 @@ task gaugeTest(type: GaugeTask) {
inParallel = true
nodes = 4
env = 'test'
additionalFlags = '--verbose'
additionalFlags = '--simple-console --verbose'
}
}
}
````
```

### Running gauge task with source code of gradle plugin
run the gauge command with -
````

```bash
gradle gauge --include-build {PATH_TO_GRADLE_PLUGIN}
````
```

or add this property in `settings.gradle`
````

```bash
includeBuild {PATH_TO_GRADLE_PLUGIN}
````
```

## License

Gauge is released under the Apache License, Version 2.0. See [LICENSE](LICENSE) for the full license text.
Gauge is released under the Apache License, Version 2.0. See [LICENSE](LICENSE.txt) for the full license text.
16 changes: 0 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +0,0 @@
plugins {
id "java"
id "idea"
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
}

Properties plugin = new Properties()
plugin.load(project.file('./plugin.properties').newDataInputStream())
group plugin.getProperty("groupId")
version = plugin.getProperty("version")
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
org.gradle.configureondemand=true
org.gradle.daemon=false
org.gradle.console=plain
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 9f3afdc

Please sign in to comment.