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

Gradle and Github changes for JRE 17 Min #5512

Merged
merged 9 commits into from
Jun 29, 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
27 changes: 7 additions & 20 deletions .github/build-scan-init.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//
// Setup Gradle Build Scans for this Project
// with a special hook to place the Build Scan URI
// onto a GitHub Actions job step output variable
// called `buildScanUri`.
// Setup Gradle Build Scans for this Project with a special hook to place the Build Scan URI onto a GitHub Actions job
// step output variable called `buildScanUri`.
//
import com.gradle.enterprise.gradleplugin.GradleEnterprisePlugin
import com.gradle.scan.plugin.BuildScanPlugin
Expand All @@ -23,30 +21,19 @@ initscript {
def isTopLevelBuild = gradle.getParent() == null

if (isTopLevelBuild) {
def gradleVersion = GradleVersion.current().baseVersion
def atLeastGradle5 = gradleVersion >= GradleVersion.version("5.0")
def atLeastGradle6 = gradleVersion >= GradleVersion.version("6.0")

if (atLeastGradle6) {
settingsEvaluated {
if (!it.pluginManager.hasPlugin("com.gradle.enterprise")) {
it.pluginManager.apply(GradleEnterprisePlugin)
}
configureExtension(it.extensions["gradleEnterprise"])
}
} else if (atLeastGradle5) {
rootProject {
pluginManager.apply(BuildScanPlugin)
configureExtension(extensions["gradleEnterprise"])
settingsEvaluated {
if (!it.pluginManager.hasPlugin("com.gradle.enterprise")) {
it.pluginManager.apply(GradleEnterprisePlugin)
}
configureExtension(it.extensions["gradleEnterprise"])
}
}

void configureExtension(extension) {
extension.buildScan.with {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"

//
// After the build scan is published, put on STDOUT the special
// GitHub Actions syntax to set an Output Variable for the job
Expand Down
143 changes: 72 additions & 71 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name: MegaMek CI with Gradle
# Pull Requests being added/updated against master.
on:
pull_request:
branches: [ master ]
branches: [master]

# Setup the Build Scan "VCS" link for all gradle invocations
env:
Expand All @@ -22,84 +22,85 @@ jobs:
# Run this job once for each combination in the matrix below.
strategy:
matrix:
os: [ ubuntu-latest ] # For CI/CD running on *nix is sufficient
java-distribution: [ temurin ]
java-version: [ 11, 17 ]
os: [ubuntu-latest] # For CI/CD running on *nix is sufficient
java-distribution: [temurin]
java-version: [17]
fail-fast: false

steps:
# Checkout the Pull Request source and put it in: ./megamek
- uses: actions/checkout@v3
with:
path: megamek
# Checkout the Pull Request source and put it in: ./megamek
- uses: actions/checkout@v4
with:
path: megamek

# Setup the requested Java Distribution and Version from the matrix
- name: Set up ${{ matrix.java-distribution }} JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3
with:
distribution: ${{ matrix.java-distribution }}
java-version: ${{ matrix.java-version }}
# Setup the requested Java Distribution and Version from the matrix
- name: Set up ${{ matrix.java-distribution }} JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.java-distribution }}
java-version: ${{ matrix.java-version }}

# Make sure we can execute the Gradle wrapper
- name: Grant execute permission for gradlew (*nix or MacOS)
working-directory: megamek
run: chmod +x gradlew
if: runner.os != 'Windows'
# Make sure we can execute the Gradle wrapper
- name: Grant execute permission for gradlew (*nix or MacOS)
working-directory: megamek
run: chmod +x gradlew
if: runner.os != 'Windows'

# Build the MegaMek project
#
# Directory layout:
# /megamek
# /gradlew
#
# Output Variables:
# - buildScanUri
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: build --stacktrace --scan
build-root-directory: megamek
# Build the MegaMek project
#
# Directory layout:
# /megamek
# /gradlew
#
# Output Variables:
# - buildScanUri
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

# If the build step fails, try to upload any test logs in case it was a unit test failure.
# The logs will be relative to the ./megamek directory.
- name: Upload Test Logs on Failure
uses: actions/upload-artifact@v3
if: failure()
with:
name: cd-failure-logs
path: ./megamek/megamek/build/reports/
- name: Build with Gradle
working-directory: megamek
run: ./gradlew build --stacktrace --scan

# Upload our Code Coverage Reports to CodeCov.io
- name: CodeCov.io Coverage Report
uses: codecov/codecov-action@v3
with:
directory: ./megamek/megamek/build/reports/jacoco/test
fail_ci_if_error: false
verbose: true
# If the build step fails, try to upload any test logs in case it was a unit test failure.
# The logs will be relative to the ./megamek directory.
- name: Upload Test Logs on Failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: cd-failure-logs
path: ./megamek/megamek/build/reports/

# If we have a buildScanUri comment on the PR
#
# NB: This only works if you're on the main MegaMek\megamek repo
# for now due to a GitHub Actions limitation.
# CAW: temporarily halted https://github.com/thollander/actions-comment-pull-request/issues/17
# - name: Comment on PR with Build Scan URI
# uses: thollander/actions-comment-pull-request@master
# if: always() && steps.gradle_build.outputs.buildScanUri != ''
# with:
# message: Build scan available at ${{ steps.gradle_build.outputs.buildScanUri }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Upload our Code Coverage Reports to CodeCov.io
- name: CodeCov.io Coverage Report
uses: codecov/codecov-action@v4
with:
directory: ./megamek/megamek/build/reports/jacoco/test
fail_ci_if_error: false
verbose: true

# Put the Windows Release in an artifact
# NB: Due to a GitHub Actions limitation we won't know what the filename is in order to display it somewhere.
- name: Upload Windows Release
uses: actions/upload-artifact@v3
with:
name: mm-release-win-${{ matrix.java-distribution }}-jdk${{ matrix.java-version }}
path: ./megamek/megamek/build/distributions/megamek-windows-*.zip
# If we have a buildScanUri comment on the PR
#
# NB: This only works if you're on the main MegaMek\megamek repo
# for now due to a GitHub Actions limitation.
# CAW: temporarily halted https://github.com/thollander/actions-comment-pull-request/issues/17
# - name: Comment on PR with Build Scan URI
# uses: thollander/actions-comment-pull-request@master
# if: always() && steps.gradle_build.outputs.buildScanUri != ''
# with:
# message: Build scan available at ${{ steps.gradle_build.outputs.buildScanUri }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Put the non-Windows release in an artifact
- name: Upload Nix/Mac Release
uses: actions/upload-artifact@v3
with:
name: mm-release-nix-mac-${{ matrix.java-distribution }}-jdk${{ matrix.java-version }}
path: ./megamek/megamek/build/distributions/*.tar
# Put the Windows Release in an artifact
# NB: Due to a GitHub Actions limitation we won't know what the filename is in order to display it somewhere.
- name: Upload Windows Release
uses: actions/upload-artifact@v4
with:
name: mm-release-win-${{ matrix.java-distribution }}-jdk${{ matrix.java-version }}
path: ./megamek/megamek/build/distributions/megamek-windows-*.zip

# Put the non-Windows release in an artifact
- name: Upload Nix/Mac Release
uses: actions/upload-artifact@v4
with:
name: mm-release-nix-mac-${{ matrix.java-distribution }}-jdk${{ matrix.java-version }}
path: ./megamek/megamek/build/distributions/*.tar.gz
99 changes: 50 additions & 49 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name: MegaMek CI with Code Coverage
# This Action Definition should be triggered only on pushes to master
on:
push:
branches: [ master ]
branches: [master]

# Setup the Build Scan "VCS" link for all gradle invocations
env:
Expand All @@ -22,57 +22,58 @@ jobs:
# Run this job once for each combination in the matrix below.
strategy:
matrix:
os: [ ubuntu-latest ] # For Code QL running on *nix is sufficient
java-distribution: [ temurin ]
java-version: [ 17 ]
os: [ubuntu-latest] # For Code QL running on *nix is sufficient
java-distribution: [temurin]
java-version: [17]

steps:
# Checkout the Pull Request source and put it in: ./megamek
- uses: actions/checkout@v3
with:
path: megamek
# Checkout the Pull Request source and put it in: ./megamek
- uses: actions/checkout@v4
with:
path: megamek

# Setup the requested Java Distribution and Version from the matrix
- name: Set up ${{ matrix.java-distribution }} JDK ${{ matrix.java-version }}
uses: actions/setup-java@v3
with:
distribution: ${{ matrix.java-distribution }}
java-version: ${{ matrix.java-version }}
# Setup the requested Java Distribution and Version from the matrix
- name: Set up ${{ matrix.java-distribution }} JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.java-distribution }}
java-version: ${{ matrix.java-version }}

# Make sure we can execute the Gradle wrapper
- name: Grant execute permission for gradlew (*nix or MacOS)
working-directory: megamek
run: chmod +x gradlew
if: runner.os != 'Windows'
# Make sure we can execute the Gradle wrapper
- name: Grant execute permission for gradlew (*nix or MacOS)
working-directory: megamek
run: chmod +x gradlew
if: runner.os != 'Windows'

# Build the MegaMek project
#
# Directory layout:
# /megamek
# /gradlew
#
# Output Variables:
# - buildScanUri
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: build --stacktrace --scan
build-root-directory: megamek

# If the build step fails, try to upload any test logs in case it was a unit test failure.
#
# The logs will be relative to the ./megamek directory.
- name: Upload Test Logs on Failure
uses: actions/upload-artifact@v3
if: failure()
with:
name: cd-failure-logs
path: ./megamek/megamek/build/reports/
# Build the MegaMek project
#
# Directory layout:
# /megamek
# /gradlew
#
# Output Variables:
# - buildScanUri
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

# Upload our Code Coverage Reports to CodeCov.io
- name: CodeCov.io Coverage Report
uses: codecov/codecov-action@v3
with:
directory: ./megamek/megamek/build/reports/jacoco/test
fail_ci_if_error: false
verbose: true
- name: Build with Gradle
working-directory: megamek
run: ./gradlew build --stacktrace --scan

# If the build step fails, try to upload any test logs in case it was a unit test failure.
#
# The logs will be relative to the ./megamek directory.
- name: Upload Test Logs on Failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: cd-failure-logs
path: ./megamek/megamek/build/reports/

# Upload our Code Coverage Reports to CodeCov.io
- name: CodeCov.io Coverage Report
uses: codecov/codecov-action@v4
with:
directory: ./megamek/megamek/build/reports/jacoco/test
fail_ci_if_error: false
verbose: true
Loading
Loading