Skip to content

[GCSI-515] update fastlane build actions android/ios #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: GCSI-409
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
10 changes: 7 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require:
- rubocop/require_tools
- rubocop-performance
AllCops:
TargetRubyVersion: 2.6
TargetRubyVersion: 3.2.2
NewCops: enable
Include:
- "**/*.rb"
Expand Down Expand Up @@ -70,6 +70,7 @@ Require/MissingRequireStatement:
- "**/Rakefile"
- fastlane/**/*
- supply/**/*
- "lib/fastlane/plugin/**/*.rb"
Layout/FirstHashElementIndentation:
Enabled: false
Layout/HashAlignment:
Expand All @@ -87,6 +88,8 @@ Style/MixinGrouping:
- "**/spec/**/*"
Lint/SuppressedException:
Enabled: false
Lint/IneffectiveAccessModifier:
Enabled: false
Lint/UnusedBlockArgument:
Enabled: false
Lint/AmbiguousBlockAssociation:
Expand Down Expand Up @@ -120,6 +123,8 @@ Layout/LineLength:
Max: 370
Metrics/ParameterLists:
Max: 17
Metrics/PerceivedComplexity:
Max: 10
Style/GuardClause:
Enabled: false
Style/StringLiterals:
Expand Down Expand Up @@ -192,5 +197,4 @@ Bundler/OrderedGems:
Enabled: true
TreatCommentsAsGroupSeparators: false
Gemspec/DevelopmentDependencies:
Enabled: true
EnforcedStyle: Gemfile
Enabled: false
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# instabug-stores-upload plugin
# instabug_stores_upload plugin

[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-instabug-stores-upload)
[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-instabug_stores_upload)

## Getting Started

This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-instabug-stores-upload`, add it to your project by running:
This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-instabug_stores_upload`, add it to your project by running:

```bash
fastlane add_plugin instabug-stores-upload
fastlane add_plugin instabug_stores_upload
```

## About instabug-stores-upload
## About instabug_stores_upload

Wrapper plugin for uploading builds to App Store and Play Store with Instabug-specific metadata reporting. This plugin provides custom actions that wrap the standard Fastlane actions and automatically report build and upload events to Instabug systems for better observability and integration into internal pipelines.

Expand Down
17 changes: 9 additions & 8 deletions fastlane-plugin-instabug-stores-upload.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'fastlane/plugin/instabug_stores_upload/version'

Gem::Specification.new do |spec|
spec.name = 'fastlane-plugin-instabug-stores-upload'
spec.name = 'fastlane-plugin-instabug_stores_upload'
spec.version = Fastlane::InstabugStoresUpload::VERSION
spec.author = 'Instabug'
spec.email = '[email protected]'
Expand All @@ -17,11 +17,12 @@ Gem::Specification.new do |spec|
spec.metadata['rubygems_mfa_required'] = 'true'
spec.required_ruby_version = '>= 3.2.2'

spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rubocop', '1.50.2'
spec.add_development_dependency 'rubocop-require_tools'
spec.add_development_dependency 'simplecov'
spec.add_development_dependency 'fastlane', '~> 2.228.0'
spec.add_development_dependency('bundler')
spec.add_development_dependency('fastlane', '~> 2.228.0')
spec.add_development_dependency('rake')
spec.add_development_dependency('rspec')
spec.add_development_dependency('rubocop', '1.50.2')
spec.add_development_dependency('rubocop-performance')
spec.add_development_dependency('rubocop-require_tools')
spec.add_development_dependency('simplecov')
end
32 changes: 16 additions & 16 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# Example lane for building iOS app with Instabug reporting
lane :build_ios_app do |options|
branch_name = options[:branch_name]

instabug_build_ios_app(
branch_name: branch_name,
instabug_api_key: ENV["INSTABUG_API_KEY"],
branch_name:,
instabug_api_key: ENV.fetch("INSTABUG_API_KEY", nil),
# All standard build_ios_app parameters are supported
workspace: "MyApp.xcworkspace",
scheme: "MyApp",
Expand All @@ -18,42 +18,42 @@ end
# Example lane for building Android app with Instabug reporting
lane :build_android_app do |options|
branch_name = options[:branch_name]

instabug_build_android_app(
branch_name: branch_name,
instabug_api_key: ENV["INSTABUG_API_KEY"],
branch_name:,
instabug_api_key: ENV.fetch("INSTABUG_API_KEY", nil),
# All standard gradle parameters are supported
task: "assembleRelease",
project_dir: "android/",
properties: {
"android.injected.signing.store.file" => "keystore.jks",
"android.injected.signing.store.password" => ENV["KEYSTORE_PASSWORD"],
"android.injected.signing.store.password" => ENV.fetch("KEYSTORE_PASSWORD", nil),
"android.injected.signing.key.alias" => "key0",
"android.injected.signing.key.password" => ENV["KEY_PASSWORD"]
"android.injected.signing.key.password" => ENV.fetch("KEY_PASSWORD", nil)
}
)
end

# Example lane for uploading to App Store with Instabug reporting
lane :upload_to_app_store do |options|
branch_name = options[:branch_name]

instabug_upload_to_app_store(
branch_name: branch_name,
instabug_api_key: ENV["INSTABUG_API_KEY"],
branch_name:,
instabug_api_key: ENV.fetch("INSTABUG_API_KEY", nil),
# All standard upload_to_app_store parameters are supported
ipa: "path/to/your/app.ipa",
skip_waiting_for_build_processing: true
)
end

# Example lane for uploading to Play Store with Instabug reporting
# Example lane for uploading to Play Store with Instabug reporting
lane :upload_to_play_store do |options|
branch_name = options[:branch_name]
branch_name = options[:branch_name]

instabug_upload_to_play_store(
branch_name: branch_name,
instabug_api_key: ENV["INSTABUG_API_KEY"],
branch_name:,
instabug_api_key: ENV.fetch("INSTABUG_API_KEY", nil),
# All standard upload_to_play_store parameters are supported
aab: "path/to/your/app.aab",
track: "internal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,67 @@ module Actions
class InstabugBuildAndroidAppAction < Action
def self.run(params)
UI.message("Starting Instabug Android build...")

# Extract Instabug-specific parameters
branch_name = params.delete(:branch_name)
instabug_api_key = params.delete(:instabug_api_key)

# Validate required parameters
if branch_name.nil? || branch_name.empty?
UI.user_error!("branch_name is required for Instabug reporting")
end

begin
# Report build start to Instabug
Helper::InstabugStoresUploadHelper.report_status(
branch_name: branch_name,
branch_name:,
api_key: instabug_api_key,
status: "inprogress",
step: "build_app"
)

# Start timing the build
build_start_time = Time.now

# Execute the actual Android build using gradle
result = Actions::GradleAction.run(params)

# Calculate build time in seconds
build_time = (Time.now - build_start_time).round

# Extract Android build path (APK or AAB)
build_path = Helper::InstabugStoresUploadHelper.fetch_android_build_path(Actions.lane_context)

if build_path.nil? || build_path.empty?
UI.user_error!("Could not find any generated APK or AAB. Please check your gradle settings.")
else
UI.success("Successfully found build artifact(s) at: #{build_path}")
end

# Report build success to Instabug
Helper::InstabugStoresUploadHelper.report_status(
branch_name: branch_name,
branch_name:,
api_key: instabug_api_key,
status: "success",
step: "build_app"
step: "build_app",
extras: {
build_time:,
build_path:
}
)

UI.success("Android build completed successfully!")
result
rescue => e
rescue StandardError => e
UI.error("Android build failed: #{e.message}")

# Report build failure to Instabug
Helper::InstabugStoresUploadHelper.report_status(
branch_name: branch_name,
branch_name:,
api_key: instabug_api_key,
status: "failure",
step: "build_app"
step: "build_app",
error_message: e.message
)
raise e
end
Expand All @@ -71,7 +91,7 @@ def self.details
def self.available_options
# Start with the original gradle options
options = Actions::GradleAction.available_options

# Add Instabug-specific options
instabug_options = [
FastlaneCore::ConfigItem.new(
Expand All @@ -88,9 +108,17 @@ def self.available_options
optional: false,
type: String,
sensitive: true
)
),
FastlaneCore::ConfigItem.new(
key: :instabug_api_base_url,
env_name: "INSTABUG_API_BASE_URL",
description: "Instabug API base URL (defaults to https://api.instabug.com)",
optional: true,
type: String,
skip_type_validation: true # Since we don't extract this param
)
]

# Combine both sets of options
options + instabug_options
end
Expand Down Expand Up @@ -121,4 +149,4 @@ def self.category
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,67 @@ module Actions
class InstabugBuildIosAppAction < Action
def self.run(params)
UI.message("Starting Instabug iOS build...")

# Extract Instabug-specific parameters
branch_name = params.delete(:branch_name)
instabug_api_key = params.delete(:instabug_api_key)

# Validate required parameters
if branch_name.nil? || branch_name.empty?
UI.user_error!("branch_name is required for Instabug reporting")
end

begin
# Report build start to Instabug
Helper::InstabugStoresUploadHelper.report_status(
branch_name: branch_name,
branch_name:,
api_key: instabug_api_key,
status: "inprogress",
step: "build_app"
)

# Start timing the build
build_start_time = Time.now

# Execute the actual iOS build
result = Actions::BuildIosAppAction.run(params)

# Calculate build time in seconds
build_time = (Time.now - build_start_time).round

# Extract IPA path from Fastlane environment
build_path = Actions.lane_context[SharedValues::IPA_OUTPUT_PATH]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an array instead of string.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied.


if build_path
UI.success("IPA Output Path: #{build_path}")
else
UI.error("No IPA path found.")
end

# Report build success to Instabug
Helper::InstabugStoresUploadHelper.report_status(
branch_name: branch_name,
branch_name:,
api_key: instabug_api_key,
status: "success",
step: "build_app"
step: "build_app",
extras: {
build_time:,
build_path:
}
)

UI.success("iOS build completed successfully!")
result
rescue => e
rescue StandardError => e
UI.error("iOS build failed: #{e.message}")

# Report build failure to Instabug
Helper::InstabugStoresUploadHelper.report_status(
branch_name: branch_name,
branch_name:,
api_key: instabug_api_key,
status: "failure",
step: "build_app"
step: "build_app",
error_message: e.message
)
raise e
end
Expand All @@ -71,7 +91,7 @@ def self.details
def self.available_options
# Start with the original build_ios_app options
options = Actions::BuildIosAppAction.available_options

# Add Instabug-specific options
instabug_options = [
FastlaneCore::ConfigItem.new(
Expand All @@ -88,9 +108,17 @@ def self.available_options
optional: false,
type: String,
sensitive: true
)
),
FastlaneCore::ConfigItem.new(
key: :instabug_api_base_url,
env_name: "INSTABUG_API_BASE_URL",
description: "Instabug API base URL (defaults to https://api.instabug.com)",
optional: true,
type: String,
skip_type_validation: true # Since we don't extract this param
)
]

# Combine both sets of options
options + instabug_options
end
Expand All @@ -117,4 +145,4 @@ def self.category
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Fastlane
module Actions
class InstabugStoresUploadAction < Action
def self.run(params)
UI.message("The instabug-stores-upload plugin is working!")
UI.message("The instabug_stores_upload plugin is working!")
end

def self.description
Expand Down
Loading