Skip to content
Merged
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
55 changes: 55 additions & 0 deletions .github/workflows/cli_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build and Deploy CLI Binary

on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g. 1.0.0)'
required: true
type: string

jobs:
build:
name: Build CLI Binary
runs-on: ubuntu-latest
defaults:
run:
working-directory: cli

steps:
- uses: actions/checkout@v4

- name: Set up Ruby and install dependencies
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2.2'
bundler-cache: true
working-directory: cli

- name: Install dependencies
run: |
gem install bundler
bundle install

- name: Build the gem
run: gem build emerge.gemspec

- name: Install the gem
run: gem install --user-install emerge-*.gem

- name: Update PATH and test emerge
run: |
export PATH="$(ruby -e 'puts Gem.user_dir')/bin:$PATH"
OUTPUT=$(emerge -h 2>&1 || true)
echo "$OUTPUT"

# Check for expected strings
echo "$OUTPUT" | grep -q "emerge integrate \[SUBCOMMAND\]" || { echo "Expected integrate command not found"; exit 1; }
echo "$OUTPUT" | grep -q "emerge upload \[SUBCOMMAND\]" || { echo "Expected upload command not found"; exit 1; }

# - name: Upload binary artifact
# uses: actions/upload-artifact@v4
# with:
# name: emerge_cli
# path: cli/emerge-cli-output
# if-no-files-found: error
42 changes: 42 additions & 0 deletions .github/workflows/cli_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CLI Tests and Linting

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
rubocop:
name: Rubocop
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Ruby and install dependencies
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2.2'
bundler-cache: true

- name: Run Rubocop
run: bundle exec rubocop --parallel

minitest:
name: Minitest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Ruby and install dependencies
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2.2'
bundler-cache: true

- name: Run Minitest tests
run: |
bundle exec rake test TESTOPTS="--verbose"
env:
MINITEST_REPORTER: ProgressReporter
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SimpleCov
coverage/

# RSpec
spec/examples.txt

# Rake tasks
.rake_tasks~

# Bundler
.bundle/

# Yardoc
.yardoc
/_yardoc/

# Documentation
/doc/

# Packages
/pkg/

# Reports
/spec/reports/

# Temporary files
/tmp/

# Gems
*.gem

# Gemfile lock
Gemfile.lock

# DS_Store
.DS_Store
93 changes: 93 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Layout

Layout/LineLength:
Max: 120

Layout/EmptyLineAfterGuardClause:
Enabled: false

# Lint

Lint/DuplicateMethods:
Enabled: false

Lint/MissingSuper:
Enabled: false

# Metrics

Metrics/AbcSize:
Enabled: false

Metrics/ClassLength:
Enabled: false

Metrics/CyclomaticComplexity:
Enabled: false

Metrics/MethodLength:
Enabled: false

Metrics/ParameterLists:
Max: 10

Metrics/PerceivedComplexity:
Enabled: false

Metrics/BlockLength:
Enabled: false

Metrics/ModuleLength:
Max: 300

# Naming

Naming/AccessorMethodName:
Enabled: false

Naming/MethodParameterName:
Enabled: false

# Style

Style/Documentation:
Enabled: false
Style/FormatString:
Enabled: false

Style/FrozenStringLiteralComment:
Enabled: false

Style/GlobalStdStream:
Enabled: false

Style/GlobalVars:
Enabled: false

Style/AccessorGrouping:
Enabled: false

Style/InverseMethods:
Enabled: false

Style/MultilineBlockChain:
Enabled: false

Style/NegatedIf:
Enabled: false

Style/NumericPredicate:
Enabled: false

Style/RedundantCapitalW:
Enabled: false

Style/RedundantParentheses:
Enabled: false

Style/TrivialAccessors:
Enabled: false

Style/ZeroLengthPredicate:
Enabled: false

1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.2
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## [0.1.0] - 2024-XX-XX

- Initial release
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gemspec
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
# emerge-cli
# Emerge CLI

WIP - starting with just uploading of BYOSnapshots/apps

## Running

View all commands: `ruby emgcli.rb --help`

### Upload snapshots:

Set the `EMERGE_API_KEY` environment variable to your API key. (alternatively pass with the `--api-token` option)

#### Using with swift-snapshot-testing

```shell
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
```

#### Using with manual image paths

```shell
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"
```

Git info will be set automatically.
13 changes: 13 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'rubocop/rake_task'

RuboCop::RakeTask.new

Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.libs << 'lib'
t.test_files = Dir.glob('test/**/*_test.rb')
end

task default: %i[rubocop test]
13 changes: 13 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'emerge_cli'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. For example:
# require "pry"
# Pry.start

require 'irb'
IRB.start(__FILE__)
18 changes: 18 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'fileutils'

# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

FileUtils.chdir APP_ROOT do
# This script is a way to set up or update your development environment automatically.
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
end
45 changes: 45 additions & 0 deletions emerge_cli.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require_relative 'lib/version'

Gem::Specification.new do |spec|
spec.name = 'emerge'
spec.version = EmergeCli::VERSION
spec.authors = ['Emerge Tools']
spec.email = ['[email protected]']

spec.summary = 'Emerge CLI'
spec.description = 'The official CLI for Emerge Tools'
spec.homepage = 'https://github.com/EmergeTools/emerge-cli'
spec.license = 'MIT'
spec.required_ruby_version = '>= 3.2.0'

spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = spec.homepage
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md"

# Specify which files should be included in the gem when published
spec.files = Dir[
'lib/**/*',
'LICENSE.txt',
'README.md',
'CHANGELOG.md'
]

spec.bindir = 'exe'
spec.executables = ['emerge']
spec.require_paths = ['lib']

spec.add_dependency 'async', '~> 2.20.0'
spec.add_dependency 'async-http', '~> 0.83.1'
spec.add_dependency 'chunky_png', '~> 1.4.0'
spec.add_dependency 'colorize', '~> 1.1.0'
spec.add_dependency 'dry-cli', '~> 1.2.0'
spec.add_dependency 'open3', '~> 0.2.1'

spec.add_development_dependency 'minitest', '~> 5.25.1'
spec.add_development_dependency 'minitest-reporters', '~> 1.7.1'
spec.add_development_dependency 'pry', '~> 0.15.0'
spec.add_development_dependency 'rake', '~> 13.2.1'
spec.add_development_dependency 'rspec', '~> 3.13.0'
spec.add_development_dependency 'rubocop', '~> 1.68.0'
spec.add_development_dependency 'simplecov', '~> 0.22.0'
end
6 changes: 6 additions & 0 deletions exe/emerge
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative '../lib/emerge_cli'

Dry::CLI.new(EmergeCLI).call
15 changes: 15 additions & 0 deletions lib/commands/global_options.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'dry/cli'
require 'logger'

module EmergeCLI
module Commands
class GlobalOptions < Dry::CLI::Command
option :debug, type: :boolean, default: false, desc: 'Enable debug logging'

def before(args)
log_level = args[:debug] ? ::Logger::DEBUG : ::Logger::INFO
EmergeCLI::Logger.configure(log_level)
end
end
end
end
Loading