# QA Binaries Guide

This guide explains how to download the latest E2E QA binary files for mobile apps from AWS S3.

## Overview

We maintain E2E QA binaries for 3 mobile applications across iOS and Android platforms. These binaries are stored in AWS S3 and can be downloaded using the script provided in this repository.

## Applications

We support the following applications:

1. **OrchardGo** - stored in `orchardgo/` folder
2. **AWALGo** - stored in `awalgo/` folder
3. **InsightsGo (SME)** - stored in `insightsgo/` folder

Each application has:
- iOS: `.ipa` file
- Android: `.apk` file

## S3 Storage

**Bucket**: `orcd-mobile-binaries`
**Region**: `us-east-1`

### File Naming Convention

QA binaries follow this naming pattern from fastlane:

```
e2e_[platform]_[brand]_qa.[extension]
```

The script downloads these 6 specific files:
- `e2e_ios_orchard_qa.ipa`
- `e2e_ios_awal_qa.ipa`
- `e2e_ios_sme_qa.ipa`
- `e2e_android_orchard_qa.apk`
- `e2e_android_awal_qa.apk`
- `e2e_android_sme_qa.apk`

## Prerequisites

### 1. AWS Credentials with MFA

You need AWS credentials with read access to the S3 bucket. We use `awsume` for MFA authentication.

**Setup Steps:**

1. Install AWS CLI:
   ```bash
   # macOS
   brew install awscli

   # Or download from: https://aws.amazon.com/cli/
   ```

2. Install awsume:
   ```bash
   pip install awsume
   ```

3. Configure AWS credentials:
   ```bash
   aws configure
   ```

4. Add MFA to `~/.aws/config`:
   ```ini
   [profile your-profile]
   mfa_serial = arn:aws:iam::ACCOUNT_ID:mfa/YOUR_USERNAME
   ```

5. Verify setup:
   ```bash
   yarn binaries:verify
   ```

### 2. Node.js Dependencies

The script requires the AWS SDK:

```bash
yarn install
```

## Available Commands

### Download QA Binaries

Download the latest E2E QA binaries for all 3 brands:

```bash
# Authenticate with MFA first
awsume <your-profile-name>

# Download all 6 binaries
yarn binaries:download
```

This will download all 6 binaries (iOS and Android for all 3 brands) to the `./binaries/` directory.

### Verify AWS Setup

Check that AWS CLI, awsume, and credentials are properly configured:

```bash
yarn binaries:verify
```

This verifies:
- AWS CLI installation
- awsume installation
- AWS credentials file (`~/.aws/credentials`)
- AWS config file (`~/.aws/config`)
- MFA configuration

## Output Structure

Downloaded binaries are organized by brand in the `./binaries/` directory (git ignored):

```
binaries/
├── orchardgo/
│   ├── android.apk
│   └── ios.ipa
├── awalgo/
│   ├── android.apk
│   └── ios.ipa
└── insightsgo/
    ├── android.apk
    └── ios.ipa
```

**Note:** Files are automatically renamed during download for simplicity:
- Folders: `orchardgo`, `awalgo`, `insightsgo`
- Files: `android.apk` or `ios.ipa`

## Sharing with InfoSec

For InfoSec access, binaries must be uploaded to the designated Google Drive folder:

**Google Drive Location**: [InfoSec Binaries Folder](https://drive.google.com/drive/folders/1tIofwsJA0TEoBP-Bph7qkTd2DgOa8M7I)

**Process:**
1. Authenticate with awsume: `awsume <profile-name>`
2. Download binaries: `yarn binaries:download`
3. Upload files from `./binaries/` to Google Drive
4. Notify InfoSec that the binaries are available

## Troubleshooting

### Authentication Errors

If you see credential errors:

```
Error: CredentialsError
```

**Solution:**
1. Make sure you've run `awsume <profile-name>` first
2. Check that your MFA token is current (they expire after a short period)
3. Verify credentials: `yarn binaries:verify`

### No Binaries Found

If the script reports files not found:

1. Check that files exist in S3 bucket
2. Verify AWS credentials have correct permissions
3. Contact DevOps if files are missing from S3

### Download Failures

If downloads fail:

1. Check network connectivity
2. Verify you're authenticated with awsume
3. Check S3 bucket permissions with your AWS admin

### File Overwriting

The download command automatically overwrites existing files. Each time you run it, it will download the latest binaries and replace any existing files in the `./binaries/` directory.

## Related Jira Tickets

- [GO-4431](https://theorchard.atlassian.net/browse/GO-4431) - Share Latest QA Binary Files for Mobile Apps
