Stop compiling assets on auto-deploy pipelines
Currently, we set COMPILE_ASSETS
to true whenever we detect we are running on an auto-deploy pipeline. The reasoning we gave is as follows
Always compile assets for auto-deploy builds,this is done for auto-deploy builds so that we do not have to wait for the compile assets job in the gitlab-ee pipeline.
However, the time spent on compiling assets for Rails is much more than what we will be spending on waiting for the assets image to be built. Checking the recent 40 tag pipeline jobs in omnibus-gitlab
(which still relies on fetching the asset image), the most fetch-asset
job ever waited was for 21 minutes.
Code
require 'gitlab'
client = Gitlab::Client.new(endpoint: 'https://dev.gitlab.org/api/v4', private_token: ENV['DEV_GITLAB_API_TOKEN'])
# At the time of writing, this gave 40 auto-deploy pipelines. 10 of them were regular tag builds.
pipelines = client.pipelines(283, scope: 'tags', per_page: 50).select { |pipeline| pipeline.ref.length > 15 }
pipelines.each do |pipeline|
fetch_asset_job = client.pipeline_jobs(283, pipeline.id).find { |job| job.name == 'fetch-assets' }
next if fetch_asset_job.nil?
puts "#{pipeline.web_url}: #{fetch_asset_job.duration} seconds"
end
Looking at https://dev.gitlab.org/gitlab/charts/components/images/-/jobs/21768287, it takes almost an hour (52 minutes) to compile the assets in CNG pipeline. So, we are not doing us any good by compiling assets in this pipeline. Let's stop doing that and just wait for the asset image from GitLab Rails pipeline