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

Enable Gradle Build Scans #518

Merged
merged 6 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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 --scan --info --stacktrace
run: ./gradlew dockerSolution:ComposeUp -x test --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 --scan --info --stacktrace
run: ./gradlew build -x test --info --stacktrace
AndreKurait marked this conversation as resolved.
Show resolved Hide resolved
working-directory: TrafficCapture
env:
OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED: ''

- name: Run Tests with Coverage
run: ./gradlew jacocoTestReport --scan --info --stacktrace
run: ./gradlew test jacocoTestReport --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
39 changes: 39 additions & 0 deletions 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)

## Overview

Expand Down Expand Up @@ -136,3 +138,40 @@ 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.
7 changes: 7 additions & 0 deletions TrafficCapture/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,11 @@ eval "set -- $(
tr '\n' ' '
)" '"$@"'

# Check if OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED exists, and if --scan is not in the arguments and --no-scan is not provided
if [ -n "${OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED+set}" ] && ! printf '%s\n' "$@" | grep -q -- '--scan' && ! printf '%s\n' "$@" | grep -q -- '--no-scan'; then
echo "Enabling Gradle Scan based on environment variable OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED"
set -- "$@" '--scan' # Append --scan to the arguments
fi
AndreKurait marked this conversation as resolved.
Show resolved Hide resolved


exec "$JAVACMD" "$@"
4 changes: 1 addition & 3 deletions TrafficCapture/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ addSubProjects('', new File(rootProject.projectDir,'replayerPlugins'))
include 'replayerPlugins:jsonMessageTransformers:jsonJoltMessageTransformerProvider:untitled'
findProject(':replayerPlugins:jsonMessageTransformers:jsonJoltMessageTransformerProvider:untitled')?.name = 'untitled'

// Enable Gradle Scan Publishing for CI/CD
if (System.getenv().containsKey("CI")) {
if (System.getenv().containsKey("OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED") && hasProperty('gradleEnterprise')) {
AndreKurait marked this conversation as resolved.
Show resolved Hide resolved
gradleEnterprise {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
tag("CI")
}
}
}
Loading