generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 480
211 lines (178 loc) · 6.81 KB
/
kmp-test.yml
File metadata and controls
211 lines (178 loc) · 6.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# GitHub Actions Workflow for testing KMP projects (mpp-core and mpp-ui)
# This workflow builds and tests the Kotlin Multiplatform modules
# Triggered on push to master and pull requests
name: KMP Test
on:
# Trigger the workflow on pushes to the 'master' branch
push:
branches: [ master ]
paths:
- 'mpp-core/**'
- 'mpp-ui/**'
- '.github/workflows/kmp-test.yml'
# Trigger the workflow on any pull request
pull_request:
paths:
- 'mpp-core/**'
- 'mpp-ui/**'
- '.github/workflows/kmp-test.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# Build and test mpp-core
test-mpp-core:
name: Test mpp-core (KMP)
runs-on: ubuntu-latest
env:
ANDROID_SDK_ROOT: ${{ github.workspace }}/android-sdk
steps:
# Free GitHub Actions Environment Disk Space
- name: Maximize Build Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
large-packages: false
- name: Setup Android SDK
uses: android-actions/setup-android@v3
# Check out the current repository
- name: Checkout code
uses: actions/checkout@v4
# Validate wrapper
- name: Gradle Wrapper Validation
uses: gradle/actions/wrapper-validation@v4
# Set up Java environment
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
# Accept Android SDK licenses
- name: Accept Android SDK licenses
run: |
yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses || true
- name: Write local.properties
run: echo "sdk.dir=${ANDROID_SDK_ROOT}" > local.properties
# Setup Gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
# Grant execute permission for gradlew
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# Clean mpp-core module only (not the entire project)
- name: Clean mpp-core
run: ./gradlew :mpp-core:clean
# Test mpp-core for all targets
- name: Test mpp-core
run: ./gradlew :mpp-core:cleanWasmJsBrowserTest :mpp-core:wasmJsBrowserTest
# Build JS package for CLI usage
- name: Build mpp-core JS package
run: ./gradlew :mpp-core:jsNodeProductionLibraryDistribution
# Upload build artifacts for debugging
- name: Upload mpp-core build artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: mpp-core-build-logs
path: |
mpp-core/build/reports/
mpp-core/build/test-results/
# Build and test mpp-ui (depends on mpp-core)
test-mpp-ui:
name: Test mpp-ui (KMP)
runs-on: macos-latest
needs: test-mpp-core # Ensure mpp-core builds successfully first
steps:
# Check out the current repository
- name: Checkout code
uses: actions/checkout@v4
# Check out the current repository
- name: Install linters
run: |
brew install pipx
brew install detekt pmd golangci-lint dotenv-linter hadolint actionlint gitleaks swiftlint
pipx install sqlfluff checkov yamllint pylint semgrep
npm install -g markdownlint-cli eslint htmlhint
# Validate wrapper
- name: Gradle Wrapper Validation
uses: gradle/actions/wrapper-validation@v4
# Set up Java environment
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
# Set up Android SDK (pre-installed on ubuntu-latest)
- name: Set up Android SDK
run: |
# Use ANDROID_HOME which is reliably set in GitHub Actions
export ANDROID_SDK_ROOT="${ANDROID_HOME:-/usr/local/lib/android/sdk}"
echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> $GITHUB_ENV
echo "Android SDK location: $ANDROID_SDK_ROOT"
ls -la $ANDROID_SDK_ROOT || echo "SDK directory not found at $ANDROID_SDK_ROOT"
# Create local.properties with Android SDK location
- name: Create local.properties
run: |
echo "sdk.dir=$ANDROID_SDK_ROOT" > local.properties
cat local.properties
echo "Verifying SDK directory exists..."
test -d "$ANDROID_SDK_ROOT" && echo "✓ SDK directory exists" || echo "✗ SDK directory not found"
# Accept Android SDK licenses
- name: Accept Android SDK licenses
run: |
yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses || true
# Setup Gradle
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
# Grant execute permission for gradlew
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# Build JS package for CLI usage
- name: Build mpp-core JS package
run: ./gradlew :mpp-core:jsNodeProductionLibraryDistribution
# Install pnpm for JS dependencies
- name: Install pnpm
run: npm install -g pnpm@10.20.0
# Install mpp-ui JS dependencies
- name: Install mpp-ui dependencies
run: pnpm install
working-directory: mpp-ui
# Fix yarn lock issues (if any)
- name: Fix yarn lock issues
run: ./gradlew kotlinUpgradeYarnLock || echo "Yarn lock upgrade failed, continuing..."
# Test mpp-ui for all targets (excluding wasmJs browser tests due to Webpack compatibility issues)
- name: Test mpp-ui
run: ./gradlew :mpp-ui:allTests -x compileTestDevelopmentExecutableKotlinJs -x wasmJsBrowserTest -x wasmJsTest
# Build Android Debug APK
- name: Build Android Debug APK
run: ./gradlew :mpp-ui:assembleDebug
# Build Desktop distribution (JVM)
- name: Build Desktop package
run: ./gradlew :mpp-ui:packageDistributionForCurrentOS
# Upload successful build outputs
- name: Upload mpp-ui outputs
if: success()
uses: actions/upload-artifact@v4
with:
name: mpp-ui-outputs
path: |
mpp-ui/build/outputs/apk/debug/*.apk
mpp-ui/build/compose/binaries/main/app/
# Summary job to report overall status
kmp-test-summary:
name: KMP Test Summary
runs-on: ubuntu-latest
needs: [test-mpp-core, test-mpp-ui]
if: always()
steps:
- name: Check test results
run: |
if [[ "${{ needs.test-mpp-core.result }}" == "success" ]] && [[ "${{ needs.test-mpp-ui.result }}" == "success" ]]; then
echo "✅ All KMP tests passed!"
exit 0
else
echo "❌ Some KMP tests failed:"
echo " - mpp-core: ${{ needs.test-mpp-core.result }}"
echo " - mpp-ui: ${{ needs.test-mpp-ui.result }}"
exit 1
fi