Skip to content

Detect if a project targets Apple iOS platform

Eugie Limpin requested to merge collect-new-ios-projects into master

What does this MR do and why?

This MR implements the following issues as part of gitlab-org/growth/team-tasks#557 (closed)

What?

Like repository language detection feature, we'll try to detect if a project is built for Apple iOS platform. This information will be used in experiments to customize the experience of developers involved in such projects.

This detection will happen every time changes are pushed to the project’s main branch and after a project is imported (using a project template when creating a project is also an import). Detection is executed in the background as a Sidekiq job at most once every hour (using ExclusiveLease) and only if the project uses Swift or Objective-C programming language.

If the project is detected as built for iOS we mark it by setting the project’s corresponding ProjectSetting target_platforms attribute to [‘ios’].

Why?

The data collected will be used in experiments and analysis. See gitlab-org/growth&93 for a list of planned experiments that will utilize the data collected for iOS projects.

Database changes

This MR adds a new column (target_platforms) to project_settings table.

id project_id (FK) target_platforms
1 2 ['ios']
2 1 ['ios']

Note: Current implementation only detects 'ios' but detection for other platforms (macosx, watchos, tvos, Android platforms) are in the pipeline hence the use of array for target_platforms.

db:migrate output

== 20220318120802 AddTargetPlatformsToProjectSetting: migrating ===============
-- add_column(:project_settings, :target_platforms, :string, {:array=>true, :default=>[], :null=>false, :if_not_exists=>true})
   -> 0.0059s
== 20220318120802 AddTargetPlatformsToProjectSetting: migrated (0.0059s) ======

db:rollback output

== 20220318120802 AddTargetPlatformsToProjectSetting: reverting ===============
-- remove_column(:project_settings, :target_platforms, :string, {:array=>true, :default=>[], :null=>false, :if_not_exists=>true})
   -> 0.0120s
== 20220318120802 AddTargetPlatformsToProjectSetting: reverted (0.0161s) ======

Feature flag

The changes in this MR are behind the record_projects_target_platforms feature flag with Project as the actor.

How to set up and validate locally

Start GDK

Start your GDK simulating gitlab.com

  1. $ export GITLAB_SIMULATE_SAAS=1
  2. gdk start

Enable the feature flag

Feature.enable(:record_projects_target_platforms)

Detect target platforms after project import

  1. Create a new project using the iOS Swift project template
  2. In Rails console, Verify that a ProjectSetting record is created with target_platforms value of ["ios"]
    ProjectSetting.find_by_project_id(project.last.id).target_platforms

Detect target platforms after branch push

  1. Clone the project you created in the previous section locally. We will copy its iOSTemplate.xcodeproj/ dir to a new project.
  2. Create a blank project
  3. Clone the blank project locally
  4. Copy iOSTemplate.xcodeproj/ of the project from (1) to the new project: $ cp -r path/to/otherproj/iOSTemplate.xcodeproj/ path/to/newproj/
  5. Commit the change and push: $ git add -A; git commit -m 'test';git push
  6. In Rails console, Verify that a ProjectSetting record is created with target_platforms value of ["ios"]
    ProjectSetting.find_by_project_id(project.last.id).target_platforms

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Eugie Limpin

Merge request reports