|
| 1 | +# GitHub Actions Workflows |
| 2 | + |
| 3 | +This directory contains CI/CD workflows for the PeopleInSpace project. |
| 4 | + |
| 5 | +## Workflows |
| 6 | + |
| 7 | +### Platform-Specific Workflows |
| 8 | + |
| 9 | +#### `android.yml` - Android CI |
| 10 | +- **Trigger**: Pull requests |
| 11 | +- **Jobs**: |
| 12 | + - Build: Builds Android app and runs unit tests |
| 13 | + - AndroidTest: Runs instrumentation tests on Android emulator (API 26) |
| 14 | +- **Runner**: ubuntu-24.04 |
| 15 | + |
| 16 | +#### `ios.yml` - iOS CI |
| 17 | +- **Trigger**: Pull requests |
| 18 | +- **Jobs**: Builds iOS app using Xcode |
| 19 | +- **Runner**: macos-14 |
| 20 | +- **Concurrency**: Cancels previous runs from same PR |
| 21 | + |
| 22 | +#### `web.yml` - Web CI |
| 23 | +- **Trigger**: Pull requests |
| 24 | +- **Jobs**: Builds WebAssembly app |
| 25 | +- **Runner**: ubuntu-24.04 |
| 26 | +- **Note**: Has commented-out deployment to GitHub Pages |
| 27 | + |
| 28 | +#### `wearos.yml` - Wear OS CI |
| 29 | +- **Trigger**: Pull requests |
| 30 | +- **Jobs**: Builds Wear OS app |
| 31 | +- **Runner**: ubuntu-24.04 |
| 32 | + |
| 33 | +#### `maestro.yml` - E2E Tests |
| 34 | +- **Trigger**: Pull requests |
| 35 | +- **Jobs**: Runs end-to-end tests using Maestro |
| 36 | +- **Runner**: ubuntu-24.04 |
| 37 | + |
| 38 | +### Multiplatform Test Workflows |
| 39 | + |
| 40 | +#### `compose-ui-tests.yml` - Compose UI Tests (Recommended) |
| 41 | +- **Trigger**: Pull requests and pushes to main/master |
| 42 | +- **Purpose**: Runs Compose Multiplatform UI tests from `common/src/commonTest` |
| 43 | +- **Platform**: JVM (fastest and most reliable for CI) |
| 44 | +- **Features**: |
| 45 | + - Runs all UI tests matching `*Ui*` pattern |
| 46 | + - Uploads test results as artifacts (7 day retention) |
| 47 | + - Publishes detailed test report with pass/fail information |
| 48 | + - Uses Gradle caching for faster builds |
| 49 | + - Cancels in-progress runs on new commits |
| 50 | + |
| 51 | +**Test Files Covered**: |
| 52 | +- `ComposeMultiplatformUiTests.kt` - Basic UI component tests |
| 53 | +- `ISSPositionUiTests.kt` - ISS position display tests |
| 54 | +- `ViewModelUiTests.kt` - ViewModel integration tests |
| 55 | +- `TestTagExampleTests.kt` - Test tag usage examples |
| 56 | + |
| 57 | +#### `multiplatform-tests.yml` - Full Platform Coverage |
| 58 | +- **Trigger**: Pull requests and pushes to main/master |
| 59 | +- **Purpose**: Runs common module tests on all supported platforms |
| 60 | +- **Jobs**: |
| 61 | + 1. **jvm-tests**: Runs tests on JVM (Linux) |
| 62 | + 2. **android-tests**: Runs Android unit tests (Robolectric) |
| 63 | + 3. **ios-tests**: Runs iOS simulator tests (macOS) |
| 64 | + 4. **wasm-tests**: Runs WebAssembly tests |
| 65 | + 5. **test-summary**: Aggregates results from all platforms |
| 66 | + |
| 67 | +**Note**: This workflow is more comprehensive but takes longer to complete due to multiple platform builds. |
| 68 | + |
| 69 | +## Choosing Between Workflows |
| 70 | + |
| 71 | +### Use `compose-ui-tests.yml` when: |
| 72 | +- ✅ You want fast feedback on UI tests (2-3 minutes) |
| 73 | +- ✅ You're primarily testing UI logic that's platform-agnostic |
| 74 | +- ✅ You want detailed test reports in PR checks |
| 75 | +- ✅ You need quick iteration during development |
| 76 | + |
| 77 | +### Use `multiplatform-tests.yml` when: |
| 78 | +- ✅ You need to verify tests pass on all platforms |
| 79 | +- ✅ You're testing platform-specific behavior |
| 80 | +- ✅ You're preparing for a release |
| 81 | +- ✅ You have time for longer CI runs (10-15 minutes) |
| 82 | + |
| 83 | +## Local Testing |
| 84 | + |
| 85 | +Before pushing, run tests locally to catch issues early: |
| 86 | + |
| 87 | +```bash |
| 88 | +# Run UI tests on JVM (fastest) |
| 89 | +./gradlew :common:jvmTest --tests "*Ui*" |
| 90 | + |
| 91 | +# Run all common tests on JVM |
| 92 | +./gradlew :common:jvmTest |
| 93 | + |
| 94 | +# Run Android tests |
| 95 | +./gradlew :common:testDebugUnitTest |
| 96 | + |
| 97 | +# Run iOS tests (macOS only) |
| 98 | +./gradlew :common:iosSimulatorArm64Test |
| 99 | + |
| 100 | +# Run WebAssembly tests |
| 101 | +./gradlew :common:wasmJsTest |
| 102 | + |
| 103 | +# Run all platform tests |
| 104 | +./gradlew :common:test |
| 105 | +``` |
| 106 | + |
| 107 | +## Test Results |
| 108 | + |
| 109 | +Test results are uploaded as artifacts and accessible in the GitHub Actions UI: |
| 110 | +- **Retention**: 7 days for UI test results |
| 111 | +- **Format**: HTML reports and JUnit XML |
| 112 | +- **Location**: Actions tab → Workflow run → Artifacts section |
| 113 | + |
| 114 | +## Troubleshooting |
| 115 | + |
| 116 | +### Tests Failing on CI but Passing Locally |
| 117 | + |
| 118 | +1. Check for timing issues - CI might be slower: |
| 119 | + ```kotlin |
| 120 | + testDispatcher.scheduler.advanceUntilIdle() |
| 121 | + waitForIdle() |
| 122 | + ``` |
| 123 | + |
| 124 | +2. Verify test isolation - tests should not depend on order |
| 125 | + |
| 126 | +3. Check platform-specific behavior |
| 127 | + |
| 128 | +### Gradle Build Issues |
| 129 | + |
| 130 | +- Ensure `kotlinUpgradeYarnLock` runs for WebAssembly builds |
| 131 | +- Check Java version (requires JDK 17) |
| 132 | +- Verify Gradle wrapper is up to date |
| 133 | + |
| 134 | +### iOS Test Failures |
| 135 | + |
| 136 | +- iOS tests require macOS runners (more expensive) |
| 137 | +- Consider running iOS tests only on main branch or release tags |
| 138 | + |
| 139 | +## Workflow Best Practices |
| 140 | + |
| 141 | +1. **Fast Feedback**: `compose-ui-tests.yml` runs quickly (~3 min) |
| 142 | +2. **Comprehensive Coverage**: `multiplatform-tests.yml` verifies all platforms |
| 143 | +3. **Artifact Retention**: Test results kept for 7 days for debugging |
| 144 | +4. **Concurrency Control**: Only latest run per PR/branch executes |
| 145 | +5. **Clear Naming**: Test artifacts clearly labeled by platform |
| 146 | + |
| 147 | +## Adding New Tests |
| 148 | + |
| 149 | +When adding new UI tests to `common/src/commonTest`: |
| 150 | + |
| 151 | +1. Follow naming convention: `*UiTests.kt` |
| 152 | +2. Tests will automatically run in CI (matched by `*Ui*` pattern) |
| 153 | +3. Use `@Test` annotation from `kotlin.test` |
| 154 | +4. Use `runComposeUiTest` for compose UI tests |
| 155 | +5. Add test tags for better test stability |
| 156 | + |
| 157 | +Example: |
| 158 | +```kotlin |
| 159 | +@Test |
| 160 | +fun myNewUiTest() = runComposeUiTest { |
| 161 | + setContent { MyComposable() } |
| 162 | + onNodeWithTag("myElement").assertIsDisplayed() |
| 163 | +} |
| 164 | +``` |
| 165 | + |
| 166 | +## Status Checks |
| 167 | + |
| 168 | +Required status checks for PRs: |
| 169 | +- Compose UI Tests (JVM) - from `compose-ui-tests.yml` |
| 170 | +- Platform builds (Android, iOS, Web, Wear OS) - from platform workflows |
| 171 | + |
| 172 | +Optional/informational checks: |
| 173 | +- Full multiplatform test suite - from `multiplatform-tests.yml` |
| 174 | + |
| 175 | +## Resources |
| 176 | + |
| 177 | +- [GitHub Actions Documentation](https://docs.github.com/en/actions) |
| 178 | +- [Gradle Actions](https://github.com/gradle/actions) |
| 179 | +- [Compose Multiplatform Testing](https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-test.html) |
0 commit comments