|
| 1 | +# Contributing to FirebaseUI-Android |
| 2 | + |
| 3 | +<a href="https://github.com/firebase/FirebaseUI-Android/actions/workflows/android.yml"> |
| 4 | + <img src="https://github.com/firebase/FirebaseUI-Android/workflows/Android%20CI/badge.svg" alt="Android CI GitHub Workflow Status"/> |
| 5 | +</a> |
| 6 | + |
| 7 | +_See also: [Firebase's code of conduct](https://firebase.google.com/support/guides/code-conduct)_ |
| 8 | + |
| 9 | +## 1. Things you will need |
| 10 | + |
| 11 | +- Linux, Mac OS X, or Windows. |
| 12 | +- [git](https://git-scm.com) (used for source version control). |
| 13 | +- An ssh client (used to authenticate with GitHub). |
| 14 | +- [Android Studio](https://developer.android.com/studio) or [IntelliJ IDEA](https://www.jetbrains.com/idea/). |
| 15 | +- [JDK 21](https://adoptium.net/) or higher. |
| 16 | +- [Android SDK](https://developer.android.com/studio) with minimum API level 21. |
| 17 | + |
| 18 | +## 2. Forking & cloning the repository |
| 19 | + |
| 20 | +- Ensure all the dependencies described in the previous section are installed. |
| 21 | +- Fork `https://github.com/firebase/FirebaseUI-Android` into your own GitHub account. If |
| 22 | + you already have a fork, and are now installing a development environment on |
| 23 | + a new machine, make sure you've updated your fork so that you don't use stale |
| 24 | + configuration options from long ago. |
| 25 | +- If you haven't configured your machine with an SSH key that's known to github, then |
| 26 | + follow [GitHub's directions](https://help.github.com/articles/generating-ssh-keys/) |
| 27 | + to generate an SSH key. |
| 28 | +- `git clone [email protected]:<your_name_here>/FirebaseUI-Android.git` |
| 29 | +- `git remote add upstream [email protected]:firebase/FirebaseUI-Android.git` (So that you |
| 30 | + fetch from the main repository, not your clone, when running `git fetch` |
| 31 | + et al.) |
| 32 | + |
| 33 | +## 3. Environment Setup |
| 34 | + |
| 35 | +FirebaseUI-Android uses Gradle to manage the project and dependencies. |
| 36 | + |
| 37 | +The repository includes a `library/google-services.json` file that is copied to the app and test modules during builds. This is handled automatically by the build scripts. |
| 38 | + |
| 39 | +To verify your environment is set up correctly, run: |
| 40 | + |
| 41 | +```bash |
| 42 | +./scripts/build.sh |
| 43 | +``` |
| 44 | + |
| 45 | +This will: |
| 46 | +- Copy the necessary `google-services.json` files |
| 47 | +- Download all dependencies |
| 48 | +- Build all modules |
| 49 | +- Run checkstyle |
| 50 | +- Run unit tests |
| 51 | + |
| 52 | +> If you need to use your own Firebase project, replace `library/google-services.json` with your own configuration file from the [Firebase Console](https://console.firebase.google.com/). |
| 53 | +
|
| 54 | +## 4. Running an example |
| 55 | + |
| 56 | +The project provides a demo app in the `app` module which showcases the main use-cases of FirebaseUI Auth. |
| 57 | + |
| 58 | +To run the example app: |
| 59 | + |
| 60 | +**Option 1: Android Studio** |
| 61 | +- Open the project in Android Studio |
| 62 | +- Select the `app` configuration |
| 63 | +- Run on a device or emulator |
| 64 | + |
| 65 | +**Option 2: Command line** |
| 66 | +```bash |
| 67 | +./gradlew :app:installDebug |
| 68 | +``` |
| 69 | + |
| 70 | +Then launch the app on your device. |
| 71 | + |
| 72 | +Any changes made to the library modules (auth, database, firestore, storage) locally will be automatically reflected in the example application. |
| 73 | + |
| 74 | +## 5. Running tests |
| 75 | + |
| 76 | +FirebaseUI-Android comprises of a number of tests, including unit tests and E2E tests. |
| 77 | + |
| 78 | +### Unit tests |
| 79 | + |
| 80 | +Unit tests are responsible for ensuring expected behavior whilst developing the library's Kotlin/Java code. Unit tests do not |
| 81 | +interact with 3rd party Firebase services, and mock where possible. To run unit tests for all modules (excluding e2eTest), run the following command from the root directory: |
| 82 | + |
| 83 | +```bash |
| 84 | +./gradlew testDebugUnitTest -x :e2eTest:testDebugUnitTest |
| 85 | +``` |
| 86 | + |
| 87 | +To run unit tests for a specific module (e.g., auth): |
| 88 | + |
| 89 | +```bash |
| 90 | +./gradlew :auth:testDebugUnitTest |
| 91 | +``` |
| 92 | + |
| 93 | +### E2E tests |
| 94 | + |
| 95 | +E2E tests run against Firebase Auth Emulator and test the full integration with Firebase services. To run e2e tests, you first need to start the Firebase Emulator: |
| 96 | + |
| 97 | +```bash |
| 98 | +# Install Firebase Tools (if not already installed) |
| 99 | +npm install -g firebase-tools |
| 100 | + |
| 101 | +# Start the Firebase Auth Emulator |
| 102 | +./scripts/start-firebase-emulator.sh |
| 103 | +``` |
| 104 | + |
| 105 | +Then in a separate terminal, run the e2e tests: |
| 106 | + |
| 107 | +```bash |
| 108 | +./gradlew e2eTest |
| 109 | +``` |
| 110 | + |
| 111 | +> Note: E2E tests use Firebase Emulator Suite, so you don't need a real Firebase project to run them. |
| 112 | +
|
| 113 | +### Lint and Code Analysis |
| 114 | + |
| 115 | +To run lint checks: |
| 116 | + |
| 117 | +```bash |
| 118 | +./gradlew checkstyle |
| 119 | +``` |
| 120 | + |
| 121 | +## 6. Contributing code |
| 122 | + |
| 123 | +We gladly accept contributions via GitHub pull requests. |
| 124 | + |
| 125 | +Please peruse the |
| 126 | +[Kotlin coding conventions](https://kotlinlang.org/docs/coding-conventions.html) and |
| 127 | +[Android code style guide](https://developer.android.com/kotlin/style-guide) before |
| 128 | +working on anything non-trivial. These guidelines are intended to |
| 129 | +keep the code consistent and avoid common pitfalls. |
| 130 | + |
| 131 | +To start working on a patch: |
| 132 | + |
| 133 | +1. `git fetch upstream` |
| 134 | +2. `git checkout upstream/master -b <name_of_your_branch>` |
| 135 | +3. Hack away! |
| 136 | + |
| 137 | +Once you have made your changes, ensure that it passes the internal analyzer & formatting checks. The following |
| 138 | +commands can be run locally to highlight any issues before committing your code: |
| 139 | + |
| 140 | +```bash |
| 141 | +# Run the full CI build script |
| 142 | +./scripts/build.sh |
| 143 | +``` |
| 144 | + |
| 145 | +This script runs: |
| 146 | +- `./gradlew clean` |
| 147 | +- `./gradlew assembleDebug` - Build all modules |
| 148 | +- `./gradlew checkstyle` - Run code style checks |
| 149 | +- `./gradlew testDebugUnitTest -x :e2eTest:testDebugUnitTest` - Run unit tests |
| 150 | + |
| 151 | +You can also run these commands individually if needed. |
| 152 | + |
| 153 | +Assuming all is successful, commit and push your code: |
| 154 | + |
| 155 | +1. `git commit -a -m "<your informative commit message>"` |
| 156 | +2. `git push origin <name_of_your_branch>` |
| 157 | + |
| 158 | +To send us a pull request: |
| 159 | + |
| 160 | +- `git pull-request` (if you are using [Hub](http://github.com/github/hub/)) or |
| 161 | + go to `https://github.com/firebase/FirebaseUI-Android` and click the |
| 162 | + "Compare & pull request" button |
| 163 | + |
| 164 | +Please make sure all your check-ins have detailed commit messages explaining the patch. |
| 165 | + |
| 166 | +When naming the title of your pull request, please follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) |
| 167 | +guide. For example, for a fix to the FirebaseUI Auth module: |
| 168 | + |
| 169 | +`fix(auth): fixed a bug with email sign-in!` |
| 170 | + |
| 171 | +For a new feature: |
| 172 | + |
| 173 | +`feat(auth): add support for passkey authentication` |
| 174 | + |
| 175 | +Tests are run automatically on contributions using GitHub Actions. Depending on |
| 176 | +your code contributions, various tests will be run against your updated code automatically. |
| 177 | + |
| 178 | +Once you've gotten an LGTM from a project maintainer and once your PR has received |
| 179 | +the green light from all our automated testing, wait for one of the package maintainers |
| 180 | +to merge the pull request. |
| 181 | + |
| 182 | +### Code style |
| 183 | + |
| 184 | +FirebaseUI-Android follows standard Kotlin and Android conventions: |
| 185 | + |
| 186 | +#### Kotlin |
| 187 | + |
| 188 | +- Use 4 spaces for indentation |
| 189 | +- Maximum line length: 120 characters |
| 190 | +- Use meaningful variable and function names |
| 191 | +- Follow [Kotlin coding conventions](https://kotlinlang.org/docs/coding-conventions.html) |
| 192 | + |
| 193 | +#### Jetpack Compose |
| 194 | + |
| 195 | +- Follow [Compose API guidelines](https://github.com/androidx/androidx/blob/androidx-main/compose/docs/compose-api-guidelines.md) |
| 196 | +- Composables should be stateless when possible |
| 197 | +- Use `remember` for state that survives recomposition |
| 198 | +- Hoist state when it needs to be shared |
| 199 | + |
| 200 | +#### Example |
| 201 | + |
| 202 | +```kotlin |
| 203 | +@Composable |
| 204 | +fun SignInScreen( |
| 205 | + configuration: AuthUIConfiguration, |
| 206 | + onSignInSuccess: (AuthResult) -> Unit, |
| 207 | + modifier: Modifier = Modifier |
| 208 | +) { |
| 209 | + var email by remember { mutableStateOf("") } |
| 210 | + var password by remember { mutableStateOf("") } |
| 211 | + |
| 212 | + Column( |
| 213 | + modifier = modifier |
| 214 | + .fillMaxSize() |
| 215 | + .padding(16.dp) |
| 216 | + ) { |
| 217 | + OutlinedTextField( |
| 218 | + value = email, |
| 219 | + onValueChange = { email = it }, |
| 220 | + label = { Text("Email") }, |
| 221 | + modifier = Modifier.fillMaxWidth() |
| 222 | + ) |
| 223 | + |
| 224 | + Spacer(modifier = Modifier.height(8.dp)) |
| 225 | + |
| 226 | + OutlinedTextField( |
| 227 | + value = password, |
| 228 | + onValueChange = { password = it }, |
| 229 | + label = { Text("Password") }, |
| 230 | + visualTransformation = PasswordVisualTransformation(), |
| 231 | + modifier = Modifier.fillMaxWidth() |
| 232 | + ) |
| 233 | + } |
| 234 | +} |
| 235 | +``` |
| 236 | + |
| 237 | +### Documentation |
| 238 | + |
| 239 | +All public APIs should be documented with KDoc: |
| 240 | + |
| 241 | +```kotlin |
| 242 | +/** |
| 243 | + * Authenticates a user with email and password. |
| 244 | + * |
| 245 | + * @param email The user's email address |
| 246 | + * @param password The user's password |
| 247 | + * @return [AuthResult] containing the signed-in user |
| 248 | + * @throws AuthException.InvalidCredentialsException if credentials are invalid |
| 249 | + * @throws AuthException.NetworkException if network is unavailable |
| 250 | + * |
| 251 | + * Example usage: |
| 252 | + * ```kotlin |
| 253 | + * val result = authUI.signInWithEmailAndPassword( |
| 254 | + |
| 255 | + * password = "securePassword123" |
| 256 | + * ) |
| 257 | + * ``` |
| 258 | + */ |
| 259 | +suspend fun signInWithEmailAndPassword( |
| 260 | + email: String, |
| 261 | + password: String |
| 262 | +): AuthResult |
| 263 | +``` |
| 264 | + |
| 265 | +### Contributor License Agreement |
| 266 | + |
| 267 | +You must complete the |
| 268 | +[Contributor License Agreement](https://cla.developers.google.com/clas). |
| 269 | +You can do this online, and it only takes a minute. |
| 270 | +If you've never submitted code before, you must add your (or your |
| 271 | +organization's) name and contact info to the [AUTHORS](AUTHORS) file. |
| 272 | + |
| 273 | +### License Headers |
| 274 | + |
| 275 | +If you create a new file, do not forget to add the license header: |
| 276 | + |
| 277 | +```kotlin |
| 278 | +/* |
| 279 | + * Copyright 2025 Google Inc. All Rights Reserved. |
| 280 | + * |
| 281 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
| 282 | + * in compliance with the License. You may obtain a copy of the License at |
| 283 | + * |
| 284 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 285 | + * |
| 286 | + * Unless required by applicable law or agreed to in writing, software distributed under the |
| 287 | + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 288 | + * express or implied. See the License for the specific language governing permissions and |
| 289 | + * limitations under the License. |
| 290 | + */ |
| 291 | +``` |
| 292 | + |
| 293 | +### The review process |
| 294 | + |
| 295 | +Newly opened PRs first go through initial triage which results in one of: |
| 296 | + |
| 297 | +- **Merging the PR** - if the PR can be quickly reviewed and looks good. |
| 298 | +- **Closing the PR** - if the PR maintainer decides that the PR should not be merged. |
| 299 | +- **Moving the PR to the backlog** - if the review requires non-trivial effort and the issue isn't a priority; in this case the maintainer will: |
| 300 | + - Make sure that the PR has an associated issue labeled with "auth", "database", "firestore", or "storage". |
| 301 | + - Add the "backlog" label to the issue. |
| 302 | + - Leave a comment on the PR explaining that the review is not trivial and that the issue will be looked at according to priority order. |
| 303 | +- **Starting a non-trivial review** - if the review requires non-trivial effort and the issue is a priority; in this case the maintainer will: |
| 304 | + - Add the "in review" label to the issue. |
| 305 | + - Self assign the PR. |
| 306 | +- **API Changes** |
| 307 | + - If a change or improvement will affect public API, the team will take longer in the review process. |
| 308 | + |
| 309 | +### The release process |
| 310 | + |
| 311 | +We push releases manually, using Gradle and Maven publishing. |
| 312 | + |
| 313 | +Changelogs and version updates are managed by project maintainers. The new version is automatically |
| 314 | +generated via the commit types and changelogs via the commit messages. |
| 315 | + |
| 316 | +Some things to keep in mind before publishing the release: |
| 317 | + |
| 318 | +- Has CI run on the main commit and gone green? Even if CI shows as green on |
| 319 | + the PR it's still possible for it to fail on merge, for multiple reasons. |
| 320 | + There may have been some bug in the merge that introduced new failures. CI |
| 321 | + runs on PRs as it's configured on their branch state, and not on tip of tree. |
| 322 | +- [Publishing is |
| 323 | + forever.](https://central.sonatype.org/publish/publish-guide/#deployment) |
| 324 | + Hopefully any bugs or breaking changes in this PR have already been caught |
| 325 | + in PR review, but now's a second chance to revert before anything goes live. |
| 326 | +- "Don't deploy on a Friday." Consider carefully whether or not it's worth |
| 327 | + immediately publishing an update before a stretch of time where you're going |
| 328 | + to be unavailable. There may be bugs with the release or questions about it |
| 329 | + from people that immediately adopt it, and uncovering and resolving those |
| 330 | + support issues will take more time if you're unavailable. |
| 331 | + |
| 332 | +## 7. Contributing documentation |
| 333 | + |
| 334 | +We gladly accept contributions to the SDK documentation. As our docs are also part of this repo, |
| 335 | +see "Contributing code" above for how to prepare and submit a PR to the repo. |
| 336 | + |
| 337 | +FirebaseUI-Android documentation lives in the README files for each module: |
| 338 | +- `auth/README.md` - FirebaseUI Auth documentation |
| 339 | +- `database/README.md` - FirebaseUI Realtime Database documentation |
| 340 | +- `firestore/README.md` - FirebaseUI Firestore documentation |
| 341 | +- `storage/README.md` - FirebaseUI Storage documentation |
| 342 | + |
| 343 | +Firebase follows the [Google developer documentation style guide](https://developers.google.com/style), |
| 344 | +which you should read before writing substantial contributions. |
| 345 | + |
| 346 | +When updating documentation: |
| 347 | + |
| 348 | +1. Ensure code samples are tested and working |
| 349 | +2. Follow Markdown best practices |
| 350 | +3. Include screenshots or GIFs for UI-related changes |
| 351 | +4. Update table of contents if adding new sections |
| 352 | +5. Ensure links are valid and point to the correct locations |
| 353 | + |
| 354 | +## 8. Getting help |
| 355 | + |
| 356 | +If you have questions about contributing: |
| 357 | + |
| 358 | +- Check the module README files |
| 359 | +- Check existing [issues](https://github.com/firebase/FirebaseUI-Android/issues) and [pull requests](https://github.com/firebase/FirebaseUI-Android/pulls) |
| 360 | +- Ask on [Stack Overflow](https://stackoverflow.com/questions/tagged/firebaseui) with the `firebaseui` tag |
| 361 | +- Create a new issue for discussion |
| 362 | + |
| 363 | +## 9. Recognition |
| 364 | + |
| 365 | +Contributors will be recognized in: |
| 366 | +- Release notes |
| 367 | +- GitHub contributors page |
| 368 | +- Project AUTHORS file |
| 369 | + |
| 370 | +Thank you for making FirebaseUI-Android better! 🎉 |
0 commit comments