Commit Graph

310 Commits

Author SHA1 Message Date
Zeger-Jan van de Weg c6edae3887
Load commit in batches for pipelines#index
Uses `list_commits_by_oid` on the CommitService, to request the needed
commits for pipelines. These commits are needed to display the user that
created the commit and the commit title.

This includes fixes for tests failing that depended on the commit
being `nil`. However, now these are batch loaded, this doesn't happen
anymore and the commits are an instance of BatchLoader.
2017-12-19 10:05:40 +01:00
Christiaan Van den Poel 7edbc0f8c8 Fix job count in pipeline success mail 2017-12-18 09:13:46 +00:00
Grzegorz Bizon 9293842d09 Do not set pipeline source after initialization 2017-11-30 12:53:35 +01:00
Shinya Maeda 53da3d976f Replce kubernetes_service and deployment_service to deployment_platform 2017-11-28 20:47:59 +09:00
Yorick Peterse 54f1e406f4
Use arrays in Pipeline#latest_builds_with_artifacts
This changes Ci::Pipeline#latest_builds_with_artifacts so it returns an
Array instead of a relation. Whenever we use this data we do so in two
steps:

1. Count the number of rows
2. If this number is greater than 0, iterate over the rows

By returning an Array instead we only execute 1 query of which the total
time/work is less than running either just a COUNT(*) or both queries
(in the worst case).

On GitLab.com this change should save us a few milliseconds per request
to ProjectsController#show.
2017-11-21 17:40:29 +01:00
Rémy Coutable 4f09d099e9 Merge branch '18040-rubocop-line-break-after-guard-clause' into 'master'
Adds Rubocop rule for line break after guard clause

Closes #18040

See merge request gitlab-org/gitlab-ce!15188
2017-11-20 09:22:14 +00:00
Jacopo 181cd299f9 Adds Rubocop rule for line break after guard clause
Adds a rubocop rule (with autocorrect) to ensure line break after guard clauses.
2017-11-16 17:58:29 +01:00
Yorick Peterse ab16a6fb34
Optimise getting the pipeline status of commits
This adds an optimised way of getting the latest pipeline status for a
list of Commit objects (or just a single one).
2017-11-16 16:01:14 +01:00
Lin Jen-Shin c00fde606e Make sure all pipelines would go to pending once
Without this fix, pipeline could go from skipped to
running directly, bypassing the transition for:

    [:created, :pending] => :running

And this is responsible for setting up started_at.
Without this fix, started_at would never be set.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/39884
2017-11-09 16:59:52 +08:00
Douwe Maan fec48c6e17 Use Commit#notes and Note.for_commit_id when possible to make sure we use all the indexes available to us 2017-11-08 12:22:11 +01:00
Zeger-Jan van de Weg 3411fef1df
Cache commits on the repository model
Now, when requesting a commit from the Repository model, the results are
not cached. This means we're fetching the same commit by oid multiple times
during the same request. To prevent us from doing this, we now cache
results. Caching is done only based on object id (aka SHA).

Given we cache on the Repository model, results are scoped to the
associated project, eventhough the change of two repositories having the
same oids for different commits is small.
2017-10-27 12:49:11 +02:00
Grzegorz Bizon 83059f130e Improve pipeline optimistic locking implementation 2017-10-05 11:50:12 +02:00
Grzegorz Bizon 9f639b0733 Set a pipeline failure reason when it has YAML errors
Conflicts:
	app/models/ci/pipeline.rb
2017-10-05 11:38:01 +02:00
Grzegorz Bizon 41d8030ec2 Pass pipeline failure reason to a transition event 2017-10-05 11:36:35 +02:00
Grzegorz Bizon 29f59bdf6f Add failure reason enum to CI/CD pipeline model 2017-10-05 11:33:41 +02:00
Grzegorz Bizon d3762c2247 Implement pipeline seeds size methods 2017-10-05 11:29:28 +02:00
Grzegorz Bizon 1209f4f671 Move related pipeline class to new pipeline module 2017-09-25 13:22:04 +02:00
Grzegorz Bizon f52c61f846 Do not initialize YAML processor with project full path 2017-09-18 14:35:31 +02:00
Grzegorz Bizon d79ad28fcb Do not pass project path from YAML processor
Use project full path that can be received from a pipeline object
2017-09-18 14:29:43 +02:00
Yorick Peterse 7219009993
Memoize the latest builds of a pipeline
This ensures that if a pipeline is present for the last commit on a
project's homepage we only run 1 query to get the builds, instead of
running 2 queries.

See https://gitlab.com/gitlab-org/gitlab-ce/issues/36878#note_40073339
for more information.
2017-09-14 13:20:05 +02:00
Maxim Rydkin c45ace8972
move `lib/ci/gitlab_ci_yaml_processor.rb` into `lib/gitlab/ci/yaml_processor.rb` 2017-09-12 22:32:02 +03:00
Maxim Rydkin c295d3362b
move `lib/ci/model.rb` into `lib/gitlab/ci/model.rb` 2017-09-12 22:32:01 +03:00
Kamil Trzcinski cd8ea329f0 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into zj/gitlab-ce-zj-auto-devops-table 2017-09-06 21:00:47 +02:00
Kamil Trzcinski 82ed2a0909 Improve config source handling code 2017-09-06 18:57:07 +02:00
Shinya Maeda 608cd40607 Remove only validation 2017-09-07 00:31:22 +09:00
Shinya Maeda c4c383e6d5 Revert set_protected 2017-09-07 00:30:44 +09:00
Shinya Maeda 4b8c52f2fc Fix /models/ci/pipeline.rb 2017-09-06 23:19:23 +09:00
Shinya Maeda f7da15bae3 Use before_save :set_protected 2017-09-06 23:09:41 +09:00
Zeger-Jan van de Weg 8189347b49
Merge branch 'master' into zj-auto-devops-table 2017-09-06 15:16:38 +02:00
Zeger-Jan van de Weg c288ca78b4
Use hook for setting Pipeline config_source 2017-09-06 15:14:21 +02:00
Zeger-Jan van de Weg 003bfac293
Incorporate another round of feedback 2017-09-06 09:26:47 +02:00
Zeger-Jan van de Weg bcd70c4c46
Incorporate review 2017-09-04 15:44:46 +02:00
Grzegorz Bizon e23e86953d Merge branch 'master' into feature/gb/kubernetes-only-pipeline-jobs
* master: (469 commits)
2017-09-04 12:13:11 +02:00
Shinya Maeda 5547baa3eb Fix spec 2017-09-03 23:49:11 +09:00
Shinya Maeda ce7c0ac3db Add validation for protected attributes 2017-09-03 23:49:11 +09:00
Grzegorz Bizon 73d0cafbe4 Check if service active when using CI/CD kubernetes policy 2017-09-01 12:58:22 +02:00
Zeger-Jan van de Weg 35b9213cd7
Add config_source to ci_pipelines
Given the user can soon have multiple config sources for CI, we now store
what type at the time of the pipeline run we chose. This will give us
insight into what triggered the new pipeline so we can display it to the
enduser.
2017-08-31 22:25:26 +02:00
Zeger-Jan van de Weg 6ed490401f
Implement the implied CI/CD config for AutoDevOps
Behind an application setting, which defaults to false, this commit
implements the implied CI/CD config. Which means that in the case we
can't find the `.gitlab-ci.yml` on the commit we want to start a
pipeline for, we fall back to an implied configuration.

For now the Bash template has been copied to
`Auto-Devops.gitlab-ci.yml` so the tests actually work.

Fixes #34777
2017-08-31 22:25:25 +02:00
Grzegorz Bizon 92673c2c63 Merge branch 'master' into feature/gb/kubernetes-only-pipeline-jobs
* master: (275 commits)
  Decrease Metrics/PerceivedComplexity threshold to 17
  Upgrade mail and nokogiri gems due to security issues
  Link out to stackoverflow answer on setting swappiness
  Document swappiness recomendations in the requirements doc
  Fix invalid attribute used for time-ago-tooltip component
  Update latest artifacts doc
  Add changelog entry for flipping verify_certificates
  Default LDAP config verify_certificates to true
  Update share project with groups docs
  remove accidental console.log from karma tests
  update specs to match reorganized monitoring components
  Remove tooltips from new sidebar
  Use `git update-ref --stdin -z` to delete refs
  Don't use public_send in destroy_conditionally! helper
  Remove unused expressions policy from ci/cd config
  Simplify code for appending strategies in CI/CD config
  Raise exception when simplifiable ci entry incomplete
  Add changelog entry
  Fix MySQL failure for emoji autocomplete
  max-width for lazy-loaded images (this was removed in the original MR through merge resolution most probably)
  ...

Conflicts:
	lib/gitlab/ci/config/entry/policy.rb
2017-08-31 14:02:52 +02:00
Grzegorz Bizon 96a7e1628a Refactor context variables in pipeline model class 2017-08-31 13:24:03 +02:00
Grzegorz Bizon 326dc7da3b Check if kubernetes required before creating a job 2017-08-26 12:45:36 +02:00
Grzegorz Bizon cdcc196c1f Make it possible to access deployment details from pipeline 2017-08-26 11:17:47 +02:00
Zeger-Jan van de Weg a99b2d8e12
Expose CI_PIPELINE_SOURCE on CI jobs
It was missing and expected it wouldn't hurt anyone
2017-08-23 13:14:49 +02:00
Gabriel Mazetto abb878326c Rename many path_with_namespace -> full_path 2017-08-01 07:26:58 +02:00
Shinya Maeda 1ad4efe64e fix merge miss 2017-07-28 18:13:29 +09:00
Shinya Maeda 56418e85ac init 2017-07-28 18:13:29 +09:00
Lin Jen-Shin 65e722ee97 Merge remote-tracking branch 'upstream/master' into 30634-protected-pipeline
* upstream/master: (638 commits)
  Simplify background migrations stealing code
  Expire cached user IDs that can see the performance after 5 minutes
  Promote visibility level helpers from Group to Namespace
  Fix off-by-one error in background migration retries
  Recover from all exceptions when stealing bg migration
  Fix label creation from new list for subgroup projects
  move click handler to button. when on the icon it wasn't triggered in firefox
  Fix incorrect AWS ELB metrics.
  Fix wrong link to docs in docs styleguide
  Update issue-related docs
  Refactor groups docs
  Add subgroups limitations to Pages docs
  Update Google launcher details
  Split docs on IP whitelist for monitoring access
  Update health check docs
  Bump fog-core to 1.44.3 and fog providers' plugins to latest
  Introduce have_gitlab_http_status
  Remove Repository#search_files
  Update Pipeline's badge count in Merge Request and Commits view to match real-time content
  Fixes the user order being overriden in the autocomplete controller
  ...
2017-07-17 22:38:37 +08:00
Yorick Peterse 8fbbf41e29
Added Cop to blacklist the use of `dependent:`
This is allowed for existing instances so we don't end up 76 offenses
right away, but for new code one should _only_ use this if they _have_
to remove non database data. Even then it's usually better to do this in
a service class as this gives you more control over how to remove the
data (e.g. in bulk).
2017-07-06 12:01:36 +02:00
Lin Jen-Shin 56ea7a0cfe Merge allowed_to_create? into CreatePipelineService 2017-07-05 21:55:35 +08:00
Lin Jen-Shin 9f5ac179d1 Rename ci_config_file to ci_config_path 2017-07-05 20:11:01 +08:00