Skip to content

Commit 095aaac

Browse files
Add Dokka API docs setup and GitHub Pages deploy workflow (#15)
* Add Dokka public API docs and Pages deploy workflow * Use Copy task for dokkaPublicApi output aggregation * Prevent Pages deploy job from being cancelled by concurrency * Use safe copy for Pages artifact staging * Handle cancelled CI runs in test summary output * Skip PR test summary comment on cancelled runs * Update scripts/ci-test-summary.sh Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com> * Speed up lint workflow by removing redundant cache and verbose logging * Make Android Dokka source set configuration idempotent * Remove --info from test workflow commands --------- Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
1 parent b27477b commit 095aaac

File tree

13 files changed

+147
-25
lines changed

13 files changed

+147
-25
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Deploy API Docs
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [main]
7+
paths:
8+
- "lib/**"
9+
- ".github/workflows/deploy-gh-pages.yml"
10+
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
jobs:
17+
build:
18+
name: Build Dokka Docs
19+
runs-on: ubuntu-latest
20+
concurrency:
21+
group: pages-build-${{ github.ref }}
22+
cancel-in-progress: true
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Set up JDK 17
28+
uses: actions/setup-java@v4
29+
with:
30+
distribution: zulu
31+
java-version: "17"
32+
cache: gradle
33+
34+
- name: Generate Dokka docs
35+
run: ./gradlew -p lib dokkaPublicApi --no-daemon
36+
37+
- name: Prepare Pages artifact
38+
shell: bash
39+
run: |
40+
set -euo pipefail
41+
mkdir -p site
42+
cp -R lib/build/dokka/public-api/. site/
43+
44+
cat > site/index.html << 'EOF'
45+
<!doctype html>
46+
<html>
47+
<head>
48+
<meta charset="utf-8">
49+
<meta name="viewport" content="width=device-width,initial-scale=1">
50+
<title>Compose GIF Recorder API</title>
51+
</head>
52+
<body>
53+
<h1>Compose GIF Recorder API</h1>
54+
<ul>
55+
<li><a href="./recorder-annotations/">Annotations</a></li>
56+
<li><a href="./recorder-core/">Core</a></li>
57+
<li><a href="./recorder-ksp/">KSP</a></li>
58+
<li><a href="./recorder-android/">Android</a></li>
59+
<li><a href="./recorder-gradle-plugin/">Gradle Plugin</a></li>
60+
</ul>
61+
</body>
62+
</html>
63+
EOF
64+
65+
- name: Configure Pages
66+
uses: actions/configure-pages@v5
67+
68+
- name: Upload Pages artifact
69+
uses: actions/upload-pages-artifact@v3
70+
with:
71+
path: site
72+
73+
deploy:
74+
name: Deploy to GitHub Pages
75+
needs: build
76+
runs-on: ubuntu-latest
77+
concurrency:
78+
group: pages-deploy
79+
cancel-in-progress: false
80+
environment:
81+
name: github-pages
82+
url: ${{ steps.deployment.outputs.page_url }}
83+
steps:
84+
- name: Deploy
85+
id: deployment
86+
uses: actions/deploy-pages@v4

.github/workflows/lint.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,12 @@ jobs:
3333
java-version: 17
3434
distribution: 'zulu'
3535
cache: gradle
36-
- name: Cache Gradle packages
37-
if: steps.changes.outputs.should_run == 'true'
38-
uses: actions/cache@v4
39-
with:
40-
path: |
41-
~/.gradle/caches
42-
~/.gradle/wrapper
43-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
44-
restore-keys: |
45-
${{ runner.os }}-gradle-
4636
- name: Lint
4737
if: steps.changes.outputs.should_run == 'true'
4838
run: |
4939
set -euo pipefail
50-
./gradlew ktlintCheck --info
51-
cd lib
52-
./gradlew ktlintCheck --info
40+
./gradlew ktlintCheck
41+
./gradlew -p lib ktlintCheck
5342
- name: Skip lint for docs-only changes
5443
if: steps.changes.outputs.should_run != 'true'
5544
run: echo "No code/build changes detected. Skipping lint."

.github/workflows/pr-test-summary-comment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
comment:
1616
name: Comment test summary on PR
1717
runs-on: ubuntu-latest
18-
if: ${{ github.event.workflow_run.event == 'pull_request' }}
18+
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion != 'cancelled' }}
1919
steps:
2020
- name: Download summary artifact
2121
continue-on-error: true

.github/workflows/test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ jobs:
4848
if: steps.changes.outputs.should_run == 'true'
4949
run: |
5050
set -euo pipefail
51-
./gradlew appTest --info
51+
./gradlew appTest
5252
cd lib
53-
./gradlew recorderTest --info
53+
./gradlew recorderTest
5454
- name: Test summary
5555
if: always()
5656
env:
5757
CI_GRADLE_TEST_OUTCOME: ${{ steps.gradle_tests.outcome }}
58+
CI_JOB_STATUS: ${{ job.status }}
5859
CI_SHOULD_RUN: ${{ steps.changes.outputs.should_run }}
5960
run: bash scripts/ci-test-summary.sh
6061
- name: Ensure summary files exist
@@ -64,6 +65,7 @@ jobs:
6465
CI_TEST_SUMMARY_FORCE_ZERO=true \
6566
CI_TEST_SUMMARY_SKIP_STEP_SUMMARY=true \
6667
CI_GRADLE_TEST_OUTCOME="${{ steps.gradle_tests.outcome }}" \
68+
CI_JOB_STATUS="${{ job.status }}" \
6769
CI_SHOULD_RUN="${{ steps.changes.outputs.should_run }}" \
6870
bash scripts/ci-test-summary.sh
6971
fi

lib/build.gradle.kts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import org.gradle.api.tasks.Copy
2+
13
plugins {
24
base
5+
alias(libs.plugins.dokka) apply false
36
alias(libs.plugins.kotlin.jvm) apply false
47
alias(libs.plugins.kotlin.compose) apply false
58
alias(libs.plugins.android.library) apply false
@@ -8,6 +11,14 @@ plugins {
811
alias(libs.plugins.ktlint) apply false
912
}
1013

14+
val publishableModules = listOf(
15+
":recorder-annotations",
16+
":recorder-core",
17+
":recorder-ksp",
18+
":recorder-android",
19+
":recorder-gradle-plugin"
20+
)
21+
1122
subprojects {
1223
apply(plugin = "org.jlleitschuh.gradle.ktlint")
1324

@@ -27,14 +38,6 @@ allprojects {
2738
}
2839
}
2940

30-
val publishableModules = listOf(
31-
":recorder-annotations",
32-
":recorder-core",
33-
":recorder-ksp",
34-
":recorder-android",
35-
":recorder-gradle-plugin"
36-
)
37-
3841
val testableJvmModules = listOf(
3942
":recorder-annotations",
4043
":recorder-core",
@@ -60,3 +63,16 @@ tasks.register("publishRecorderModulesToMavenLocal") {
6063
description = "Publishes all recorder modules to Maven Local"
6164
dependsOn(publishableModules.map { "$it:publishToMavenLocal" })
6265
}
66+
67+
tasks.register<Copy>("dokkaPublicApi") {
68+
group = "documentation"
69+
description = "Generates Dokka HTML docs for published recorder modules"
70+
dependsOn(publishableModules.map { "$it:dokkaGeneratePublicationHtml" })
71+
into(layout.buildDirectory.dir("dokka/public-api"))
72+
publishableModules.forEach { modulePath ->
73+
val moduleName = modulePath.removePrefix(":")
74+
from(project(modulePath).layout.buildDirectory.dir("dokka/html")) {
75+
into(moduleName)
76+
}
77+
}
78+
}

lib/gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8
22
android.useAndroidX=true
33
kotlin.code.style=official
4+
org.jetbrains.dokka.experimental.gradle.pluginMode=V2EnabledWithHelpers
45

56
#Maven Central Publishing (gradle-maven-publish-plugin 0.34.0+)
67
mavenCentralPublishing=true

lib/gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ androidx-test-ext = "1.3.0"
1010
junit4 = "4.13.2"
1111
kotlinpoet = "2.2.0"
1212
ktlint = "14.0.1"
13+
dokka = "2.1.0"
1314

1415
[libraries]
1516
compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "compose-ui" }
@@ -37,3 +38,4 @@ gradle-plugin-publish = { id = "java-gradle-plugin" }
3738
maven-publish = { id = "maven-publish" }
3839
vanniktech-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech-publish" }
3940
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
41+
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }

lib/recorder-android/build.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
alias(libs.plugins.android.library)
33
alias(libs.plugins.kotlin.compose)
4+
alias(libs.plugins.dokka)
45
`maven-publish`
56
signing
67
alias(libs.plugins.vanniktech.publish)
@@ -52,6 +53,19 @@ dependencies {
5253
debugImplementation(libs.compose.ui.test.manifest)
5354
}
5455

56+
dokka {
57+
dokkaSourceSets.maybeCreate("main").apply {
58+
sourceRoots.from(file("src/main/kotlin"))
59+
sourceRoots.from(file("src/main/java"))
60+
classpath.from(provider { configurations.getByName("releaseCompileClasspath") })
61+
analysisPlatform.set(org.jetbrains.dokka.gradle.engine.parameters.KotlinPlatform.AndroidJVM)
62+
documentedVisibilities.set(
63+
setOf(org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier.Public),
64+
)
65+
jdkVersion.set(17)
66+
}
67+
}
68+
5569
mavenPublishing {
5670
configure(
5771
com.vanniktech.maven.publish.AndroidSingleVariantLibrary(

lib/recorder-annotations/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
alias(libs.plugins.kotlin.jvm)
3+
alias(libs.plugins.dokka)
34
`maven-publish`
45
signing
56
alias(libs.plugins.vanniktech.publish)

lib/recorder-core/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
alias(libs.plugins.kotlin.jvm)
33
alias(libs.plugins.kotlin.compose)
4+
alias(libs.plugins.dokka)
45
`maven-publish`
56
signing
67
alias(libs.plugins.vanniktech.publish)

0 commit comments

Comments
 (0)