From 6eb567d09fa40f80e7d815980ef2c64144406b7e Mon Sep 17 00:00:00 2001 From: staszekscp Date: Fri, 18 Nov 2022 09:55:08 +0100 Subject: [PATCH] test android deployment --- .github/workflows/testBuild.yml | 87 +++++++++++++++++++++++++++++++++ Gemfile | 4 ++ Gemfile.lock | 10 ++++ fastlane/Fastfile | 23 +++++++++ fastlane/Pluginfile | 5 ++ 5 files changed, 129 insertions(+) create mode 100644 .github/workflows/testBuild.yml create mode 100644 fastlane/Pluginfile diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml new file mode 100644 index 000000000000..f760ea946281 --- /dev/null +++ b/.github/workflows/testBuild.yml @@ -0,0 +1,87 @@ +name: Build and deploy apps for testing + +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize] + +env: + DEVELOPER_DIR: /Applications/Xcode_14.0.1.app/Contents/Developer + +jobs: + validateActor: + runs-on: ubuntu-latest + outputs: + IS_DEPLOYER: ${{ fromJSON(steps.isUserDeployer.outputs.isTeamMember) || github.actor == 'OSBotify' }} + steps: + - id: isUserDeployer + uses: tspascoal/get-user-teams-membership@baf2e6adf4c3b897bd65a7e3184305c165aec872 + with: + GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} + username: ${{ github.actor }} + team: mobile-deployers + + android: + name: Build and deploy Android + needs: validateActor + if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) }} + runs-on: ubuntu-latest + steps: + + - uses: Expensify/App/.github/actions/composite/setupNode@main + + - uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7 + with: + ruby-version: '2.7' + bundler-cache: true + + - name: Decrypt keystore + run: cd android/app && gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output my-upload-key.keystore my-upload-key.keystore.gpg + env: + LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} + + - name: Decrypt json key + run: cd android/app && gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output android-fastlane-json-key.json android-fastlane-json-key.json.gpg + env: + LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} + + - name: Run Fastlane beta test + id: runFastlaneBetaTest + run: bundle exec fastlane android build_test + env: + S3_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }} + S3_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + S3_BUCKET: ad-hoc-expensify-cash + S3_REGION: us-east-1 + + - uses: actions/upload-artifact@v2 + with: + name: paths.json + path: ./paths.json + + + postGithubComment: + runs-on: ubuntu-latest + name: An example job to comment a PR + needs: [android] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: actions/download-artifact@v2 + with: + name: paths.json + + - id: set_var + run: | + content=`cat ./paths.json` + content="${content//'%'/'%25'}" + content="${content//$'\n'/'%0A'}" + content="${content//$'\r'/'%0D'}" + echo "::set-output name=paths::$content" + + - name: Comment PR + uses: thollander/actions-comment-pull-request@v1 + with: + message: | + 'Hello world ! ${{fromJson(steps.set_var.outputs.paths).html_path}}' \ No newline at end of file diff --git a/Gemfile b/Gemfile index c41a21c6604f..86cf34940e86 100644 --- a/Gemfile +++ b/Gemfile @@ -3,3 +3,7 @@ source "https://rubygems.org" gem "cocoapods", "~> 1.11.3" gem "fastlane", "~> 2" gem "xcpretty", "~> 0" + + +plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') +eval_gemfile(plugins_path) if File.exist?(plugins_path) \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 5ac763189187..95a2611d953c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,6 +14,8 @@ GEM algoliasearch (1.27.5) httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) + apktools (0.7.4) + rubyzip (~> 2.0) artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) @@ -155,6 +157,10 @@ GEM xcodeproj (>= 1.13.0, < 2.0.0) xcpretty (~> 0.3.0) xcpretty-travis-formatter (>= 0.0.3) + fastlane-plugin-aws_s3 (2.1.0) + apktools (~> 0.7) + aws-sdk-s3 (~> 1) + mime-types (~> 3.3) ffi (1.15.5) fourflusher (2.3.1) fuzzy_match (2.0.4) @@ -207,6 +213,9 @@ GEM json (2.6.2) jwt (2.5.0) memoist (0.16.2) + mime-types (3.4.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2022.0105) mini_magick (4.11.0) mini_mime (1.1.2) minitest (5.16.2) @@ -283,6 +292,7 @@ PLATFORMS DEPENDENCIES cocoapods (~> 1.11.3) fastlane (~> 2) + fastlane-plugin-aws_s3 xcpretty (~> 0) BUNDLED WITH diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 74060ccb501c..795dec68c235 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -36,6 +36,29 @@ platform :android do ) end + desc "Build app for testing" + lane :build_test do + ENV["ENVFILE"]="e2e/.env.e2e" + + gradle( + project_dir: './android', + task: 'bundle', + build_type: 'Release', + ) + + aws_s3( + access_key: ENV['S3_ACCESS_KEY'], + secret_access_key: ENV['S3_SECRET_ACCESS_KEY'], + bucket: ENV['S3_BUCKET'], + region: ENV['S3_REGION'], + + apk: 'expensify_test.apk', + app_directory: 'android', + ) + + sh('echo "{\"apk_path\": \"${lane_context[SharedValues::S3_APK_OUTPUT_PATH]}\",\"html_path\": \"${lane_context[SharedValues::S3_HTML_OUTPUT_PATH]}\"}" > ../paths.json') + end + desc "Build and upload app to Google Play" lane :beta do ENV["ENVFILE"]=".env.production" diff --git a/fastlane/Pluginfile b/fastlane/Pluginfile new file mode 100644 index 000000000000..c6ab0dfb46a4 --- /dev/null +++ b/fastlane/Pluginfile @@ -0,0 +1,5 @@ +# Autogenerated by fastlane +# +# Ensure this file is checked in to source control! + +gem 'fastlane-plugin-aws_s3'