Skip to content

Test Fork PR #9

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 25 commits into
base: dummyTestPR
Choose a base branch
from
Open
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
64 changes: 54 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ jobs:
- checkout

- run:
name: PR Files Test
command: ruby .circleci/gitChangedLibs.rb
name: Determine Tests to Run
shell: /bin/bash
command: |
LIBS_TO_TEST=$(ruby .circleci/gitChangedLibs.rb)
echo "export LIBS_TO_TEST=${LIBS_TO_TEST}" >> "${BASH_ENV}"
echo -e "\n\nLibraries to Test-> ${LIBS_TO_TEST}"

- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "build.gradle" }}
Expand All @@ -44,48 +48,88 @@ jobs:
- run:
name: Run SalesforceAnalytics Tests
halt_build_on_fail: false
command: ./gradlew :libs:SalesforceAnalytics:connectedAndroidTest --continue --no-daemon --profile --max-workers 2
no_output_timeout: 900
when: always
command: |
if [[ ${LIBS_TO_TEST} == *"SalesforceAnalytics"* ]]; then
./gradlew :libs:SalesforceAnalytics:connectedAndroidTest --continue --no-daemon --profile --max-workers 2
else
echo "No need to run SalesforceAnalytics tests for this PR."
fi

- run:
name: Run SalesforceSDK Tests
name: Run Salesforce Core Tests
halt_build_on_fail: false
command: ./gradlew :libs:SalesforceSDK:connectedAndroidTest --continue --no-daemon --profile --max-workers 2
no_output_timeout: 900
when: always
command: |
if [[ ${LIBS_TO_TEST} == *"SalesforceSDK"* ]]; then
./gradlew :libs:SalesforceSDK:connectedAndroidTest --continue --no-daemon --profile --max-workers 2
else
echo "No need to run Salesforce Core tests for this PR."
fi

- run:
name: Run SmartStore Tests
halt_build_on_fail: false
command: ./gradlew :libs:SmartStore:connectedAndroidTest --continue --no-daemon --profile --max-workers 2
no_output_timeout: 900
when: always
command: |
if [[ ${LIBS_TO_TEST} == *"SmartStore"* ]]; then
./gradlew :libs:SmartStore:connectedAndroidTest --continue --no-daemon --profile --max-workers 2
else
echo "No need to run SmartStore tests for this PR."
fi

- run:
name: Run SmartSync Tests
halt_build_on_fail: false
command: ./gradlew :libs:SmartSync:connectedAndroidTest --continue --no-daemon --profile --max-workers 2
no_output_timeout: 900
when: always
command: |
if [[ ${LIBS_TO_TEST} == *"SmartSync"* ]]; then
./gradlew :libs:SmartSync:connectedAndroidTest --continue --no-daemon --profile --max-workers 2
else
echo "No need to run SmartSync tests for this PR."
fi

- run:
name: Run SalesforceHybrid Tests
halt_build_on_fail: false
command: ./gradlew :libs:SalesforceHybrid:connectedAndroidTest --continue --no-daemon --profile --max-workers 2
no_output_timeout: 900
when: always
command: |
if [[ ${LIBS_TO_TEST} == *"SalesforceHybrid"* ]]; then
./gradlew :libs:SalesforceHyrbid:connectedAndroidTest --continue --no-daemon --profile --max-workers 2
else
echo "No need to run SalesforceHybrid tests for this PR."
fi

- run:
name: Build SalesforceReact
halt_build_on_fail: false
command: ./gradlew :libs:SalesforceReact:assembleDebug -p . --continue --no-daemon --profile --max-workers 2
no_output_timeout: 900
when: always
command: |
if [[ ${LIBS_TO_TEST} == *"SalesforceReact"* ]]; then
./gradlew :libs:SalesforceReact:assembleDebug -p . --continue --no-daemon --profile --max-workers 2
else
echo "No need to build SalesforceReact for this PR."
fi

- run:
name: Combine lib Test Restuls
command: junit-merge libs/**/build/outputs/androidTest-results/connected/*.xml
when: always
- run:
name: Run Danger
command: danger --dangerfile=.circleci/Dangerfile --danger_id=ci/circleci
when: always
command: |
if [ -n "$CIRCLE_PR_NUMBER" ]; then
DANGER_GITHUB_API_TOKEN="c21349d8a97e1bf9cdd9""301fd949a83db862216b" danger --dangerfile=.circleci/Dangerfile --danger_id=ci/circleci
else
echo "Not a PR, no need to run Danger."
fi

- store_artifacts:
path: libs/SalesforceAnalytics/build/reports/
Expand Down
23 changes: 14 additions & 9 deletions .circleci/gitChangedLibs.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
require 'json'
require 'set'

$GITPRAPI = "https://api.github.com/repos/%s/SalesforceMobileSDK-android/pulls/%s/files"
$libs = ["SalesforceAnalytics", "SalesforceHybridSDK", "SalesforceReact", "SalesforceSDKCore", "SmartStore", "SmartSync"]
$libs = ["SalesforceAnalytics", "SalesforceHybridSDK", "SalesforceReact", "SalesforceSDK", "SmartStore", "SmartSync"]

prFilesAPI = $GITPRAPI % [ENV["CIRCLE_PROJECT_USERNAME"], ENV["CIRCLE_PR_NUMBER"]]
puts "prFIelsAPI: " + prFilesAPI
curlCommand = "curl %s -H 'Authorization: token %s'" % [prFilesAPI, ENV["GITHUB_TOKEN"]]
pullfiles = `#{curlCommand}`
pullfiles = `#{"curl %s" % [prFilesAPI]}`
prfiles = JSON.parse(pullfiles)

# delete me
puts "PR Files: " + prfiles.to_a().join(",")

libs = Set.new
for prfile in prfiles
path = prfile["filename"]
for lib in $libs
if path.include? lib
testLibs = testLibs.add(lib)
libs = libs.add(lib)
end
end
end
puts "Libs:" + testLibs.to_a().join(",")

libs_ar = libs.to_a()
if !libs_ar.empty?() && libs_ar.include?("SalesforceSDK")
libs_ar = $libs.to_a()
elsif libs_ar.include?("SmartStore") && !libs_ar.include?("SmartSync")
libs_ar.push("SmartSync")
end

print libs_ar.join(", ")
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
test some stuff

updated
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
asjodnfasjdnfak;j