Extended CI with various extra tests, added Java 17 support in unit tests (fixes #8835) (#8839)

* Added a pure build stage with various versions

* Added build artifacts from GitHub CI

* Upgrade mocking and testing libraries

* Extended GitHub CI test stages, added Windows tests

* Fixed job name

* Split some jobs for increased speed due to better parallelism
This commit is contained in:
Crsi 2023-03-08 15:39:32 +01:00 committed by GitHub
parent a4339ff783
commit 5e88dbd7a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 144 additions and 8 deletions

View File

@ -36,7 +36,7 @@ jobs:
java-version: '11' java-version: '11'
- name: Setup Gradle - name: Setup Gradle
uses: gradle/gradle-build-action@v2.3.3 uses: gradle/gradle-build-action@v2.4.0
- name: Compile kotlin and build classes - name: Compile kotlin and build classes
run: ./gradlew classes run: ./gradlew classes

136
.github/workflows/buildAndTest.yml vendored Normal file
View File

@ -0,0 +1,136 @@
# Jobs to test the code base and build the client and server app
name: Build and test
on:
# Triggers the workflow on any push or pull request
push:
pull_request:
jobs:
# Job to execute code checks and unit tests on the project source
code-checks:
name: Check code and run unit tests (Java ${{ matrix.java_version }})
strategy:
matrix:
java_version:
- 11
- 17
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
cache: 'gradle'
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2.4.0
- name: Compile kotlin and build classes
run: ./gradlew classes
- name: Run code checks
run: ./gradlew check
- name: Run unit tests
run: ./gradlew --no-build-cache cleanTest test tests:test
# Job to build the android files on a Ubuntu host
build-android:
strategy:
matrix:
java_version:
- 11
- 17
runs-on: ubuntu-latest
name: Build Android (Java ${{ matrix.java_version }})
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
cache: 'gradle'
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2.4.0
- name: Build Android debug and release files
run: |
mkdir whatsNewDirectory
echo "Nothing changed so far" > whatsNewDirectory/whatsnew-en-US
set -x
./gradlew :android:bundleDebug
./gradlew :android:assembleDebug
./gradlew :android:bundleRelease
./gradlew :android:assembleRelease
- name: Upload Android artifacts
uses: actions/upload-artifact@v3
with:
name: Android (built with Java ${{ matrix.java_version }})
path: |
android/build/outputs/apk/*/*.apk
android/build/outputs/bundle/*/*.aab
retention-days: 1
continue-on-error: true
# Job to build the desktop and server JAR files on all available platforms
build-desktop:
defaults:
run:
# Ensures that a UNIX-like shell is available (default would be Powershell on Windows)
shell: sh
name: Build Desktop for ${{ matrix.os }} (Java ${{ matrix.java_version }})
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
java_version:
- 11
- 17
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
cache: 'gradle'
distribution: 'temurin'
java-version: ${{ matrix.java_version }}
- name: Setup Gradle
uses: gradle/gradle-build-action@v2.4.0
- name: Build the Desktop app
run: ./gradlew desktop:dist
- name: Build the Java server
run: ./gradlew server:dist
- name: Upload Desktop artifacts
uses: actions/upload-artifact@v3
with:
name: Desktop (built with Java ${{ matrix.java_version }})
path: desktop/build/libs/*.jar
retention-days: 1
# Only run this step on ubuntu-latest, since Java is cross-platform anyways
if: ${{ matrix.os == 'ubuntu-latest' }}
continue-on-error: true
- name: Upload Java server artifacts
uses: actions/upload-artifact@v3
with:
name: Server (built with Java ${{ matrix.java_version }})
path: server/build/libs/*.jar
retention-days: 1
# Only run this step on ubuntu-latest, since Java is cross-platform anyways
if: ${{ matrix.os == 'ubuntu-latest' }}
continue-on-error: true

View File

@ -89,7 +89,7 @@ project(":android") {
dependencies { dependencies {
"implementation"(project(":core")) "implementation"(project(":core"))
"implementation"("com.badlogicgames.gdx:gdx-backend-android:$gdxVersion") "implementation"("com.badlogicgames.gdx:gdx-backend-android:$gdxVersion")
"implementation"("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1") "implementation"("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4")
natives("com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a") natives("com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a")
natives("com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a") natives("com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a")
natives("com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86") natives("com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86")
@ -116,7 +116,7 @@ project(":core") {
dependencies { dependencies {
"implementation"("com.badlogicgames.gdx:gdx:$gdxVersion") "implementation"("com.badlogicgames.gdx:gdx:$gdxVersion")
"implementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1") "implementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
"implementation"("org.jetbrains.kotlin:kotlin-reflect:${com.unciv.build.BuildConfig.kotlinVersion}") "implementation"("org.jetbrains.kotlin:kotlin-reflect:${com.unciv.build.BuildConfig.kotlinVersion}")
} }
@ -129,18 +129,18 @@ project(":core") {
dependencies { dependencies {
"implementation"(project(":core")) "implementation"(project(":core"))
"implementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1") "implementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
"implementation"("junit:junit:4.13.1") "implementation"("junit:junit:4.13.2")
"implementation"("org.mockito:mockito-all:1.10.19") "implementation"("org.mockito:mockito-core:5.1.1")
"implementation"("com.badlogicgames.gdx:gdx-backend-lwjgl3:${gdxVersion}") "implementation"("com.badlogicgames.gdx:gdx-backend-lwjgl3:${gdxVersion}")
"implementation"("com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop") "implementation"("com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop")
"implementation"("com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion") "implementation"("com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion")
"implementation"("com.badlogicgames.gdx:gdx:$gdxVersion") "implementation"("com.badlogicgames.gdx:gdx:$gdxVersion")
"testImplementation"("junit:junit:4.13.1") "testImplementation"("junit:junit:4.13.2")
"testImplementation"("org.mockito:mockito-all:1.10.19") "testImplementation"("org.mockito:mockito-core:5.1.1")
"testImplementation"("io.mockk:mockk:1.9.3") "testImplementation"("io.mockk:mockk:1.9.3")
"testImplementation"("com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion") "testImplementation"("com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion")