Skip to content

Initial setup for Github Pages #4427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Dec 7, 2022
55 changes: 55 additions & 0 deletions .github/workflows/jekyll-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Jekyll with GitHub Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["master"]
paths:
- '.github/workflows/jekyll-gh-pages.yml'
- 'contributor-docs/**'
pull_request:
paths:
- '.github/workflows/jekyll-gh-pages.yml'
- 'contributor-docs/**'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./contributor-docs
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v1

deploy:
if: ${{ github.event_name == 'push' && github.repository == 'firebase/firebase-android-sdk' }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
10 changes: 10 additions & 0 deletions contributor-docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Contributor documentation

This site is a collection of docs and best practices for contributors to Firebase Android SDKs.
It describes how Firebase works on Android and provides guidance on how to build/maintain a Firebase SDK.

## New to Firebase?

- [Development Environment Setup]({{ site.baseurl }}{% link onboarding/env_setup.md %})
- [Creating a new SDK]({{ site.baseurl }}{% link onboarding/new_sdk.md %})
- [How Firebase works]({{ site.baseurl }}{% link how_firebase_works.md %})
67 changes: 67 additions & 0 deletions contributor-docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
title: Contributor documentation
description: Documentation and best practices for Android SDK development
logo: "https://firebase.google.com/downloads/brand-guidelines/SVG/logo-logomark.svg"

remote_theme: just-the-docs/[email protected]
plugins:
- jekyll-remote-theme

color_scheme: dark

# Aux links for the upper right navigation
aux_links:
"SDK Github Repo":
- "//github.com/firebase/firebase-android-sdk"

# Enable or disable the site search
# Supports true (default) or false
search_enabled: true
search:
# Split pages into sections that can be searched individually
# Supports 1 - 6, default: 2
heading_level: 6
# Maximum amount of previews per search result
# Default: 3
previews: 2
# Maximum amount of words to display before a matched word in the preview
# Default: 5
preview_words_before: 3
# Maximum amount of words to display after a matched word in the preview
# Default: 10
preview_words_after: 3
# Set the search token separator
# Default: /[\s\-/]+/
# Example: enable support for hyphenated search words
tokenizer_separator: /[\s/]+/
# Display the relative url in search results
# Supports true (default) or false
rel_url: true
# Enable or disable the search button that appears in the bottom right corner of every page
# Supports true or false (default)
button: false

mermaid:
# Version of mermaid library
# Pick an available version from https://cdn.jsdelivr.net/npm/mermaid/
version: "9.2.2"
# Put any additional configuration, such as setting the theme, in _includes/mermaid_config.js

# Enable or disable heading anchors
heading_anchors: true

# Back to top link
back_to_top: true
back_to_top_text: "Back to top"

# Footer last edited timestamp
last_edit_timestamp: true # show or hide edit time - page must have `last_modified_date` defined in the frontmatter
last_edit_time_format: "%b %e %Y at %I:%M %p" # uses ruby's time format: https://ruby-doc.org/stdlib-2.7.0/libdoc/time/rdoc/Time.html


# Footer "Edit this page on GitHub" link text
gh_edit_link: true # show or hide edit this page link
gh_edit_link_text: "Edit this page on GitHub"
gh_edit_repository: "https://github.com/firebase/firebase-android-sdk" # the github URL for your repo
gh_edit_branch: "master" # the branch that your docs is served from
gh_edit_source: "contributor-docs" # the source that your files originate from
gh_edit_view_mode: "edit" # "tree" or "edit" if you want the user to jump into the editor immediately
1 change: 1 addition & 0 deletions contributor-docs/_includes/favicon.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<link rel="shortcut icon" href="https://firebase.google.com/downloads/brand-guidelines/SVG/logo-logomark.svg" type="image/x-icon">
3 changes: 3 additions & 0 deletions contributor-docs/_includes/nav_footer_custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<footer class="site-footer">
&copy; Google LLC {{ 'now' | date: "%Y" }}
</footer>
81 changes: 81 additions & 0 deletions contributor-docs/how_firebase_works.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# How Firebase Works

## Background

### Eager Initialization

One of the biggest strengths for Firebase clients is the ease of integration. In a common case, a developer has very few things to do to integrate with Firebase. There is no need to initialize/configure Firebase at runtime. Firebase automatically initializes at application start and begins providing value to developers. A few notable examples:

* `Analytics` automatically tracks app events
* `Firebase Performance` automatically tracks app startup time, all network requests and screen performance
* `Crashlytics` automatically captures all application crashes, ANRs and non-fatals

This feature makes onboarding and adoption very simple. However, comes with the great responsibility of keeping the application snappy. We shouldn't slow down application startup for 3p developers as it can stand in the way of user adoption of their application.

### Automatic Inter-Product Discovery

When present together in an application, Firebase products can detect each other and automatically provide additional functionality to the developer, e.g.:

* `Firestore` automatically detects `Auth` and `AppCheck` to protect read/write access to the database
* `Crashlytics` integrates with `Analytics`, when available, to provide additional insights into the application behavior and enables safe app rollouts

## FirebaseApp at the Core of Firebase

Regardless of what Firebase SDKs are present in the app, the main initialization point of Firebase is `FirebaseApp`. It acts as a container for all SDKs, manages their configuration, initialization and lifecycle.

### Initialization

`FirebaseApp` gets initialized with the help of `FirebaseApp#initializeApp()`. This happens [automatically at app startup](https://firebase.blog/posts/2016/12/how-does-firebase-initialize-on-android) or manually by the developer.

During initialization, `FirebaseApp` discovers all Firebase SDKs present in the app, determines the dependency graph between products(for inter-product functionality) and initializes `eager` products that need to start immediately, e.g. `Crashlytics` and `FirebasePerformance`.

### Firebase Configuration

`FirebaseApp` contains Firebase configuration for all products to use, namely `FirebaseOptions`, which tells Firebase which `Firebase` project to talk to, which real-time database to use, etc.

### Additional Services/Components

In addition to `FirebaseOptions`, `FirebaseApp` registers additional components that product SDKs can request via dependency injection. To name a few:

* `android.content.Context`(Application context)
* [Common Executors](https://github.com/firebase/firebase-android-sdk/blob/master/docs/executors.md)
* `FirebaseOptions`
* Various internal components

## Discovery and Dependency Injection

There are multiple considerations that lead to the current design of how Firebase SDKs initialize.

1. Certain SDKs need to initialize at app startup.
2. SDKs have optional dependencies on other products that get enabled when the developer adds the dependency to their app.

To enable this functionality, Firebase uses a runtime discovery and dependency injection framework [firebase-components](https://github.com/firebase/firebase-android-sdk/tree/master/firebase-components).

To integrate with this framework SDKs register the components they provide via a `ComponentRegistrar` and declare any dependencies they need to initialize, e.g.

```java
public class MyRegistrar implements ComponentRegistrar {
@Override
public List<Component<?>> getComponents() {
return Arrays.asList(
// declare the component
Component.builder(MyComponent.class)
// declare dependencies
.add(Dependency.required(Context.class))
.add(Dependency.required(FirebaseOptions.class))
.add(Dependency.optionalProvider(InternalAuthProvider.class))
// let the runtime know how to create your component.
.factory(
diContainer ->
new MyComponent(
diContainer.get(Context.class),
diContainer.get(FirebaseOptions.class),
diContainer.get(InternalAuthProvider.class)))
.build());
}
}
```

This registrar is then registered in `AndroidManifest.xml` of the SDK and is used by `FirebaseApp` to discover all components and construct the dependency graph.

More details in [Firebase Components]({{ site.baseurl }}{% link in_depth/components.md %})).
7 changes: 7 additions & 0 deletions contributor-docs/in_depth/components.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
parent: In Depth
---

# Firebase Components

TODO
5 changes: 5 additions & 0 deletions contributor-docs/in_depth/in_depth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
has_children: true
---

# In Depth
Binary file added contributor-docs/onboarding/as_open_project.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions contributor-docs/onboarding/env_setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
parent: Onboarding
---

# Development Environment Setup

This page describes software and configuration required to work on code in the
[Firebase/firebase-android-sdk](https://github.com/firebase/firebase-android-sdk)
repository.

{:toc}

## JDK

The currently required version of the JDK is `11`. Any other versions are
unsupported and using them could result in build failures.

## Android Studio

In general, the most recent version of Android Studio should work. The version
that is tested at the time of this writing is `Dolphin | 2021.3.1`.

Download it here:
[Download Android Studio](https://developer.android.com/studio)

## Emulators

If you plan to run tests on emulators(you should), you should be able to install
them directly from Android Studio's AVD manager.

## Github (Googlers Only)

To onboard and get write access to the github repository you need to have a
github account fully linked with [go/github](http://go/github).

File a bug using this
[bug template](http://b/issues/new?component=312729&template=1016566) and wait
for access to be granted.

After that configure github keys as usual using this
[Github documentation page](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh).

## Importing the repository

1. Clone the repository with `git clone --recurse-submodules
[email protected]:firebase/firebase-android-sdk.git`.
1. Open Android Studio and click "Open an existing project".
![Open an existing project](as_open_project.png)
1. Find the `firebase-android-sdk` directory and open.
1. To run integration/device tests you will need a `google-services.json` file.
Loading