Skip to content

Commit

Permalink
chore: update sample app groups
Browse files Browse the repository at this point in the history
  • Loading branch information
mrehan27 committed Jan 10, 2025
1 parent c633035 commit cf466bb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/build-sample-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set Default Firebase Distribution Groups
run: |
# Define all the possible distribution groups
ALL_BUILDS_GROUP="all-builds"
FEATURE_BUILDS_GROUP="feature-branch"
STABLE_BUILDS_GROUP="next"
# Initialize with the default distribution group
distribution_groups=("$ALL_BUILDS_GROUP")
# Determine current app type and Git context
current_branch="${GITHUB_REF}"
# Append distribution groups based on branch and context
[[ "$current_branch" == "refs/heads/feature/"* ]] && distribution_groups+=("$FEATURE_BUILDS_GROUP")
[[ "$current_branch" == "refs/heads/main" ]] && distribution_groups+=("$STABLE_BUILDS_GROUP")
# Export the groups as an environment variable
echo "firebase_distribution_groups=$(IFS=','; echo "${distribution_groups[*]}")" >> $GITHUB_ENV
# Install CLI tools, Ruby, and Ruby dependencies for Fastlane

- name: Install CLI tools used in CI script
Expand Down
26 changes: 8 additions & 18 deletions apps/fastlane/helpers/build_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
platform :android do
lane :build do |values|
build_notes = get_build_notes()
test_groups = get_build_test_groups()
test_groups = get_build_test_groups(distribution_groups: arguments[:distribution_groups])
app_package_name = CredentialsManager::AppfileConfig.try_fetch_value(:package_name) # get package_name from Appfile

# Firebase app id is required. Fetch it from google-services.json file using app_package_name
Expand Down Expand Up @@ -75,7 +75,7 @@

firebase_app_distribution(
service_credentials_file: service_credentials_file_path,
groups: get_build_test_groups(),
groups: get_build_test_groups(distribution_groups: arguments[:distribution_groups]),
release_notes: get_build_notes()
)
end
Expand Down Expand Up @@ -115,22 +115,12 @@
build_notes # return value
end

lane :get_build_test_groups do
test_groups = ['all-builds'] # send all builds to group 'all-builds'. Therefore, set it here and we will not remove it.
test_groups.append("feature-branch") # Feature branch will be used when a PR is merged into a feature branch. We will need to add a check for this.
github = GitHub.new()

# To avoid giving potentially unstable builds of our sample apps to certain members of the organization, we only send builds to "stable" group uncertain certain situations.
# If a commit is merged into main, it's considered stable because we deploy to production on merges to main.
if github.is_commit_pushed && github.push_branch == "main"
test_groups.append("stable-builds")
test_groups.append("next") # Next group will depricate the 'stable` builds group'.
test_groups.append("public") # Temp send to public group until we actually build from the deployed SDK.
end

test_groups = test_groups.join(", ")
lane :get_build_test_groups do |arguments|
# Firebase App Distribution expects a comma separated string of test group names.
# If no groups are passed in, then set test groups to an empty string.
test_groups = arguments[:distribution_groups] || ""

UI.important("Test group names that will be added to this build: #{test_groups}")

test_groups # return value
end
test_groups # return value
end

0 comments on commit cf466bb

Please sign in to comment.