Skip to content

Commit

Permalink
Merge pull request #262 from nimblehq/release/3.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
suho authored Apr 12, 2022
2 parents 4731cdc + 0de0f78 commit 54866ef
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 34 deletions.
8 changes: 8 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Team Lead
* @suho

# Team Members
* @blyscuit @edgarss @markgravity @minhnimble @nmint8m @phongvhd93 @vnntsu

# Engineering Leads
CODEOWNERS @nimblehq/engineering-leads
5 changes: 5 additions & 0 deletions .github/wiki/Automating-Wiki.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Automating Wiki

1. Setup the Github Wiki by following this [official guide](https://docs.github.com/en/communities/documenting-your-project-with-wikis/adding-or-editing-wiki-pages#adding-wiki-pages).
2. Create [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token.) with `repo` scope enabled - a bot account is recommended to generate that token.
3. Create a [Repository Secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) with the above token, the default name for this secret is `NIMBLE_DEV_TOKEN`.
File renamed without changes.
64 changes: 64 additions & 0 deletions .github/wiki/Self-Hosted-Github-Actions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Github Actions Self-Hosted Runner

## Problem

While Github Actions is being used on some iOS projects, the CI pipeline is not running on all pull requests because of the high pricing of runner minutes for iOS. So to support running the CI pipeline on all pull requests, we decide to use self-hosted runners with Github Actions.

## Host

### Self-Hosted Runner

GitHub Actions allows developers to set up a self-hosted runner in place of a Github-provided runner. A self-hosted runner can be either a local or cloud device.

### Local Hosted Runner

Existing macOS devices can be used to run Github Actions Workflow by installing the runner and having the machine listen to the command from Github Actions.

### Remote/Rental Hosted Runner

These are remote computers, available to use as infrastructure-as-a-service or platform-as-a-service. They are more suitable to host the Github Actions runner as they are guaranteed to be online (as per the service’s terms). Covered in this guide is as [MacStadium](http://macstadium.com/). Other services include:

- [https://aws.amazon.com/ec2/instance-types/mac/](https://aws.amazon.com/ec2/instance-types/mac/)
- [http://www.macincloud.com/](http://www.macincloud.com/)

## MacStadium Set Up

A freshly rented MacStadium does not include all the tools needed to start a GitHub Actions for iOS development.

To install all the dependencies, follow these required steps:

1. Download Xcode and Xcode Command Line Tool from [https://developer.apple.com/xcode/](https://developer.apple.com/xcode/)

![Download Xcode](assets/images/self-hosted-github-actions/download-xcode.png)

2. Launch `Terminal` to install Ruby with `gem update --system`. The current version used for writing this document is `gem install bundler:2.2.15`.
3. Connect Github Actions Runner to the machine.
4. Trigger a run from Github Console or git push.
5. During the first Github Actions runtime, some gems package will require machine password to install. This is referred to machine password in MacStadium when setting up the Mac.

## Connect Github Actions Runner

The instruction for connecting Github Actions to the hosting machine should follow the instruction found in `Settings > Actions > Runners > New self-hosted runner` in the projects repository page.

![New Self Hosted Runner](assets/images/self-hosted-github-actions/new-self-hosted-runner.png)

![New Self Hosted Runner Script](assets/images/self-hosted-github-actions/new-self-hosted-runner-script.png)

The general steps are:

1. Download: Download the newest version of Github Runner and save in the runner folder.
2. Configure: Inject the project’s token to the runner and run the executable.

## Add More Runners

To add more runners to the same or a new host, simply follow the instruction from the repository’s settings `Settings > Actions > Runners > New self-hosted runner`. Make sure the new runner is downloaded onto a separate folder.

## Restarting Runner

In the case that the machine is shut down or the terminal running the script was exited, the runner script can be relaunched by `cd` to the script folder and run `./run.sh`.

## Result

When setting up successfully.

![Result](assets/images/self-hosted-github-actions/result.png)
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions docs/_Sidebar.md → .github/wiki/_Sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

**Technical document**
* [[Standard File Organization]]
* [[Self Hosted Github Actions]]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 7 additions & 30 deletions .github/workflows/publish_docs_to_wiki.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,12 @@ on:
- main
- master

env:
USER_TOKEN: ${{ secrets.NIMBLE_DEV_TOKEN }}
USER_NAME: team-nimblehq
USER_EMAIL: [email protected]
OWNER: ${{ github.event.repository.owner.name }}
REPOSITORY_NAME: ${{ github.event.repository.name }}

jobs:
publish_docs_to_wiki:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Pull wiki
run: |
mkdir tmp_wiki
cd tmp_wiki
git init
git config user.name $USER_NAME
git config user.email $USER_EMAIL
git pull https://[email protected]/$OWNER/$REPOSITORY_NAME.wiki.git
- name: Push wiki
run: |
rsync -av --delete docs/ tmp_wiki/ --exclude .git
cd tmp_wiki
git add .
git commit -m "Update Wiki content"
git push -f --set-upstream https://[email protected]/$OWNER/$REPOSITORY_NAME.wiki.git master
name: Publish Wiki
uses: nimblehq/github-actions-workflows/.github/workflows/[email protected]
with:
USER_NAME: team-nimblehq
USER_EMAIL: [email protected]
secrets:
USER_TOKEN: ${{ secrets.NIMBLE_DEV_TOKEN }}
14 changes: 13 additions & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ platform :ios do

# Code Sign

desc 'Sync Development match signing'
lane :sync_development_signing do
match_manager.sync_development_signing(
app_identifier: [
Constants.BUNDLE_ID_STAGING,
Constants.BUNDLE_ID_PRODUCTION
]
)
end

desc 'Sync Adhoc match signing'
lane :sync_adhoc_signing do
match_manager.sync_adhoc_signing(app_identifier: [Constants.BUNDLE_ID_STAGING])
Expand All @@ -78,7 +88,9 @@ platform :ios do
device_hash = {}
device_hash[device_name] = device_udid
register_devices(devices: device_hash)
match(force: true)

match_manager.sync_development_signing(app_identifier: nil, force: true)
match_manager.sync_adhoc_signing(app_identifier: nil, force: true)
end

# Firebase
Expand Down
23 changes: 20 additions & 3 deletions fastlane/Managers/MatchManager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,35 @@ def initialize(
@is_ci = is_ci
end

def sync_adhoc_signing(app_identifier:)
def sync_development_signing(app_identifier:, force: false)
if @is_ci
create_ci_keychain
@fastlane.match(
type: 'development',
keychain_name: @keychain_name,
keychain_password: @keychain_password,
app_identifier: app_identifier,
readonly: !force,
force: force
)
else
@fastlane.match(type: 'development', app_identifier: app_identifier, readonly: !force, force: force)
end
end

def sync_adhoc_signing(app_identifier:, force: false)
if @is_ci
create_ci_keychain
@fastlane.match(
type: 'adhoc',
keychain_name: @keychain_name,
keychain_password: @keychain_password,
app_identifier: app_identifier,
readonly: true
readonly: !force,
force: force
)
else
@fastlane.match(type: 'adhoc', app_identifier: app_identifier, readonly: true)
@fastlane.match(type: 'adhoc', app_identifier: app_identifier, readonly: !force, force: force)
end
end

Expand Down

0 comments on commit 54866ef

Please sign in to comment.