From e02c69d2acd3555273b8155232a70c6eb719b917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 24 Apr 2023 11:58:18 +0200 Subject: [PATCH] init android plugin (#1) --- .../.github/workflows/test.yml | 24 +++ plugins/fastlane-plugin-android_cd/.gitignore | 12 ++ plugins/fastlane-plugin-android_cd/.rspec | 5 + .../fastlane-plugin-android_cd/.rubocop.yml | 188 ++++++++++++++++++ .../fastlane-plugin-android_cd/.travis.yml | 4 + plugins/fastlane-plugin-android_cd/Gemfile | 6 + plugins/fastlane-plugin-android_cd/LICENSE | 21 ++ plugins/fastlane-plugin-android_cd/README.md | 52 +++++ plugins/fastlane-plugin-android_cd/Rakefile | 9 + .../fastlane-plugin-android_cd.gemspec | 36 ++++ .../fastlane/Fastfile | 3 + .../fastlane/Pluginfile | 1 + .../lib/fastlane/plugin/android_cd.rb | 16 ++ .../android_cd/actions/android_cd_action.rb | 47 +++++ .../android_cd/helper/android_cd_helper.rb | 16 ++ .../lib/fastlane/plugin/android_cd/version.rb | 5 + .../spec/android_cd_action_spec.rb | 9 + .../spec/spec_helper.rb | 15 ++ 18 files changed, 469 insertions(+) create mode 100644 plugins/fastlane-plugin-android_cd/.github/workflows/test.yml create mode 100644 plugins/fastlane-plugin-android_cd/.gitignore create mode 100644 plugins/fastlane-plugin-android_cd/.rspec create mode 100644 plugins/fastlane-plugin-android_cd/.rubocop.yml create mode 100644 plugins/fastlane-plugin-android_cd/.travis.yml create mode 100644 plugins/fastlane-plugin-android_cd/Gemfile create mode 100644 plugins/fastlane-plugin-android_cd/LICENSE create mode 100644 plugins/fastlane-plugin-android_cd/README.md create mode 100644 plugins/fastlane-plugin-android_cd/Rakefile create mode 100644 plugins/fastlane-plugin-android_cd/fastlane-plugin-android_cd.gemspec create mode 100644 plugins/fastlane-plugin-android_cd/fastlane/Fastfile create mode 100644 plugins/fastlane-plugin-android_cd/fastlane/Pluginfile create mode 100644 plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd.rb create mode 100644 plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/android_cd_action.rb create mode 100644 plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb create mode 100644 plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/version.rb create mode 100644 plugins/fastlane-plugin-android_cd/spec/android_cd_action_spec.rb create mode 100644 plugins/fastlane-plugin-android_cd/spec/spec_helper.rb diff --git a/plugins/fastlane-plugin-android_cd/.github/workflows/test.yml b/plugins/fastlane-plugin-android_cd/.github/workflows/test.yml new file mode 100644 index 0000000..f1e0b0c --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/.github/workflows/test.yml @@ -0,0 +1,24 @@ +name: Test + +on: + push: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v1 + with: + path: vendor/bundle + key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile') }} + restore-keys: | + ${{ runner.os }}-gem- + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.5 + - name: Install dependencies + run: bundle check || bundle install --jobs=4 --retry=3 --path vendor/bundle + - name: Run tests + run: bundle exec rake diff --git a/plugins/fastlane-plugin-android_cd/.gitignore b/plugins/fastlane-plugin-android_cd/.gitignore new file mode 100644 index 0000000..b7e3986 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/.gitignore @@ -0,0 +1,12 @@ +*.gem +Gemfile.lock + +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ +fastlane/README.md +fastlane/report.xml +coverage +test-results diff --git a/plugins/fastlane-plugin-android_cd/.rspec b/plugins/fastlane-plugin-android_cd/.rspec new file mode 100644 index 0000000..e1f89b5 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/.rspec @@ -0,0 +1,5 @@ +--require spec_helper +--color +--format d +--format RspecJunitFormatter +--out test-results/rspec/rspec.xml diff --git a/plugins/fastlane-plugin-android_cd/.rubocop.yml b/plugins/fastlane-plugin-android_cd/.rubocop.yml new file mode 100644 index 0000000..fc36fbb --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/.rubocop.yml @@ -0,0 +1,188 @@ +--- +require: +- rubocop/require_tools +- rubocop-performance +AllCops: + TargetRubyVersion: 2.6 + NewCops: enable + Include: + - "**/*.rb" + - "**/*file" + - "**/*.gemspec" + - "*/lib/assets/*Template" + - "*/lib/assets/*TemplateAndroid" + Exclude: + - "**/lib/assets/custom_action_template.rb" + - "./vendor/**/*" + - "**/lib/assets/DefaultFastfileTemplate" + - "**/lib/assets/MatchfileTemplate" + - "**/spec/fixtures/broken_files/broken_file.rb" + - "**/*.provisionprofile" +Lint/ErbNewArguments: + Enabled: false +Style/SlicingWithRange: + Enabled: false +Style/MultipleComparison: + Enabled: false +Style/PercentLiteralDelimiters: + Enabled: false +Style/ClassCheck: + EnforcedStyle: kind_of? +Style/FrozenStringLiteralComment: + Enabled: false +Style/SafeNavigation: + Enabled: false +Performance/RegexpMatch: + Enabled: false +Performance/StringReplacement: + Enabled: false +Style/NumericPredicate: + Enabled: false +Metrics/BlockLength: + Enabled: false +Metrics/ModuleLength: + Enabled: false +Naming/VariableNumber: + Enabled: false +Style/MissingRespondToMissing: + Enabled: false +Style/MultilineBlockChain: + Enabled: false +Style/NumericLiteralPrefix: + Enabled: false +Style/TernaryParentheses: + Enabled: false +Style/EmptyMethod: + Enabled: false +Lint/UselessAssignment: + Exclude: + - "**/spec/**/*" +Require/MissingRequireStatement: + Exclude: + - "**/spec/**/*.rb" + - "**/spec_helper.rb" + - spaceship/lib/spaceship/babosa_fix.rb + - fastlane_core/lib/fastlane_core/ui/disable_colors.rb + - "**/Fastfile" + - "**/*.gemspec" + - rakelib/**/* + - "**/*.rake" + - "**/Rakefile" + - fastlane/**/* + - supply/**/* +Layout/FirstHashElementIndentation: + Enabled: false +Layout/HashAlignment: + Enabled: false +Layout/DotPosition: + Enabled: false +Style/DoubleNegation: + Enabled: false +Style/SymbolArray: + Enabled: false +Layout/HeredocIndentation: + Enabled: false +Style/MixinGrouping: + Exclude: + - "**/spec/**/*" +Lint/SuppressedException: + Enabled: false +Lint/UnusedBlockArgument: + Enabled: false +Lint/AmbiguousBlockAssociation: + Enabled: false +Style/GlobalVars: + Enabled: false +Style/ClassAndModuleChildren: + Enabled: false +Style/SpecialGlobalVars: + Enabled: false +Metrics/AbcSize: + Enabled: false +Metrics/MethodLength: + Enabled: false +Metrics/CyclomaticComplexity: + Enabled: false +Style/WordArray: + MinSize: 19 +Style/SignalException: + Enabled: false +Style/RedundantReturn: + Enabled: false +Style/IfUnlessModifier: + Enabled: false +Style/AndOr: + Enabled: true + EnforcedStyle: conditionals +Metrics/ClassLength: + Max: 320 +Layout/LineLength: + Max: 370 +Metrics/ParameterLists: + Max: 17 +Style/GuardClause: + Enabled: false +Style/StringLiterals: + Enabled: false +Style/ConditionalAssignment: + Enabled: false +Style/RedundantSelf: + Enabled: false +Lint/UnusedMethodArgument: + Enabled: false +Lint/ParenthesesAsGroupedExpression: + Exclude: + - "**/spec/**/*" +Naming/PredicateName: + Enabled: false +Style/PerlBackrefs: + Enabled: false +Layout/SpaceAroundOperators: + Exclude: + - "**/spec/actions_specs/xcodebuild_spec.rb" +Naming/FileName: + Exclude: + - "**/Dangerfile" + - "**/Brewfile" + - "**/Gemfile" + - "**/Podfile" + - "**/Rakefile" + - "**/Fastfile" + - "**/Deliverfile" + - "**/Snapfile" + - "**/Pluginfile" + - "**/*.gemspec" +Style/Documentation: + Enabled: false +Style/MutableConstant: + Enabled: false +Style/ZeroLengthPredicate: + Enabled: false +Style/IfInsideElse: + Enabled: false +Style/CollectionMethods: + Enabled: false +Style/MethodCallWithArgsParentheses: + Enabled: true + IgnoredMethods: + - require + - require_relative + - fastlane_require + - gem + - program + - command + - raise + - attr_accessor + - attr_reader + - desc + - lane + - private_lane + - platform + - to + - not_to + - describe + - it + - be + - context + - before + - after diff --git a/plugins/fastlane-plugin-android_cd/.travis.yml b/plugins/fastlane-plugin-android_cd/.travis.yml new file mode 100644 index 0000000..3b35e45 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/.travis.yml @@ -0,0 +1,4 @@ +# os: osx # enable this if you need macOS support +language: ruby +rvm: + - 2.2.4 diff --git a/plugins/fastlane-plugin-android_cd/Gemfile b/plugins/fastlane-plugin-android_cd/Gemfile new file mode 100644 index 0000000..7e8dba6 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/Gemfile @@ -0,0 +1,6 @@ +source('https://rubygems.org') + +gemspec + +plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') +eval_gemfile(plugins_path) if File.exist?(plugins_path) diff --git a/plugins/fastlane-plugin-android_cd/LICENSE b/plugins/fastlane-plugin-android_cd/LICENSE new file mode 100644 index 0000000..c1a9462 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2023 Malo Léon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/plugins/fastlane-plugin-android_cd/README.md b/plugins/fastlane-plugin-android_cd/README.md new file mode 100644 index 0000000..bc0cac8 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/README.md @@ -0,0 +1,52 @@ +# android_cd plugin + +[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-android_cd) + +## Getting Started + +This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-android_cd`, add it to your project by running: + +```bash +fastlane add_plugin android_cd +``` + +## About android_cd + +Google Play Store deployment plugin for Fastlane, simplifying the build and deployment process to internal, beta, alpha, and production channels, and promoting builds for testing. + +**Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here. + +## Example + +Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`. + +**Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary) + +## Run tests for this plugin + +To run both the tests, and code style validation, run + +``` +rake +``` + +To automatically fix many of the styling issues, use +``` +rubocop -a +``` + +## Issues and Feedback + +For any other issues and feedback about this plugin, please submit it to this repository. + +## Troubleshooting + +If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide. + +## Using _fastlane_ Plugins + +For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/). + +## About _fastlane_ + +_fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools). diff --git a/plugins/fastlane-plugin-android_cd/Rakefile b/plugins/fastlane-plugin-android_cd/Rakefile new file mode 100644 index 0000000..094ebe2 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/Rakefile @@ -0,0 +1,9 @@ +require 'bundler/gem_tasks' + +require 'rspec/core/rake_task' +RSpec::Core::RakeTask.new + +require 'rubocop/rake_task' +RuboCop::RakeTask.new(:rubocop) + +task(default: [:spec, :rubocop]) diff --git a/plugins/fastlane-plugin-android_cd/fastlane-plugin-android_cd.gemspec b/plugins/fastlane-plugin-android_cd/fastlane-plugin-android_cd.gemspec new file mode 100644 index 0000000..5950ed6 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/fastlane-plugin-android_cd.gemspec @@ -0,0 +1,36 @@ +lib = File.expand_path("lib", __dir__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'fastlane/plugin/android_cd/version' + +Gem::Specification.new do |spec| + spec.name = 'fastlane-plugin-android_cd' + spec.version = Fastlane::AndroidCd::VERSION + spec.author = 'Malo Léon' + spec.email = 'malo.leon@wyatt-studio.fr' + + spec.summary = 'Google Play Store deployment plugin for Fastlane, simplifying the build and deployment process to internal, beta, alpha, and production channels, and promoting builds for testing.' + # spec.homepage = "https://github.com//fastlane-plugin-android_cd" + spec.license = "MIT" + + spec.files = Dir["lib/**/*"] + %w(README.md LICENSE) + spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) + spec.require_paths = ['lib'] + + spec.required_ruby_version = '>= 2.6' + + # Don't add a dependency to fastlane or fastlane_re + # since this would cause a circular dependency + + # spec.add_dependency 'your-dependency', '~> 1.0.0' + + spec.add_development_dependency('bundler') + spec.add_development_dependency('fastlane', '>= 2.212.2') + spec.add_development_dependency('pry') + spec.add_development_dependency('rake') + spec.add_development_dependency('rspec') + spec.add_development_dependency('rspec_junit_formatter') + spec.add_development_dependency('rubocop', '1.12.1') + spec.add_development_dependency('rubocop-performance') + spec.add_development_dependency('rubocop-require_tools') + spec.add_development_dependency('simplecov') +end diff --git a/plugins/fastlane-plugin-android_cd/fastlane/Fastfile b/plugins/fastlane-plugin-android_cd/fastlane/Fastfile new file mode 100644 index 0000000..fdbc775 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/fastlane/Fastfile @@ -0,0 +1,3 @@ +lane :test do + android_cd +end diff --git a/plugins/fastlane-plugin-android_cd/fastlane/Pluginfile b/plugins/fastlane-plugin-android_cd/fastlane/Pluginfile new file mode 100644 index 0000000..e0576b0 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/fastlane/Pluginfile @@ -0,0 +1 @@ +# Autogenerated by fastlane diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd.rb new file mode 100644 index 0000000..196367b --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd.rb @@ -0,0 +1,16 @@ +require 'fastlane/plugin/android_cd/version' + +module Fastlane + module AndroidCd + # Return all .rb files inside the "actions" and "helper" directory + def self.all_classes + Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))] + end + end +end + +# By default we want to import all available actions and helpers +# A plugin can contain any number of actions and plugins +Fastlane::AndroidCd.all_classes.each do |current| + require current +end diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/android_cd_action.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/android_cd_action.rb new file mode 100644 index 0000000..71f4c8f --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/android_cd_action.rb @@ -0,0 +1,47 @@ +require 'fastlane/action' +require_relative '../helper/android_cd_helper' + +module Fastlane + module Actions + class AndroidCdAction < Action + def self.run(params) + UI.message("The android_cd plugin is working!") + end + + def self.description + "Google Play Store deployment plugin for Fastlane, simplifying the build and deployment process to internal, beta, alpha, and production channels, and promoting builds for testing." + end + + def self.authors + ["Malo Léon"] + end + + def self.return_value + # If your method provides a return value, you can describe here what it does + end + + def self.details + # Optional: + "The Fastlane Google Play Store deployment plugin streamlines the build and deployment process to internal, beta, alpha, and production channels, simplifying the process of distributing builds for testing. With its advanced promotion functionality, it also enables easy promotion of builds to higher beta testing phases, helping you get your app to market faster." + end + + def self.available_options + [ + # FastlaneCore::ConfigItem.new(key: :your_option, + # env_name: "ANDROID_CD_YOUR_OPTION", + # description: "A description of your option", + # optional: false, + # type: String) + ] + end + + def self.is_supported?(platform) + # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example) + # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform + # + # [:ios, :mac, :android].include?(platform) + true + end + end + end +end diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb new file mode 100644 index 0000000..72f8fb1 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb @@ -0,0 +1,16 @@ +require 'fastlane_core/ui/ui' + +module Fastlane + UI = FastlaneCore::UI unless Fastlane.const_defined?("UI") + + module Helper + class AndroidCdHelper + # class methods that you define here become available in your action + # as `Helper::AndroidCdHelper.your_method` + # + def self.show_message + UI.message("Hello from the android_cd plugin helper!") + end + end + end +end diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/version.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/version.rb new file mode 100644 index 0000000..2ecc613 --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/version.rb @@ -0,0 +1,5 @@ +module Fastlane + module AndroidCd + VERSION = "0.1.0" + end +end diff --git a/plugins/fastlane-plugin-android_cd/spec/android_cd_action_spec.rb b/plugins/fastlane-plugin-android_cd/spec/android_cd_action_spec.rb new file mode 100644 index 0000000..dac01eb --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/spec/android_cd_action_spec.rb @@ -0,0 +1,9 @@ +describe Fastlane::Actions::AndroidCdAction do + describe '#run' do + it 'prints a message' do + expect(Fastlane::UI).to receive(:message).with("The android_cd plugin is working!") + + Fastlane::Actions::AndroidCdAction.run(nil) + end + end +end diff --git a/plugins/fastlane-plugin-android_cd/spec/spec_helper.rb b/plugins/fastlane-plugin-android_cd/spec/spec_helper.rb new file mode 100644 index 0000000..78b2fad --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/spec/spec_helper.rb @@ -0,0 +1,15 @@ +$LOAD_PATH.unshift(File.expand_path('../lib', __dir__)) + +require 'simplecov' + +# SimpleCov.minimum_coverage 95 +SimpleCov.start + +# This module is only used to check the environment is currently a testing env +module SpecHelper +end + +require 'fastlane' # to import the Action super class +require 'fastlane/plugin/android_cd' # import the actual plugin + +Fastlane.load_actions # load other actions (in case your plugin calls other actions or shared values)