Skip to content

Commit

Permalink
ci: Experiment with simpler CI steps
Browse files Browse the repository at this point in the history
Current CI performs matrix builds for the different colour and store
variants.

In theory this allows a build to succeed for most variants and fail
for only one.

In practice, this is of limited use, as an issue that causes one variant
to file will likely cause them all to fail.

The separate builds require a lengthy configuration phase because the
configuration cache is not shared or restored across builds.

Experiment with a simpler CI workflow that checks and asssembles all
variants at once.

As well as avoiding the repeated configuration phases this may allow
better parallelisation across the build steps for different variants.

As part of this cleanup:

- Remove unnecessary `gradle.properties` and `settings.gradle` files for
  projects that are included as subprojects, not included builds.

- Provide a build convention plugin for command line tools, and use
  `libs.versions.toml` for command line tool dependencies. Adjust the
  individual tool `build.gradle.kts` files accordingly.

- Add a trivial test for each command line tool so there are tests to
  run and provide some confidence that automated library upgrades don't
  break command line tool compilation.
  • Loading branch information
nikclayton committed Apr 12, 2024
1 parent 4d7f8d4 commit e979c0f
Show file tree
Hide file tree
Showing 18 changed files with 174 additions and 148 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on:
push:
tags:
- '*'
pull_request:
workflow_dispatch:

permissions: read-all

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4
with:
java-version: '17'
distribution: 'temurin'

- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@b231772637bb498f11fdbc86052b6e8a8dc9fc92 # v2

- name: Copy CI gradle.properties
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

- name: Setup Gradle
uses: gradle/actions/setup-gradle@1168cd3d07c1876a65e1724114de42ccbdfa7b78 # v3
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}

# Disable the configuration cache; it's not restored, or saved at the end, so this
# removes any overhead trying to load or save it.
- name: Check and assemble everything
run: ./gradlew --no-configuration-cache build
4 changes: 4 additions & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,9 @@ gradlePlugin {
id = "pachli.android.lint"
implementationClass = "AndroidLintConventionPlugin"
}
register("tool") {
id = "pachli.tool"
implementationClass = "ToolConventionPlugin"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2024 Pachli Association
*
* This file is a part of Pachli.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Pachli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Pachli; if not,
* see <http://www.gnu.org/licenses>.
*/

import app.pachli.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies

class ToolConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
dependencies {
add("implementation", libs.findLibrary("kotlin-logging-jvm").get())
add("implementation", libs.findLibrary("logback").get())
add("implementation", libs.findLibrary("clikt").get())

add("testImplementation", libs.findLibrary("truth").get())
add("testImplementation", libs.findLibrary("junit-jupiter").get())
add("testImplementation", libs.findLibrary("junit-jupiter-params").get())
add("testRuntimeOnly", "org.junit.platform:junit-platform-launcher")
}
}
}
}
21 changes: 0 additions & 21 deletions checks/gradle.properties

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class IntentDetector : Detector(), Detector.UastScanner {
Creating an `Intent` with a class from another module can create unnecessary or circular
dependencies. Use the `...Intent` classes in `core.navigation` to create an intent for
the appropriate `Activity`.
""".trimIndent(),
""",
category = Category.CORRECTNESS,
priority = 6,
severity = Severity.WARNING,
Expand Down
4 changes: 4 additions & 0 deletions core/navigation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ dependencies {

implementation(libs.androidx.core.ktx) // IntentCompat
}

// ktlint checks generated files (https://github.com/JLLeitschuh/ktlint-gradle/issues/580) so
// ensure it's run after the navigation files have been created.
tasks.named("runKtlintCheckOverMainSourceSet").configure { dependsOn(":core:navigation:generateActivityClassNameConstants") }
20 changes: 10 additions & 10 deletions core/testing/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.3.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.3.0)" variant="all" version="8.3.0">
<issues format="6" by="lint 8.3.1" type="baseline" client="gradle" dependencies="false" name="AGP (8.3.1)" variant="all" version="8.3.1">

<issue
id="InvalidPackage"
message="Invalid package reference in org.bouncycastle:bcprov-jdk18on; not included in Android: `javax.naming.directory`. Referenced from `org.bouncycastle.jce.provider.CrlCache`.">
<location
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk18on/1.76/3a785d0b41806865ad7e311162bfa3fa60b3965b/bcprov-jdk18on-1.76.jar"/>
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk18on/1.77/2cc971b6c20949c1ff98d1a4bc741ee848a09523/bcprov-jdk18on-1.77.jar"/>
</issue>

<issue
id="InvalidPackage"
message="Invalid package reference in org.bouncycastle:bcprov-jdk18on; not included in Android: `javax.naming`. Referenced from `org.bouncycastle.jce.provider.X509LDAPCertStoreSpi`.">
<location
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk18on/1.76/3a785d0b41806865ad7e311162bfa3fa60b3965b/bcprov-jdk18on-1.76.jar"/>
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.bouncycastle/bcprov-jdk18on/1.77/2cc971b6c20949c1ff98d1a4bc741ee848a09523/bcprov-jdk18on-1.77.jar"/>
</issue>

<issue
Expand All @@ -26,49 +26,49 @@
id="InvalidPackage"
message="Invalid package reference in org.robolectric:resources; not included in Android: `javax.xml.stream`. Referenced from `org.robolectric.res.NodeHandler`.">
<location
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.robolectric/resources/4.11.1/21e05203a923c9cfee41583dbe33bef361a8a210/resources-4.11.1.jar"/>
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.robolectric/resources/4.12.1/27d487d37469973f0f84e56706730db2705aa6b8/resources-4.12.1.jar"/>
</issue>

<issue
id="InvalidPackage"
message="Invalid package reference in org.robolectric:shadows-framework; not included in Android: `java.awt.geom`. Referenced from `org.robolectric.shadows.CachedPathIteratorFactory`.">
<location
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.robolectric/shadows-framework/4.11.1/e8ff683a932c20bb7b1d81a7b65c912734caee4/shadows-framework-4.11.1.jar"/>
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.robolectric/shadows-framework/4.12.1/356321ebb0ef309b3fbcb9865b0e682287abfd0f/shadows-framework-4.12.1.jar"/>
</issue>

<issue
id="InvalidPackage"
message="Invalid package reference in org.robolectric:shadows-framework; not included in Android: `java.awt.image`. Referenced from `org.robolectric.shadows.AutoValue_ImageUtil_RobolectricBufferedImage`.">
<location
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.robolectric/shadows-framework/4.11.1/e8ff683a932c20bb7b1d81a7b65c912734caee4/shadows-framework-4.11.1.jar"/>
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.robolectric/shadows-framework/4.12.1/356321ebb0ef309b3fbcb9865b0e682287abfd0f/shadows-framework-4.12.1.jar"/>
</issue>

<issue
id="InvalidPackage"
message="Invalid package reference in org.robolectric:shadows-framework; not included in Android: `java.awt`. Referenced from `org.robolectric.shadows.ImageUtil`.">
<location
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.robolectric/shadows-framework/4.11.1/e8ff683a932c20bb7b1d81a7b65c912734caee4/shadows-framework-4.11.1.jar"/>
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.robolectric/shadows-framework/4.12.1/356321ebb0ef309b3fbcb9865b0e682287abfd0f/shadows-framework-4.12.1.jar"/>
</issue>

<issue
id="InvalidPackage"
message="Invalid package reference in org.robolectric:shadows-framework; not included in Android: `javax.imageio.stream`. Referenced from `org.robolectric.shadows.ImageUtil`.">
<location
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.robolectric/shadows-framework/4.11.1/e8ff683a932c20bb7b1d81a7b65c912734caee4/shadows-framework-4.11.1.jar"/>
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.robolectric/shadows-framework/4.12.1/356321ebb0ef309b3fbcb9865b0e682287abfd0f/shadows-framework-4.12.1.jar"/>
</issue>

<issue
id="InvalidPackage"
message="Invalid package reference in org.robolectric:shadows-framework; not included in Android: `javax.imageio`. Referenced from `org.robolectric.shadows.ImageUtil`.">
<location
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.robolectric/shadows-framework/4.11.1/e8ff683a932c20bb7b1d81a7b65c912734caee4/shadows-framework-4.11.1.jar"/>
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.robolectric/shadows-framework/4.12.1/356321ebb0ef309b3fbcb9865b0e682287abfd0f/shadows-framework-4.12.1.jar"/>
</issue>

<issue
id="InvalidPackage"
message="Invalid package reference in org.robolectric:utils; not included in Android: `javax.inject`. Referenced from `org.robolectric.util.inject.Injector`.">
<location
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.robolectric/utils/4.11.1/12828864aac49e8ebcf2de03d3d33919ca8a1b01/utils-4.11.1.jar"/>
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.robolectric/utils/4.12.1/d5a680f8c337bea14ef9a410e30e683c11e4b429/utils-4.12.1.jar"/>
</issue>

</issues>
18 changes: 18 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ turbine = "1.1.0"
unified-push = "2.1.1"
xmlwriter = "1.0.4"

# Tool dependencies
betterparse = "0.4.4"
clikt = "4.3.0"
icu4j = "74.2"
junit-jupiter = "5.10.2"
kotlin-logging-jvm = "6.0.4"
logback = "1.5.3"

[plugins]
aboutlibraries = { id = "com.mikepenz.aboutlibraries.plugin", version.ref = "aboutlibraries" }
android-application = { id = "com.android.application", version.ref = "agp" }
Expand All @@ -94,6 +102,7 @@ pachli-android-application-flavors = { id = "pachli.android.application.flavors"
pachli-android-hilt = { id = "pachli.android.hilt", version = "unspecified" }
pachli-android-library = { id = "pachli.android.library", version = "unspecified" }
pachli-android-room = { id = "pachli.android.room", version = "unspecified" }
pachli-tool = { id = "pachli.tool", version = "unspecified" }

[libraries]
aboutlibraries-core = { module = "com.mikepenz:aboutlibraries-core", version.ref = "aboutlibraries" }
Expand Down Expand Up @@ -162,6 +171,8 @@ hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt"
hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hilt" }
hilt-android-testing = { module = "com.google.dagger:hilt-android-testing", version.ref = "hilt" }
junit = { module = "junit:junit", version.ref = "junit" }
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit-jupiter" }
kotlin-result = { module = "com.michael-bull.kotlin-result:kotlin-result", version.ref = "kotlin-result" }
kotlin-result-coroutines = { module = "com.michael-bull.kotlin-result:kotlin-result-coroutines", version.ref = "kotlin-result" }
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
Expand Down Expand Up @@ -200,6 +211,13 @@ turbine = { module = "app.cash.turbine:turbine", version.ref = "turbine" }
unified-push = { module = "com.github.UnifiedPush:android-connector", version.ref = "unified-push" }
xmlwriter = { module = "org.pageseeder.xmlwriter:pso-xmlwriter", version.ref = "xmlwriter" }

# Tool libraries
betterparse = { module = "com.github.h0tk3y.betterParse:better-parse", version.ref = "betterparse" }
clikt = { module = "com.github.ajalt.clikt:clikt", version.ref = "clikt" }
icu4j = { module = "com.ibm.icu:icu4j", version.ref = "icu4j"}
kotlin-logging-jvm = { module = "io.github.oshai:kotlin-logging-jvm", version.ref = "kotlin-logging-jvm" }
logback = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }

# build-logic dependencies
android-gradlePlugin = { module = "com.android.tools.build:gradle", version.ref = "agp" }
kotlin-gradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ include(":core:ui")
include(":feature:about")
include(":feature:lists")
include(":feature:login")
include(":tools")
include(":tools:mklanguages")
include(":tools:mkserverversions")
include(":tools:mvstring")
Expand Down
12 changes: 8 additions & 4 deletions tools/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
alias(libs.plugins.kotlin.jvm)
}

subprojects {
apply(plugin = "kotlin")
apply(plugin = "application")

dependencies {
add("implementation", "com.github.ajalt.clikt:clikt:4.3.0")
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn"
}
}

tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
}
23 changes: 6 additions & 17 deletions tools/mklanguages/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,15 @@
* see <http://www.gnu.org/licenses>.
*/

plugins {
alias(libs.plugins.pachli.tool)
}

application {
mainClass = "app.pachli.mklanguages.MainKt"
}

dependencies {
// ICU
implementation("com.ibm.icu:icu4j:74.2")

// Parsing
implementation("com.github.h0tk3y.betterParse:better-parse:0.4.4")

// Logging
implementation("io.github.oshai:kotlin-logging-jvm:6.0.4")
implementation("ch.qos.logback:logback-classic:1.5.3")

// Testing
testImplementation(kotlin("test"))
testImplementation("org.junit.jupiter:junit-jupiter-params:5.10.2") // for parameterized tests
}

tasks.test {
useJUnitPlatform()
implementation(libs.betterparse)
implementation(libs.icu4j)
}
30 changes: 0 additions & 30 deletions tools/mklanguages/settings.gradle.kts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Pachli Association
* Copyright 2024 Pachli Association
*
* This file is a part of Pachli.
*
Expand All @@ -15,16 +15,17 @@
* see <http://www.gnu.org/licenses>.
*/

dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
versionCatalogs {
create("libs") {
from(files("../../gradle/libs.versions.toml"))
}
package app.pachli.mklanguages

import com.github.ajalt.clikt.testing.test
import com.google.common.truth.Truth.assertThat
import org.junit.jupiter.api.Test

class AppTest {
@Test
fun testHelp() {
val app = App()
val result = app.test("--help")
assertThat(result.statusCode).isEqualTo(0)
}
}

rootProject.name = "mvstring"
Loading

0 comments on commit e979c0f

Please sign in to comment.