Skip to content

Commit

Permalink
Merge pull request #518 from AndreKurait/EnableGradleScan
Browse files Browse the repository at this point in the history
Enable Gradle Build Scans
  • Loading branch information
AndreKurait authored Feb 29, 2024
2 parents aff1b80 + b70650a commit bc31bff
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/e2eTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ jobs:
cache-read-only: false

- name: Start Docker Solution
run: ./gradlew dockerSolution:ComposeUp -x test
run: ./gradlew dockerSolution:ComposeUp -x test --scan --info --stacktrace
working-directory: TrafficCapture
env:
OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED: ''

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/gradle-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ jobs:
gradle-home-cache-cleanup: true

- name: Run Gradle Build
run: ./gradlew build -x test --info
run: ./gradlew build -x test --scan --info --stacktrace
working-directory: TrafficCapture
env:
OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED: ''

- name: Run Tests with Coverage
run: ./gradlew jacocoTestReport --info
run: ./gradlew test jacocoTestReport --scan --info --stacktrace
working-directory: TrafficCapture
env:
OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED: ''

- name: Upload to Codecov
uses: codecov/codecov-action@v4
Expand Down
42 changes: 41 additions & 1 deletion TrafficCapture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
- [Traffic Capture Proxy Server](#traffic-capture-proxy-server)
- [Traffic Replayer](#traffic-replayer)
- [Capture Kafka Offloader](#capture-kafka-offloader)
- [Building](#building)
- [Gradle Scans](#gradle-scans)
- [Publishing](#publishing)

## Overview
Expand Down Expand Up @@ -137,6 +139,44 @@ The Capture Kafka Offloader will act as a Kafka Producer for offloading captured

Learn more about its functionality and setup here: [Capture Kafka Offloader](captureKafkaOffloader/README.md)

## Building

The building process for this project is streamlined through the use of Gradle. This section outlines the necessary steps to build the project and execute tests effectively.

To compile the project and execute unit tests, use the following command:

```sh
./gradlew build
```

This command compiles the source code and runs the quick unit tests, ensuring the project is correctly assembled and functional.

For a comprehensive test run, including both quick unit tests and more extensive slow tests, execute:

```sh
./gradlew test slowTest --rerun
```

This command initiates all tests, ensuring thorough validation of the project. The `--rerun` option is used to ignore existing task output cache for the specified tasks.

### Gradle Scans

Gradle Scans offer a more intuitive understanding of build outputs. To enable Gradle Scans for enhanced output analysis, append `--scan` to your Gradle command.
This action requires acceptance of the Gradle Scan terms of service.
To automate this acceptance and enable scans by default, set the `OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED` environment variable:

```sh
export OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED=
```

For persistent configuration in Zsh:

```sh
echo 'export OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED=' >> ~/.zshrc
```

Access your detailed build reports by following the link provided at the end of your Gradle command's output.

## Publishing

This project can be published to a local maven repository with:
Expand Down Expand Up @@ -182,4 +222,4 @@ To include a testFixture dependency, define the import like

```groovy
testImplementation testFixtures('org.opensearch.migrations.trafficcapture:trafficReplayer:0.1.0-SNAPSHOT')
```
```
1 change: 1 addition & 0 deletions TrafficCapture/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,5 @@ eval "set -- $(
tr '\n' ' '
)" '"$@"'


exec "$JAVACMD" "$@"
14 changes: 14 additions & 0 deletions TrafficCapture/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* in the user manual at https://docs.gradle.org/8.0.2/userguide/multi_project_builds.html
*/

plugins {
id("com.gradle.enterprise") version("3.16.2")
}

void addSubProjects(String path, File dir) {
if (dir.isDirectory() == false) return;
if (dir.name == 'buildSrc') return;
Expand Down Expand Up @@ -37,3 +41,13 @@ include('captureKafkaOffloader',
)

addSubProjects('', new File(rootProject.projectDir,'replayerPlugins'))

if (System.getenv().containsKey("OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED")) {
gradleEnterprise {
buildScan {
publishAlways()
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
}
}
}

0 comments on commit bc31bff

Please sign in to comment.