Skip to content

Commit 59d51a8

Browse files
authored
Update README (#2)
1 parent edf5ddb commit 59d51a8

File tree

1 file changed

+79
-10
lines changed

1 file changed

+79
-10
lines changed

README.md

Lines changed: 79 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,94 @@
11
# Emerge CLI
22

3-
WIP - starting with just uploading of BYOSnapshots/apps
3+
The official CLI for Emerge Tools.
44

5-
## Running
5+
[Emerge](https://emergetools.com) offers a suite of products to help optimize app size, performance, and quality by detecting regressions before they make it to production. This plugin provides a set of actions to interact with the Emerge API.
66

7-
View all commands: `ruby emgcli.rb --help`
7+
## Installation
88

9-
### Upload snapshots:
9+
This tool is packaged as a Ruby Gem which can be installed by:
1010

11-
Set the `EMERGE_API_KEY` environment variable to your API key. (alternatively pass with the `--api-token` option)
11+
```
12+
gem install emerge
13+
```
14+
15+
## API Key
16+
17+
Follow our guide to obtain an [API key](https://docs.emergetools.com/docs/uploading-basics#obtain-an-api-key) for your organization. The API Token is used by the CLI to authenticate with the Emerge API. The CLI will automatically pick up the API key if configured as an `EMERGE_API_TOKEN` environment variable, or you can manually pass it into individual commands.
18+
19+
## Snapshots
20+
21+
Uploads a directory of images to be used in [Emerge Snapshot Testing](https://docs.emergetools.com/docs/snapshot-testing).
1222

13-
#### Using with swift-snapshot-testing
23+
Run `emerge upload snapshots -h` for a full list of supported options.
24+
25+
Example:
1426

1527
```shell
16-
bundle exec ruby bin/emerge_cli.rb upload snapshots --name "Awesome App Snapshots" --id "com.awesomeapp" --repo-name "EmergeTools/AwesomeApp" --client-library swift-snapshot-testing --project-root /my/ios/repo
28+
emerge upload snapshots \
29+
--name "AwesomeApp" \
30+
--id "com.emerge.awesomeapp" \
31+
--repo-name "EmergeTools/AwesomeApp" \
32+
path/to/snapshot/images
33+
```
34+
35+
### Git Configuration
36+
37+
For CI diffs to work, Emerge needs the appropriate Git `sha` and `base_sha` values set on each build. Emerge will automatically compare a build at `sha` against the build we find matching the `base_sha` for a given application id. We also recommend setting `pr_number`, `branch`, and `repo_name` for the best experience.
38+
39+
For example:
40+
41+
- `sha`: `pr-branch-commit-1`
42+
- `base_sha`: `main-branch-commit-1`
43+
- `pr_number`: `42`
44+
- `branch`: `my-awesome-feature`
45+
- `repo_name`: `EmergeTools/hackernews`
46+
47+
Will compare the snapshot diffs of your pull request changes.
48+
49+
This plugin will automatically configure Git values for you assuming certain Github workflow triggers:
50+
51+
```yaml
52+
on:
53+
# Produce base builds with a 'sha' when commits are pushed to the main branch
54+
push:
55+
branches: [main]
56+
57+
# Produce branch comparison builds with `sha` and `base_sha` when commits are pushed
58+
# to open pull requests
59+
pull_request:
60+
branches: [main]
61+
...
1762
```
1863

19-
#### Using with manual image paths
64+
If this doesn't cover your use-case, manually set the `sha` and `base_sha` values when calling the Emerge plugin.
65+
66+
### Using with swift-snapshot-testing
67+
68+
Snapshots generated via [swift-snapshot-testing](https://github.com/pointfreeco/swift-snapshot-testing) are natively supported by the CLI by setting `--client-library swift-snapshot-testing` and a `--project-root` directory. This will scan your project for all images found in `__Snapshot__` directories.
69+
70+
Example:
2071

2172
```shell
22-
bundle exec ruby bin/emerge_cli.rb upload snapshots /your/snapshots/path1 /your/snapshots/path2 --name "Awesome App Snapshots" --id "com.awesomeapp" --repo-name "EmergeTools/AwesomeApp"
73+
emerge upload snapshots \
74+
--name "AwesomeApp swift-snapshot-testing" \
75+
--id "com.emerge.awesomeapp.swift-snapshot-testing" \
76+
--repo-name "EmergeTools/AwesomeApp" \
77+
--client-library swift-snapshot-testing \
78+
--project-root /my/awesomeapp/ios/repo
2379
```
2480

25-
Git info will be set automatically.
81+
### Using with Paparazzi
82+
83+
Snapshots generated via [Paparazzi](https://github.com/cashapp/paparazzi) are natively supported by the CLI by setting `--client-library paparazzi` and a `--project-root` directory. This will scan your project for all images found in `src/test/snapshots/images` directories.
84+
85+
Example:
86+
87+
```shell
88+
emerge upload snapshots \
89+
--name "AwesomeApp Paparazzi" \
90+
--id "com.emerge.awesomeapp.paparazzi" \
91+
--repo-name "EmergeTools/AwesomeApp" \
92+
--client-library paparazzi \
93+
--project-root /my/awesomeapp/android/repo
94+
```

0 commit comments

Comments
 (0)