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

build(ci): Basic Gradle workflow to build on Github #5134

Closed
wants to merge 12 commits into from
Closed
71 changes: 71 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Java CI

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
BenjaminAmos marked this conversation as resolved.
Show resolved Hide resolved
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Build Distribution for Launcher
run: ./gradlew extractConfig extractNatives distForLauncher testDist
- name: Unit Tests
run: ./gradlew unitTest
- name: API Documentation
run: ./gradlew javadoc
Comment on lines +21 to +24
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to extract those into dedicated jobs, too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, if we get the job dependencies with reuse going then yes, otherwise I would not blow up the job count as this job with multiple steps is still faster than the other two…

- name: Publish
run: echo "TODO"
integration-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Integration Tests
run: ./gradlew integrationTest
code-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Static Code Analysis
run: ./gradlew check -x test
Comment on lines +55 to +56
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to split into mandatory (checkstyle) and not mandatory (spotbugs, pmd) ones here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could - depends a bit on what we want to see in Github and/or how we view the build results.

Currently, we're more interested in the binary ❌ / ✔️ than anything else

build-with-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Build With Gradlew
run: ./gradlew -PacceptGradleBuildScanTermsOfService=yes distForLauncher --scan
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/terasology-metrics.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ tasks.withType<Test> {
useJUnitPlatform()

// ignoreFailures: Specifies whether the build should break when the verifications performed by this task fail.
ignoreFailures = true
ignoreFailures = false
// showStandardStreams: makes the standard streams (err and out) visible at console when running tests
// If false, the outputs are still collected and visible in the test report, but they don't spam the console.
testLogging.showStandardStreams = false
Expand Down
12 changes: 12 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,15 @@ idea {
cleanIdea.doLast {
new File('Terasology.iws').delete()
}

if (hasProperty('buildScan')
// allow to programmically accept the Gradle Build Scan terms of service when running in CI
&& project.hasProperty('acceptGradleBuildScanTermsOfService')
&& project.acceptGradleBuildScanTermsOfService == 'yes') {
gradleEnterprise {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
}
}
}
Loading