Skip to content

Commit a5be5c0

Browse files
authored
Improved CI time (#359)
* Removed `BUILD_TIME` field to allow full build caching * Simplified CI
1 parent ea7293b commit a5be5c0

18 files changed

Lines changed: 34 additions & 86 deletions

File tree

.github/workflows/ci-cd.yaml

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,18 @@ permissions:
1414
checks: write
1515
pull-requests: write
1616

17-
jobs:
18-
compute-projects:
19-
name: Compute projects
20-
runs-on: ubuntu-latest
21-
outputs:
22-
projects: ${{ steps.compute-projects.outputs.projects }}
23-
steps:
24-
- name: Checkout
25-
uses: actions/checkout@v6
26-
- id: compute-projects
27-
run: |
28-
PROJECTS=$(echo "plugin"; find "demo-project" -mindepth 1 -maxdepth 1 -type d | tr '/' ':')
29-
PROJECTS_JSON=$(echo "$PROJECTS" | jq -R . | sort | jq -sc .)
30-
echo "projects=$PROJECTS_JSON" >> "$GITHUB_OUTPUT"
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
3120

21+
jobs:
3222
build:
33-
name: Build (${{ matrix.project }})
34-
needs: compute-projects
35-
runs-on: ${{ contains(matrix.project, 'kmp') && 'macos' || 'ubuntu' }}-latest
23+
name: Build (${{ matrix.os }})
24+
runs-on: ${{ matrix.os }}-latest
3625
strategy:
3726
fail-fast: false
3827
matrix:
39-
project: ${{ fromJSON(needs.compute-projects.outputs.projects) }}
28+
os: [ ubuntu, macos ]
4029
steps:
4130
- name: Checkout
4231
uses: actions/checkout@v6
@@ -45,47 +34,20 @@ jobs:
4534
with:
4635
gradle-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
4736
- name: Test & Build
48-
run: ./gradlew ${{ matrix.project }}:build
37+
run: ./gradlew build ${{ matrix.os == 'macos' && '-PkmpOnly=true' || '' }}
4938
- name: Publish Test Report
5039
if: ${{ !cancelled() }}
5140
uses: gmazzo/publish-report-annotations@v1
5241
with:
53-
checkName: Test Results (${{ matrix.project }})
54-
55-
build-passed:
56-
name: Build passed
57-
runs-on: ubuntu-latest
58-
needs: build
59-
if: ${{ !cancelled() }}
60-
steps:
61-
- name: Build has passed
62-
if: ${{ needs.build.result != 'success' }}
63-
run: |
64-
echo "Build was not successful!"
65-
exit 1
66-
67-
publish:
68-
name: Publish
69-
runs-on: ubuntu-latest
70-
needs: build
71-
if: ${{ !cancelled() && !github.event.repository.fork && !github.event.pull_request.head.repo.fork }}
72-
steps:
73-
- name: Checkout
74-
uses: actions/checkout@v6
75-
with:
76-
fetch-depth: 0
77-
- name: Setup host
78-
uses: ./.github/actions/setup-host
79-
with:
80-
gradle-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
81-
- name: Build
82-
run: ./gradlew build
42+
checkName: Test Results (${{ matrix.os }})
8343
- name: Coverage report
44+
if: ${{ matrix.os == 'ubuntu' }}
8445
uses: codecov/codecov-action@v5
8546
with:
8647
token: ${{ secrets.CODECOV_TOKEN }}
8748
files: '**/build/reports/jacoco/**/*.xml'
8849
- name: Publish
50+
if: ${{ matrix.os == 'ubuntu' }}
8951
env:
9052
ORG_GRADLE_PROJECT_RELEASE_SIGNING_ENABLED: true
9153
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ buildConfig {
2727
buildConfigField("APP_VERSION", provider { "\"${project.version}\"" })
2828
buildConfigField("APP_SECRET", "Z3JhZGxlLWphdmEtYnVpbGRjb25maWctcGx1Z2lu")
2929
buildConfigField<String>("OPTIONAL", null)
30-
buildConfigField("BUILD_TIME", System.currentTimeMillis())
3130
buildConfigField("FEATURE_ENABLED", true)
3231
buildConfigField("MAGIC_NUMBERS", intArrayOf(1, 2, 3, 4))
3332
buildConfigField("STRING_LIST", arrayOf("a", "b", "c"))
@@ -47,7 +46,6 @@ internal object BuildConfig {
4746
internal const val APP_VERSION: String = "\"0.1.0-demo\""
4847
internal const val APP_SECRET: String = "Z3JhZGxlLWphdmEtYnVpbGRjb25maWctcGx1Z2lu"
4948
internal val OPTIONAL: String? = null
50-
internal const val BUILD_TIME: Long = 1_702_559_872_137L
5149
internal const val FEATURE_ENABLED: Boolean = true
5250
internal val MAGIC_NUMBERS: IntArray = intArrayOf(1, 2, 3)
5351
internal val STRING_LIST: Array<String> = arrayOf("a", "b", "c")
@@ -81,7 +79,6 @@ buildConfig {
8179
buildConfigField(String, "APP_VERSION", provider { project.version })
8280
buildConfigField(String, 'APP_SECRET', "Z3JhZGxlLWphdmEtYnVpbGRjb25maWctcGx1Z2lu")
8381
buildConfigField(String, 'OPTIONAL', null)
84-
buildConfigField(long, 'BUILD_TIME', System.currentTimeMillis())
8582
buildConfigField(boolean, 'FEATURE_ENABLED', true)
8683
buildConfigField(int[], "MAGIC_NUMBERS", [1, 2, 3])
8784
buildConfigField('List<String>', "STRING_LIST", ["a", "b", "c"])
@@ -100,7 +97,6 @@ final class BuildConfig {
10097
public static final String APP_VERSION = "0.1.0-demo";
10198
public static final String APP_SECRET = "Z3JhZGxlLWphdmEtYnVpbGRjb25maWctcGx1Z2lu";
10299
public static final String OPTIONAL = null;
103-
public static final long BUILD_TIME = 1702559872111L;
104100
public static final boolean FEATURE_ENABLED = true;
105101
public static final int[] MAGIC_NUMBERS = {1, 2, 3};
106102
public static final String[] STRING_LIST = {"a", "b", "c"};

build.gradle.kts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,21 @@ dependencies {
1818
jacocoAggregation("com.github.gmazzo.buildconfig:plugin")
1919
}
2020

21+
val kmpOnly: String? by project
2122
val pluginBuild = gradle.includedBuild("plugin")
2223

2324
val jacocoTestReport by reporting.reports.creating(JacocoCoverageReport::class) {
2425
testSuiteName = pluginBuild.task(":test").name
2526
}
2627

27-
tasks.build {
28-
dependsOn(pluginBuild.task(":$name"))
29-
}
28+
if (kmpOnly == null) {
29+
tasks.build {
30+
dependsOn(pluginBuild.task(":$name"))
31+
}
3032

31-
tasks.check {
32-
dependsOn(jacocoTestReport.reportTask, pluginBuild.task(":$name"))
33+
tasks.check {
34+
dependsOn(jacocoTestReport.reportTask, pluginBuild.task(":$name"))
35+
}
3336
}
3437

3538
tasks.publish {

demo-project/generic/build.gradle.kts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ plugins {
1717
buildConfig {
1818
buildConfigField("String", "APP_NAME", "\"${project.name}\"")
1919
buildConfigField("String", "APP_SECRET", "\"Z3JhZGxlLWphdmEtYnVpbGRjb25maWctcGx1Z2lu\"")
20-
buildConfigField("long", "BUILD_TIME", "${TimeUnit.DAYS.toMillis(2)}")
2120
buildConfigField("boolean", "FEATURE_ENABLED", "${true}")
2221

2322
forClass("BuildResources") {
@@ -48,8 +47,6 @@ val generateBuildConfigTest by tasks.registering(AssertGeneratedFile::class) {
4847
4948
public static final String APP_SECRET = "Z3JhZGxlLWphdmEtYnVpbGRjb25maWctcGx1Z2lu";
5049
51-
public static final long BUILD_TIME = 172800000;
52-
5350
public static final boolean FEATURE_ENABLED = true;
5451
5552
public static final String PROVIDED = "byAddLater";

demo-project/groovy-gen-kotlin/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ buildConfig {
2121
buildConfigField(String, "APP_VERSION", provider { project.version })
2222
buildConfigField(String, 'APP_SECRET', "Z3JhZGxlLWphdmEtYnVpbGRjb25maWctcGx1Z2lu")
2323
buildConfigField(String, 'OPTIONAL', null)
24-
buildConfigField(long, 'BUILD_TIME', System.currentTimeMillis())
2524
buildConfigField(boolean, 'FEATURE_ENABLED', true)
2625
buildConfigField('List<Int>', 'MAGIC_NUMBERS', [1, 2, 3])
2726

demo-project/groovy/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ buildConfig {
2020
buildConfigField(String, "APP_VERSION", provider { project.version })
2121
buildConfigField(String, 'APP_SECRET', "Z3JhZGxlLWphdmEtYnVpbGRjb25maWctcGx1Z2lu")
2222
buildConfigField(String, 'OPTIONAL', null)
23-
buildConfigField(long, 'BUILD_TIME', System.currentTimeMillis())
2423
buildConfigField(boolean, 'FEATURE_ENABLED', true)
2524
buildConfigField('List<Int>', 'MAGIC_NUMBERS', [1, 2, 3])
2625

demo-project/groovy/src/testFixtures/java/com/github/gmazzo/buildconfig/demos/groovy/BuildConfigBaseTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public void testBuildConfigProperties(Object expected, Object actual) {
6565
{"0.1.0-demo", BuildConfig.APP_VERSION},
6666
{"Z3JhZGxlLWphdmEtYnVpbGRjb25maWctcGx1Z2lu", BuildConfig.APP_SECRET},
6767
{null, BuildConfig.OPTIONAL},
68-
{true, System.currentTimeMillis() >= BuildConfig.BUILD_TIME},
6968
{true, BuildConfig.FEATURE_ENABLED},
7069
{Arrays.asList(1, 2, 3), BuildConfig.MAGIC_NUMBERS},
7170

demo-project/kts-android-lib/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ android {
2828

2929
buildConfigField("APP_NAME", project.name)
3030
buildConfigField("APP_SECRET", "Z3JhZGxlLWphdmEtYnVpbGRjb25maWctcGx1Z2lu")
31-
buildConfigField("BUILD_TIME", System.currentTimeMillis())
3231
buildConfigField("FEATURE_ENABLED", true)
3332
buildConfigField("MAGIC_NUMBERS", intArrayOf(1, 2, 3, 4))
3433

demo-project/kts-android-lib/src/test/kotlin/com/github/gmazzo/buildconfig/demos/kts_android_lib/BuildConfigTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class BuildConfigTest : BuildConfigBaseTest() {
1111

1212
arrayOf("kts-android-lib", BuildConfig.APP_NAME),
1313
arrayOf("Z3JhZGxlLWphdmEtYnVpbGRjb25maWctcGx1Z2lu", BuildConfig.APP_SECRET),
14-
arrayOf(true, System.currentTimeMillis() >= BuildConfig.BUILD_TIME),
1514
arrayOf(true, BuildConfig.FEATURE_ENABLED),
1615
arrayOf(listOf(1, 2, 3, 4), BuildConfig.MAGIC_NUMBERS.toList()),
1716

demo-project/kts-android/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ android {
3535

3636
buildConfigField("APP_NAME", project.name)
3737
buildConfigField("APP_SECRET", "Z3JhZGxlLWphdmEtYnVpbGRjb25maWctcGx1Z2lu")
38-
buildConfigField("BUILD_TIME", System.currentTimeMillis())
3938
buildConfigField("FEATURE_ENABLED", true)
4039
buildConfigField("MAGIC_NUMBERS", intArrayOf(1, 2, 3, 4))
4140

0 commit comments

Comments
 (0)