Skip to content
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

test #10

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open

test #10

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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ USE_WEB_PROXY=false
USE_WDYR=false
CAPTURE_METRICS=false
ONYX_METRICS=false

2 changes: 2 additions & 0 deletions .github/actions/composite/setupNode/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ runs:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}


- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516
with:
Expand Down
140 changes: 140 additions & 0 deletions .github/workflows/testBuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Build and deploy apps for testing

on:
pull_request_target:
types: [opened, synchronize]

env:
DEVELOPER_DIR: /Applications/Xcode_14.0.1.app/Contents/Developer

jobs:
android:
name: Build and deploy Android
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: aws-upload-test-fastlane
S3_REGION: eu-central-1

- uses: actions/upload-artifact@v2
with:
name: android
path: ./android_paths.json

iOS:
name: Build and deploy iOS
runs-on: macos-12
steps:
- uses: Expensify/App/.github/actions/composite/setupNode@main

- uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7
with:
ruby-version: '2.7'
bundler-cache: true

- name: Install cocoapods
uses: nick-invision/retry@0711ba3d7808574133d713a0d92d2941be03a350
with:
timeout_minutes: 10
max_attempts: 5
command: cd ios && pod install

- name: Decrypt profile
run: cd ios && gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output chat_expensify_adhoc.mobileprovision.gpg chat_expensify_adhoc.mobileprovision.gpg.gpg
env:
LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}

- name: Decrypt certificate
run: cd ios && gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" --output Certificates.p12 Certificates.p12.gpg
env:
LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}

- name: Run Fastlane
run: bundle exec fastlane ios 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: ios
path: ./ios_paths.json


# web:
# name: Build and deploy Web
# runs-on: ubuntu-latest
# steps:
# - uses: Expensify/App/.github/actions/composite/setupNode@main

# - name: Configure AWS Credentials
# # Version: 1.5.5
# uses: aws-actions/configure-aws-credentials@e97d7fbc8e0e5af69631c13daa0f4b5a8d88165b
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: us-east-1

# - name: Build web for staging
# run: npm run build-staging

# - name: Build docs
# run: npm run storybook-build
# continue-on-error: true

# - name: Deploy to S3 for internal testing
# run: aws s3 cp --recursive --acl public-read "$GITHUB_WORKSPACE"/dist s3://aws-upload-test-fastlane/web/"$PULL_REQUEST_NAME"
# env:
# PULL_REQUEST_NAME: ${{ github.event.pull_request.title }}

postGithubComment:
runs-on: ubuntu-latest
name: An example job to comment a PR
needs: [android]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: actions/download-artifact@v2

- name: Read JSONs with paths
id: set_var
run: |
content_android=`cat ./android/android_paths.json`
content_android="${content_android//'%'/'%25'}"
content_android="${content_android//$'\n'/'%0A'}"
content_android="${content_android//$'\r'/'%0D'}"
echo "::set-output name=android_paths::$content_android"

- name: Comment PR
uses: thollander/actions-comment-pull-request@v1
with:
message: |
'Hello world ! ${{fromJson(steps.set_var.outputs.android_paths).html_path}}''
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -283,6 +292,7 @@ PLATFORMS
DEPENDENCIES
cocoapods (~> 1.11.3)
fastlane (~> 2)
fastlane-plugin-aws_s3
xcpretty (~> 0)

BUNDLED WITH
Expand Down
87 changes: 87 additions & 0 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,37 @@ platform :android do
)
end

desc "Dummy for testing"
lane :dummy do

apk = "some path"
html = 'some html'

sh("echo '{\"apk_path\": \"#{apk}\",\"html_path\": \"#{html}\"}' > ../android_paths.json")
end

desc "Build app for testing"
lane :build_test do
ENV["ENVFILE"]="e2e/.env.e2e"
gradle(
project_dir: './android',
task: 'assemble',
build_type: 'Debug',
)

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: lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH],
app_directory: 'android',
)

sh("echo '{\"apk_path\": \"#{lane_context[SharedValues::S3_APK_OUTPUT_PATH]}\",\"html_path\": \"#{lane_context[SharedValues::S3_HTML_OUTPUT_PATH]}\"}' > ../android_paths.json")
end

desc "Build and upload app to Google Play"
lane :beta do
ENV["ENVFILE"]=".env.production"
Expand Down Expand Up @@ -91,6 +122,62 @@ platform :ios do
)
end

desc "Dummy for testing"
lane :dummy do

ipa = "some path"
html = 'some html'

sh("echo '{\"ipa_path\": \"#{ipa}\",\"html_path\": \"#{html}\"}' > ../ios_paths.json")
end

desc "Build app for testing"
lane :build_test do
require 'securerandom'
ENV["ENVFILE"]=".env.production"

keychain_password = SecureRandom.uuid

create_keychain(
name: "ios-build.keychain",
password: keychain_password,
default_keychain: "true",
unlock: "true",
timeout: "3600",
add_to_search_list: "true"
)

import_certificate(
certificate_path: "./ios/Certificates.p12",
keychain_name: "ios-build.keychain",
keychain_password: keychain_password
)

install_provisioning_profile(
path: "./ios/chat_expensify_adhoc.mobileprovision.gpg"
)

build_app(
workspace: "./ios/NewExpensify.xcworkspace",
scheme: "NewExpensify",
export_options: {
manageAppVersionAndBuildNumber: false
}
)

aws_s3(
access_key: ENV['S3_ACCESS_KEY'],
secret_access_key: ENV['S3_SECRET_ACCESS_KEY'],
bucket: ENV['S3_BUCKET'],
region: ENV['S3_REGION'],

ipa: lane_context[SharedValues::IPA_OUTPUT_PATH],
app_directory: 'ios',
)

sh("echo '{\"ipa_path\": \"#{lane_context[SharedValues::S3_IPA_OUTPUT_PATH]}\",\"html_path\": \"#{lane_context[SharedValues::S3_HTML_OUTPUT_PATH]}\"}' > ../ios_paths.json")
end

desc "Build and upload app to TestFlight"
lane :beta do
require 'securerandom'
Expand Down
5 changes: 5 additions & 0 deletions fastlane/Pluginfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Autogenerated by fastlane
#
# Ensure this file is checked in to source control!

gem 'fastlane-plugin-aws_s3'