Commit Graph

33 Commits

Author SHA1 Message Date
🙈 jacopo beschi 🙉 729f05f0e3 Adds Rubocop rule for line break around conditionals 2018-01-11 16:34:01 +00:00
Lin Jen-Shin 2a7f1eec12 Memorize the value in methods rather than local 2017-06-21 20:39:05 +08:00
Lin Jen-Shin 98b60ee29b Expand with all the variables so that things like
CI_ENVIRONMENT_SLUG is also available. It won't be
recursive because we're not putting this value in the variables.
2017-06-21 20:22:26 +08:00
Lin Jen-Shin 0d3631acc1 Move expanded_environment_url to CreateDeploymentService
Because that's the only place we need it.
2017-06-21 19:53:19 +08:00
Lin Jen-Shin 1a193d042a Don't expand CI_ENVIRONMENT_URL so runner would do
And make sure CI_ENVIRONMENT_URL comes last so all
variables would be available whenever the runner is
trying to expand it.

This is an alternative to !12333
2017-06-21 18:03:42 +08:00
Lin Jen-Shin 2fa766e107 Only deploy if environment exists; Update tests accordingly 2017-06-03 00:24:20 +08:00
Lin Jen-Shin 3731ae092c CreatePipelineBuildsService would have created env
So we don't have to do it in CreateDeploymentService
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11695#note_31322649
2017-06-02 15:19:34 +08:00
Lin Jen-Shin f62603286d Fix other use of CreateDeploymentService and make
it a bit more robust against missing options,
which we did guard on for some cases.
2017-06-02 02:46:34 +08:00
Lin Jen-Shin 7193108c93 Merge all environment url methods, introduce ensure_persisted_environment
To make sure that we're accessing the same instance, so ending up
with `env.external` = `env.external_url` shall be fine.
2017-06-01 22:52:01 +08:00
Lin Jen-Shin a0990ff356 Simplify CreateDeploymentService so that it uses
methods directly from job, avoid duplicating the works.
2017-06-01 21:01:32 +08:00
Semyon Pupkov 724864eeb4 Remove unnecessary require_relative calls from service classes
Rails by default use autoload for all dirs from app folder.
require_relative not needed. See ActiveSupport::Dependencies.autoload_paths
2016-11-22 11:25:00 +05:00
Kamil Trzcinski e988072207 Fix environments specs 2016-10-17 21:06:10 +02:00
Kamil Trzcinski 4a369185d7 Work on specs 2016-10-17 17:10:26 +02:00
Kamil Trzcinski 9b790f1cf9 Improve after code review 2016-10-17 16:13:19 +02:00
Kamil Trzcinski 021263916c Save `on_stop` in deployment 2016-10-17 12:48:19 +02:00
Kamil Trzcinski 5f98d05939 Add `action` and `on_stop` to `environment` in .gitlab-ci.yml 2016-10-17 12:46:00 +02:00
Kamil Trzcinski 6cdbb27ec3 Refactor code to use available and stopped statuses and refactor views to use separate renders 2016-10-17 12:45:31 +02:00
Kamil Trzcinski 40528a1326 Merge remote-tracking branch 'origin/master' into 22191-delete-dynamic-envs-mr 2016-10-17 11:24:51 +02:00
Grzegorz Bizon 3726dc4bb7 Check if project exists before creating deployment 2016-10-14 10:19:16 +02:00
Grzegorz Bizon 03a8ed9711 Use trasaction to process build deployment 2016-10-13 13:23:23 +02:00
Kamil Trzcinski 3f85c3ef16 Initial support for closing environments 2016-10-06 13:16:34 +02:00
Timothy Andrew 918e589c2b Implement a second round of review comments from @DouweM.
- Don't use `TableReferences` - using `.arel_table` is shorter!
- Move some database-related code to `Gitlab::Database`
- Remove the `MergeRequest#issues_closed` and
  `Issue#closed_by_merge_requests`  associations. They were either
  shadowing or were too similar to existing methods. They are not being
  used anywhere, so it's better to remove them to reduce confusion.
- Use Rails 3-style validations
- Index for `MergeRequest::Metrics#first_deployed_to_production_at`
- Only include `CycleAnalyticsHelpers::TestGeneration` for specs that
  need it.
- Other minor refactorings.
2016-09-21 00:47:37 +05:30
Timothy Andrew 8957293d9b Implement review comments from @yorickpeterse
1. Change multiple updates to a single `update_all`

2. Use cascading deletes

3. Extract an average function for the database median.

4. Move database median to `lib/gitlab/database`

5. Use `delete_all` instead of `destroy_all`

6. Minor refactoring
2016-09-20 16:05:25 +05:30
Timothy Andrew fa890604aa Merge remote-tracking branch 'origin/master' into 21170-cycle-analytics 2016-09-20 14:48:13 +05:30
Kamil Trzcinski 6b97968745 Update support for dynamic environments 2016-09-19 10:07:13 +02:00
Kamil Trzcinski e1b3ab5af2 Verify expandability of variables defined as part of environment 2016-09-19 10:07:13 +02:00
Kamil Trzcinski a4638dddf2 Add support for dynamic environments
Environments that can have a URL with predefined CI variables.
2016-09-19 10:05:35 +02:00
Timothy Andrew 8f6208513a Test all cycle analytics pre-calculation code.
All the code that pre-calculates metrics for use in the cycle analytics
page.

- Ci::Pipeline -> build start/finish
- Ci::Pipeline#merge_requests
- Issue -> record default metrics after save
- MergeRequest -> record default metrics after save
- Deployment -> Update "first_deployed_to_production_at" for MR metrics
- Git Push -> Update "first commit mention" for issue metrics
- Merge request create/update/refresh -> Update "merge requests closing issues"
2016-09-19 13:12:06 +05:30
Timothy Andrew ba25e2f1ac Improve performance of the cycle analytics page.
1. These changes bring down page load time for 100 issues from more than
   a minute to about 1.5 seconds.

2. This entire commit is composed of these types of performance
   enhancements:

     - Cache relevant data in `IssueMetrics` wherever possible.
     - Cache relevant data in `MergeRequestMetrics` wherever possible.
     - Preload metrics

3. Given these improvements, we now only need to make 4 SQL calls:

    - Load all issues
    - Load all merge requests
    - Load all metrics for the issues
    - Load all metrics for the merge requests

4. A list of all the data points that are now being pre-calculated:

    a. The first time an issue is mentioned in a commit

      - In `GitPushService`, find all issues mentioned by the given commit
        using `ReferenceExtractor`. Set the `first_mentioned_in_commit_at`
        flag for each of them.

      - There seems to be a (pre-existing) bug here - files (and
        therefore commits) created using the Web CI don't have
        cross-references created, and issues are not closed even when
        the commit title is "Fixes #xx".

    b. The first time a merge request is deployed to production

      When a `Deployment` is created, find all merge requests that
      were merged in before the deployment, and set the
      `first_deployed_to_production_at` flag for each of them.

    c. The start / end time for a merge request pipeline

      Hook into the `Pipeline` state machine. When the `status` moves to
      `running`, find the merge requests whose tip commit matches the
      pipeline, and record the `latest_build_started_at` time for each
      of them. When the `status` moves to `success`, record the
      `latest_build_finished_at` time.

    d. The merge requests that close an issue

      - This was a big cause of the performance problems we were having
        with Cycle Analytics. We need to use `ReferenceExtractor` to make
        this calculation, which is slow when we have to run it on a large
        number of merge requests.

      - When a merge request is created, updated, or refreshed, find the
        issues it closes, and create an instance of
        `MergeRequestsClosingIssues`, which acts as a join model between
        merge requests and issues.

      - If a `MergeRequestsClosingIssues` instance links a merge request
        and an issue, that issue closes that merge request.

5. The `Queries` module was changed into a class, so we can cache the
   results of `issues` and `merge_requests_closing_issues` across
   various cycle analytics stages.

6. The code added in this commit is untested. Tests will be added in the
   next commit.
2016-09-15 14:53:02 +05:30
Kamil Trzcinski 14a02a6a95 Improve design after review 2016-06-14 18:34:48 +02:00
Kamil Trzcinski 3ade826065 Add specs for models and services 2016-06-14 13:51:12 +02:00
Kamil Trzcinski 4f00b93ddd Add deployment views 2016-06-11 00:15:53 +02:00
Kamil Trzcinski 907c0e6796 Added initial version of deployments 2016-06-10 23:36:54 +02:00