Skip to content
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

feat: create docummentation website #98

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions docs/commands.md

This file was deleted.

20 changes: 20 additions & 0 deletions docs/docs-site/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
16 changes: 16 additions & 0 deletions docs/docs-site/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# React Native CI CLI Documentation

<!-- 👉 Landing: [https://docs.swmansion.com/react-native-screens/](https://docs.swmansion.com/react-native-screens/) -->
<!-- 👉 Documentation: [https://reactnavigation.org/docs/native-stack-navigator/](https://reactnavigation.org/docs/native-stack-navigator/) -->

## Development

```
yarn
yarn start
```

## Meet the docs team

<!-- - [Balbina Fabia](https://dribbble.com/balbina): design -->
<!-- - [Patrycja Kalińska](https://x.com/patkalinska): site development -->
3 changes: 3 additions & 0 deletions docs/docs-site/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
7 changes: 7 additions & 0 deletions docs/docs-site/docs/aux-workflows/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"label": "Auxiliary Workflows",
"position": 3,
"link": {
"type": "generated-index"
}
}
139 changes: 139 additions & 0 deletions docs/docs-site/docs/aux-workflows/build-debug.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
---
sidebar_position: 2
---

# Debug build

Workflow that builds the app in debug mode for Android and iOS.

This workflow can be triggered by other workflows depending on it.

:::info
Additionally, Debug build workflow is triggered every time new code is pushed to `main` branch
for caching purposes. This way, every branch will be able to use the cached build. More information about cache scoping can be found here:
[GitHub Docs: Matching a cache key](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#matching-a-cache-key).
:::

## Usage

This workflow cannot be explicitly specified to be generated using SCI. It will be generated automatically
if you choose to create workflow depending on it.


## Detailed behavior

Below you can find detailed information about what the script does with your project when generating Debug Build workflow.

### Fingerprint

This workflow takes advantage from the fact that debug builds need to be remade only if native code changes.

It uses [@expo/fingerprint](https://expo.dev/blog/fingerprint-your-native-runtime) to generate
a hash string of your native code (called _fingerprint_) to cache debug builds and create new
builds only if necessary.

This logic is extracted to auxiliary reusable workflow `lookup-cached-debug-build`. You can find more
information about it here: [Lookup cached debug build](/docs/aux-workflows/lookup-cached-debug-build).

### Caching

Built apps will be cached using [actions/cache](https://github.com/actions/cache) using keys
`android-debug-build-${{ android-fingerprint }}` and
`ios-debug-build-${{ ios-fingerprint }}` (fingerprints for Android and iOS apps are different).

Note that this save a significant amount of time and resources, since changes in native code
are relatively rare when developing a React Native app.

### Modified and created files

<table>
<tr>
<th style={{ width: "40%" }}>File</th>
<th>Changes</th>
</tr>
<tr>
<td><code>.github/workflows/build-debug-android.yml</code></td>
<td>Contains the CI workflow for building debug Android app</td>
</tr>
<tr>
<td><code>.github/workflows/build-debug-ios.yml</code></td>
<td>Contains the CI workflow for building debug iOS app</td>
</tr>
<tr>
<td><code>package.json</code></td>
<td>
<ul>
<li>
New script:
<code>
build:debug:android: npx expo prebuild && cd android &&
./gradlew assembleDebug -DtestBuildType=debug
-Dorg.gradle.jvmargs=-Xmx4g
</code>
<br/>
(<code>npx expo prebuild</code> is ommited in non-Expo projects)
</li>
<li>
New script:
<code>
build:debug:ios: npx expo prebuild && xcodebuild ONLY_ACTIVE_ARCH=YES
-workspace ios/[iOSAppName].xcworkspace -UseNewBuildSystem=YES
-scheme [iOSAppName] -configuration Debug -sdk iphonesimulator
-derivedDataPath ios/build -quiet
</code>
<br/>
(<code>npx expo prebuild</code> is replaced with <code>cd ios && pod install && cd..</code> in non-Expo projects)
<br/>
(<code>[iOSAppName]</code> is replaced with the name of the iOS app retrieved from native code)
</li>
</ul>
</td>
</tr>
<tr>
<td><code>app.json</code></td>
<td>
Fields <code>expo.android.package</code> and <code>expo.ios.bundleIdentifier</code> will be created
in Expo projects if not detected (they are needed for <code>npx expo prebuild</code>)
</td>
</tr>
</table>

### Workflow details

#### build-debug-android

The following diagram represents the flow of the `build-debug-android` workflow:

```mermaid
flowchart TD;
A["🔍 Lookup cached debug build (and skip all following steps if found)\nUsing <a href='/setup-ci/docs/aux-workflows/lookup-cached-debug-build'>lookup-cached-debug-build</a>"]-->B["💾 Maximize build space\nUsing <a href='https://github.com/AdityaGarg8/remove-unwanted-software'>AdityaGarg8/remove-unwanted-software</a>"]
B-->C["🌿 Setup Node"];
C-->D["☕ Setup JDK 17"]
D-->E["🐘 Setup Gradle 8.8"]
E-->F["📦 Install dependencies"];
F-->G["🛠️ Build [yarn build:debug:android]"]
G-->H["📡 Store built app in cache"]
```

#### build-debug-ios

The following diagram represents the flow of the `build-debug-ios` workflow:

```mermaid
flowchart TD;
A["🔍 Lookup cached debug build (and skip all following steps if found)\nUsing <a href='/setup-ci/docs/aux-workflows/lookup-cached-debug-build'>lookup-cached-debug-build</a>"]-->B["💾 Maximize build space\nUsing <a href='https://github.com/AdityaGarg8/remove-unwanted-software'>AdityaGarg8/remove-unwanted-software</a>"]
B-->C["🌿 Setup Node"];
C-->D["🔨 Use latest stable Xcode"]
D-->E["📦 Install dependencies"];
E-->F["🛠️ Build [yarn build:debug:ios]"]
F-->G["📡 Store built app in cache"]
```

## Known issues and limitations

- One of limitations of GitHub Actions is that cache is scoped and cannot be accessed between
arbitrary branches (see [#79](https://github.com/actions/cache/issues/79)). This means that
if a build with specific fingerprint is created on `feature-a` branch, then in `feature-b`
branch with the same fingerprint, the build is not visible and the app will be built again.
However, since the build is also created on main branch, once either `feature-a` or `feature-b`
is merged to main, the build will be cached and available for all existing and future branches in the repository.
111 changes: 111 additions & 0 deletions docs/docs-site/docs/aux-workflows/build-release.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
sidebar_position: 1
---

# Release build

Workflow that build the app in release mode for Android and iOS.

This workflow can be triggered by other workflows depending on it.

## Usage

This workflow cannot be explicitly specified to be generated using SCI. It will be generated automatically
if you choose to create workflow depending on it.

## Detailed behavior

Below you can find detailed information about what the script does with your project when generating Release Build workflow.

### Caching

Built apps will be cached using [actions/cache](https://github.com/actions/cache) using keys
`android-release-build-${{ github.event.pull_request.head.sha }}` and
`ios-release-build-${{ github.event.pull_request.head.sha }}`.

`${{ github.event.pull_request.head.sha }}` will evaluate to SHA of last commit on feature branch in Pull Request.

Note that the objective of this caching mechanism is not to optimize and reuse builds (this is only
possible with debug builds), but rather to allow retrieving built app in other workflows.

### Modified and created files

<table>
<tr>
<th style={{ width: "40%" }}>File</th>
<th>Changes</th>
</tr>
<tr>
<td><code>.github/workflows/build-release-android.yml</code></td>
<td>Contains the CI workflow for building release Android app</td>
</tr>
<tr>
<td><code>.github/workflows/build-release-ios.yml</code></td>
<td>Contains the CI workflow for building release iOS app</td>
</tr>
<tr>
<td><code>package.json</code></td>
<td>
<ul>
<li>
New script:
<code>
build:release:android: npx expo prebuild && cd android &&
./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release
-Dorg.gradle.jvmargs=-Xmx4g
</code>
<br/>
(<code>npx expo prebuild</code> is ommited in non-Expo projects)
</li>
<li>
New script:
<code>
build:release:ios: npx expo prebuild && xcodebuild ONLY_ACTIVE_ARCH=YES
-workspace ios/[iOSAppName].xcworkspace -UseNewBuildSystem=YES
-scheme [iOSAppName] -configuration Release -sdk iphonesimulator
-derivedDataPath ios/build -quiet
</code>
<br/>
(<code>npx expo prebuild</code> is replaced with <code>cd ios && pod install && cd..</code> in non-Expo projects)
<br/>
(<code>[iOSAppName]</code> is replaced with the name of the iOS app retrieved from native code)
</li>
</ul>
</td>
</tr>
<tr>
<td><code>app.json</code></td>
<td>
Fields <code>expo.android.package</code> and <code>expo.ios.bundleIdentifier</code> will be created
in Expo projects if not detected (they are needed for <code>npx expo prebuild</code>)
</td>
</tr>
</table>

### Workflow details

#### build-release-android

The following diagram represents the flow of the `build-release-android` workflow:

```mermaid
flowchart TD;
A["💾 Maximize build space\nUsing <a href='https://github.com/AdityaGarg8/remove-unwanted-software'>AdityaGarg8/remove-unwanted-software</a>"]-->B["🌿 Setup Node"];
B-->C["📦 Install dependencies"];
C-->D["☕ Setup JDK 17"]
D-->E["🐘 Setup Gradle 8.8"]
E-->F["🛠️ Build [yarn build:release:android]"]
F-->G["📡 Store built app in cache"]
```

#### build-release-ios

The following diagram represents the flow of the `build-release-ios` workflow:

```mermaid
flowchart TD;
A["🌿 Setup Node"]-->B["📦 Install dependencies"];
B-->C["🔨 Use latest stable Xcode"]
C-->D["🛠️ Build [yarn build:release:ios]"]
D-->E["📡 Store built app in cache"]
```
82 changes: 82 additions & 0 deletions docs/docs-site/docs/aux-workflows/lookup-cached-debug-build.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
sidebar_position: 3
---

# Lookup cached debug build

Workflow that calculates the [fingerprint](https://expo.dev/blog/fingerprint-your-native-runtime) of the app and
checks whether a debug build with the same fingerprint is cached and can be retrieved.

This workflow can be triggered by other workflows depending on it.

## Usage

This workflow cannot be explicitly specified to be generated using SCI. It will be generated automatically
if you choose to create workflow depending on it.

## Detailed behavior

Below you can find detailed information about what the script
does with your project when generating Lookup cached debug build workflow.

### Input and output

Input:
- `platform: ('android' | 'ios')` - The platform for which the build should be looked up

Output:
- `build-exists: boolean` - whether the build was found in cache
- `fingerprint: string` - the fingerprint calculated for specified platform

### Fingerprint

This workflow uses [@expo/fingerprint](https://expo.dev/blog/fingerprint-your-native-runtime) to generate
a hash string of your native code (called _fingerprint_). It then checks whether key
`${{ inputs.platform }}-debug-build-${{ fingerprint }}` can be restored from cache.

### Modified and created files

<table>
<tr>
<th style={{ width: "40%" }}>File</th>
<th>Changes</th>
</tr>
<tr>
<td><code>.github/workflows/lookup-cached-debug-build.yml</code></td>
<td>Contains the CI workflow.</td>
</tr>
<tr>
<td><code>package.json</code></td>
<td>
<ul>
<li>
New script:
<code>
fingerprint:android: npx expo-updates fingerprint:generate
--platform android | jq -r '.hash' | xargs -n 1 echo 'fingerprint:'
</code>
</li>
<li>
New script:
<code>
fingerprint:ios: npx expo-updates fingerprint:generate
--platform ios | jq -r '.hash' | xargs -n 1 echo 'fingerprint:'
</code>
</li>
</ul>
</td>
</tr>
</table>

### Workflow details

#### build-debug-android

The following diagram represents the flow of the `lookup-cached-debug-build` workflow:

```mermaid
flowchart LR;
A["🌿 Setup Node"]-->B["📦 Install dependencies"];
B-->C["🧬 Calculate fingerprint"];
C-->D["🐛 Lookup debug build in cache"];
```
7 changes: 7 additions & 0 deletions docs/docs-site/docs/introduction/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"label": "Introduction",
"position": 1,
"link": {
"type": "generated-index"
}
}
Loading
Loading