Skip to content

Commit

Permalink
Feature/ci docs (#15)
Browse files Browse the repository at this point in the history
* Added CI docs to playbook

* Fixing image link

* Cleanup

* Update README.md

Co-Authored-By: Dominik Hádl <[email protected]>

* Addess PR changes

* Updating ssh files

* Fixing setup guide
  • Loading branch information
ricardotokashiki authored and NickSkull committed Aug 30, 2019
1 parent 3ea4cb3 commit 184203c
Show file tree
Hide file tree
Showing 14 changed files with 225 additions and 3 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,25 @@ The way we do localisation in Nodes is a bit different than in other places. We
Make sure to read our [**Swift Style Guide**](styleguide.md).


# Nodes CI
The Nodes CI is our new continuous integration tool. Since it's still new, we don't really use it in many of our projects. However, all the new projects should have CI set up. [Here](https://engineering.nodesagency.com/articles/iOS/Continuous-Integration-on-iOS-with-HockeyApp-and-Testflight-Deployment/) you can find an article about how we got to build our own CI system. [Here](https://git.nodescloud.com/ios/ci-template) you can find a template for implementing our CI in your project.
# Continuous Integration (CI)

As a digital agency we build hundreds of apps during the day and to manage all these builds we are using Bitrise as a CI tool to speed up our deployment process and [Match](https://docs.fastlane.tools/actions/match/) + Github to manage our client's certificates.

Please find below the steps to configure your project.

***1) Creating a new project on Bitrise***

Once you get access to Bitrise the creation process is straightforward and most of it is automatic if you have attached your github account to your Bitrise account.

[Here](./ci/bitrise-setup-readme.md) you will find a configuration guide to help you setting up your project on Bitrise.

***2) Integrating into your Xcode project***

If you already have a project created an you just need to deploy it to Bitrise you'll need to add the configuration file `project.yml` to the root of your project. In case you need to add or change any configuration but are unsure how to do that please refer to this [document](./ci/bitrise-config-readme.md).

***3) Troubleshooting***

We also listed the most common issues when Bitrise is trying to make the builds. Please check the [common issues document](./ci/bitrise-issues-readme.md) if you are having some problems.

# Swift Migration Guide

Expand Down
2 changes: 1 addition & 1 deletion ViperArchitecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Eg.: The interactor makes a API call and receives the json file. The data will b

## Flow control

![](./NodesViperFlow.png)
![](./images/nodes-viper-flow.png)

## Protocols

Expand Down
58 changes: 58 additions & 0 deletions ci/bitrise-config-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Nodes iOS CI - Guide

## Configuration ⚙️

We have two levels of configuration on [project.yml](./project.yml) file.
In the first level we have the information regarding the whole project and the second level is **Target** specific.

According to the configuration you'll tell the CI to make builds for different targets, extensions and configurations.

#### First level - Project

- **xcodeproj: String** - The name of the xcode project file. ❗️
- **workspace: String** - The name of the xcode workspace file.
- **configuration: String** - Name of the build configuration, e.g. "Staging" or "Release". ❗️
- **ci-version: Number** - **`0.1`**, **`0.2`**, or **`1.0`**. Default is currently **`0.2`**
- **hockey-upload: Bool** - Enables uploads to hockey. This is automatically `true` if testflight uploads are enabled.❗️
- **testflight-upload: Bool** - Enables uploads to testflight.❗️
- **disable-hockey-version-check: Bool** - Disable Hockey version check to avoid errors when build number <= current build number on Hockey. Not required, defaults to `false`
- **slack-channel: String** - The name of the channel to report successful builds to.❗️
- **targets: [String: Target]** - List of target settings.❗️


#### Second level - Target

- **enabled**: **Boolean** - Makes the target available for building.❗️
- **scheme**: **String** - The name of the scheme to build. Usually this is the same as the name of the target.❗️
- **hockey-app-id**: **String** - The app ID used for uploading to hockey.❗️
- **testflight-upload-account**: **String** - The email for the Apple ID used to upload to App Store Connect. Default value depends on CI version: 0.1 and 1.0 use [email protected], 0.2 uses [email protected]
- **itc_provider**: **String** - The `ShortName` for the associated AppStore Connect team.
- **team-name**: **String** - Apple Developer team name. This should match the distribution certificate's team name.
- **extensions-bundle-ids**: **[String]** - An array of bundle ID's used in app extension.
- **enable-badge**: **Boolean** - Enables the use of `fastlane badge` for non "Release" configurations.

> ❗️- Mandatory keys
## Template:

*project.yml*

```ruby
# This is the project config file
xcodeproj: "REPLACE_PROJECT_NAME.xcodeproj"
configuration: "Test" # Possible configurations: Debug | Test | Release
ci-version: 1.0
hockey-upload: true
testflight-upload: false
slack-channel: "REPLACE_SLACK_CHANNEL" # replace with your project's Slack Channel name
targets:
REPLACE_PROJECT_NAME:
enabled: true
scheme: "REPLACE_PROJECT_NAME"
hockey-app-id:
Debug: "REPLACE_HOCKEY_DEVELOPMENT"
Test: "REPLACE_HOCKEY_STAGING"
Release: "REPLACE_HOCKEY_PRODUCTION"


```
69 changes: 69 additions & 0 deletions ci/bitrise-issues-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Nodes iOS Bitrise - Common issues 🤯

If you run into issues this list of things might help you!
In case you find a new error and fixed it please update this doc to help your colleagues! 🙂

## Issues:

##### error: No signing certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID "id" with a private key was found

If you see this error using v0.2, Go into your build settings -> Code Signing Identity, and manually select Automatic: iOS Developer or iOS Distribution for your *target* and not the project. This error occurs when the target inherits the code signing identity value from the project.

--

##### Prepare repository fails at checking Hockey version
This happens due to the info plist path in the Xcode project containing a variable, which is usually expanded by Xcode, however, it isn't by the CI script.

Easiest way to fix this issue is by removing the variable part (usually `$(SRCROOT)`) from the info plist path in your target build settings.

--

##### ITC Providers during Testflight upload
If you get this error:
`Your Apple ID account is attached to other iTunes providers. You will need to specify which provider you intend to submit content to by using the -itc_provider command`

For some reason, sometimes the team name isn't enough to tell iTunes Connect which team to upload to. You need to add an extra field like this `itc_provider: "ZLCKLX4ACJ"` to that target in the project.yml file. That value is the Team ID from your account membership page in the developer portal. More info here: https://medium.com/@nickmeehan/fastlane-testflight-and-itc-provider-9233a3c4b5e5

--

##### Mutiple teams found

**Note** This one should be solved. If you still get this error, open an issue so we can see what's going wrong


If you see this message when trying to upload to Testflight: `Multiple iTunes Connect Teams found; unable to choose, terminal not ineractive!`

This means fastlane couldn't figure out which team to upload to. The easiest way to fix this is to add an environment variable with either the team name or team id. In the workflow editor, click Env Vars, and add a new variable under the deploy-testflight workflow. `FASTLANE_ITC_TEAM_ID` = `<team id>`, or `FASTLANE_ITC_TEAM_NAME` = `<team name>`. The team name and ID can be found in logs from the build that failed (there will be a list of teams that it couldn't choose from). Take a look at the fitness DK project for an example of this.

--

##### Exit 65 - ARCHIVE FAILED error

Your Xcode archived/build suceeds fine, but CI/fastlane archiving fails with exit code 65? Inspect your Xcode build/archive log for any errors that are outputted - surprisingly Xcode lets you finish the archive while running `xcodebuild` from the commandline (which is what fastlane does) fails horribly.

For example, in one project a `find` command in a custom build phase was outputting an error where it couldn't find a directory.

Search for this error in your Xcode log, if you think something similar to the above might be the cause:
`Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure`

--

##### Codesign error, export failed during Fastlane gym phase

Make sure you remove the translations model generator from your project. It should exist in the project directory but not referenced or linked in the actual xcodeproj.

--

##### Loading settings from project.yml

```
+ ruby /var/folders/90/5stft2v13fb_m_gv3c8x9nwc0000gn/T/bitrise034957535/step_src/parse_project_settings.rb
/usr/local/lib/ruby/gems/2.4.0/gems/xcodeproj-1.5.3/lib/xcodeproj/project.rb:217:in `initialize_from_file': [Xcodeproj] Unknown object version. (RuntimeError)
from /usr/local/lib/ruby/gems/2.4.0/gems/xcodeproj-1.5.3/lib/xcodeproj/project.rb:102:in `open'
from /var/folders/90/5stft2v13fb_m_gv3c8x9nwc0000gn/T/bitrise034957535/step_src/parse_project_settings.rb:80:in `<main>'
```
We've seen this issue being causes by 2 things:
1. The schemes are not shared
Solution: Share the schemes from xCode -> Product -> Scheme -> Manage schemes -> Make sure "Shared" is checked.
2. The xCode version you are using does not match the stack on the Bitrise project.
Solution: Change the default stack in Bitrise -> Workflow -> Stack
62 changes: 62 additions & 0 deletions ci/bitrise-setup-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Nodes iOS Bitrise - Setup Guide 🛠

Setting up Bitrise is simple and we described in 3 steps:

- [Xcode setup](#Xcode-setup)
- [App setup on Bitrise](#App-setup-on-Bitrise)
- [Bitrise workflow integration](#Bitrise-workflow-integration)

## Xcode setup

Make sure your project's schemes are ***shared (including app extensions)*** , otherwise you will run into a lot of warnings and it might not build all of your targets.


## App setup on Bitrise

1) Create a *New App* from the Bitrise dashboard
- Make sure you choose **Nodes** account when creating the *New App* and make it **Private**

<p align="center">
  <img src="../images/ci/01-new-app-bitrise.jpg?raw=true" alt="New App"/>
</p>

2) Connect the repository to Bitrise

<p align="center">
  <img src="../images/ci/02-new-app-bitrise.jpg?raw=true" alt="New App"/>
</p>

3) When setting up the access make sure to auto add SSH key.

<p align="center">
  <img src="../images/ci/03-new-app-bitrise.jpg?raw=true" alt="New App"/>
</p>

4) Indicate which branch Bitrise should use to make the builds

<p align="center">
  <img src="../images/ci/04-new-app-bitrise.jpg?raw=true" alt="New App"/>
</p>

5) After choosing the branch, Bitrise will validate the source code and then you can select the *export method* you want to use. Usually is **app-store**

<p align="center">
  <img src="../images/ci/05-new-app-bitrise.jpg?raw=true" alt="New App"/>
</p>

6) The last step is the Webhook setup. It will create a link from the github repository to Bitrise.

<p align="center">
  <img src="../images/ci/06-new-app-bitrise.jpg?raw=true" alt="New App"/>
</p>


## Bitrise workflow integration

In order to make everything work on Bitrise you'll need to copy the template content from [bitrise.yml](https://github.com/nodes-projects/ci-resources-ios/blob/master/bitrise.yml) into the Bitrise workflow script.

You can find the detailed workflow description [here](https://github.com/nodes-ios/bitrise-step-nodes-custom-script)

<p align="center">
  <img src="../images/ci/07-new-app-bitrise.jpg?raw=true" alt="New App"/>
</p>
16 changes: 16 additions & 0 deletions ci/project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# This is the project config file
xcodeproj: "REPLACE_PROJECT_NAME.xcodeproj"
configuration: "Test" # Possible configurations: Debug | Test | Release
ci-version: 1.0
hockey-upload: true
testflight-upload: false
slack-channel: "REPLACE_SLACK_CHANNEL" # replace with your project's Slack Channel name
targets:
REPLACE_PROJECT_NAME:
enabled: true
scheme: "REPLACE_PROJECT_NAME"
hockey-app-id:
Debug: "REPLACE_HOCKEY_DEVELOPMENT"
Test: "REPLACE_HOCKEY_STAGING"
Release: "REPLACE_HOCKEY_PRODUCTION"

Binary file added images/ci/01-new-app-bitrise.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ci/02-new-app-bitrise.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ci/03-new-app-bitrise.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ci/04-new-app-bitrise.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ci/05-new-app-bitrise.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ci/06-new-app-bitrise.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ci/07-new-app-bitrise.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes

0 comments on commit 184203c

Please sign in to comment.