Commit Graph

180 Commits

Author SHA1 Message Date
Yorick Peterse 590ff80f83
Refactor how a few ActiveRecord enums are defined
In a few models we define ActiveRecord enums that are redefined in EE
using the following pattern:

    enum :some_enum, {
      ...
    }.merge(EE_ENUM_VALUES)

This particular approach is problematic to deal with, because it
requires that we `prepend` and EE module _before_ defining the enum.
This typically translates to the `prepend` being the first line in the
model in EE, but this can easily lead to merge conflicts when developers
add more `include` and/or `prepend` lines.

As part of https://gitlab.com/gitlab-org/gitlab-ee/issues/8244 and
https://gitlab.com/gitlab-org/gitlab-ee/issues/8241 we are moving
`prepend` to the last line in a file, reducing the chances of running
into merge conflicts. This poses a bit of a problem with the pattern
above, because this pattern does not allow us to move the `prepend`
further down a file.

To resolve this problem, we simply move the Hash value of the enum to a
separate class method. This method is defined in a separate module where
necessary, allowing us to use it like so:

    enum :failure_reasons, ::SomeModelEnums.failure_reasons

The method in turn is defined in a very straightforward manner:

    module SomeModelEnums
      def self.failure_reasons
        {
          ...
        }
      end
    end

This makes it easy for EE to add values without requiring the `prepend`
to be placed before the `enum` is defined.

For more information, see the following issues and merge requests:

* https://gitlab.com/gitlab-org/gitlab-ee/issues/8244
* https://gitlab.com/gitlab-org/gitlab-ee/issues/8241
* https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/8424
2018-11-15 17:41:54 +01:00
Kamil Trzciński 40397f3577 Allow to make builds soft-archived.
The soft-archived builds cannot be run after some deadline time.
The intent is to aggressively recycle old builds after sometime.
2018-11-05 15:51:57 +01:00
George Tsiolis 733ae94921 Fix typos in comments and specs 2018-11-01 08:59:20 +02:00
Shinya Maeda 4611a59968 Add failure reason for execution timeout 2018-10-28 18:31:08 +00:00
Shinya Maeda 0c9ad4826a Support backward compatibility when introduce new failure reason 2018-10-26 08:01:28 +00:00
Shinya Maeda 8bc065e02d Rename failure reason to stale_schedule 2018-10-02 17:08:14 +02:00
Shinya Maeda 587560757f Fix StuckCiJobsWorker and added tests 2018-10-02 17:08:12 +02:00
Shinya Maeda c9077a0efd Add cleanup mechanizm for stale scheduled jobs 2018-10-02 17:04:04 +02:00
Shinya Maeda ffbc0b1c29 Remove whitespace 2018-10-02 17:02:12 +02:00
Shinya Maeda a7c767f164 Add a new status to ci_builds.status 2018-10-02 17:02:11 +02:00
Yorick Peterse 2039c8280d
Disable existing offenses for the CodeReuse cops
This whitelists all existing offenses for the various CodeReuse cops, of
which most are triggered by the CodeReuse/ActiveRecord cop.
2018-09-11 17:32:00 +02:00
Rémy Coutable f20a40f4a1 Merge branch 'frozen-string-enable-app-models' into 'master'
Enable frozen string in app/models/*.rb

See merge request gitlab-org/gitlab-ce!20851
2018-08-02 09:11:52 +00:00
Kamil Trzciński c0abcc68de Fix spec failures 2018-08-01 12:25:19 +02:00
Kamil Trzciński 6b0bfda8ac Add `runner_unsupported` CI failure 2018-08-01 12:25:19 +02:00
gfyoung 50abbd3e53 Enable frozen string in app/models/*.rb
Partially addresses #47424.
2018-07-26 16:55:41 -07:00
Jan Provaznik 0665a8f730 Enable mapping to nil in enums
Enum in Rails 5 does not map nil values - IOW nil value remains nil,
even if there is a key with nil value in the enum definition.

This commit overrides the underlying Enum methods so nil value is
still mapped. This solution is far from being ideal: it uses dynamic
definition of methods which introduces more magic/confusion
into the codebase.

It would be better to get rid of the nil value in enums.
2018-06-06 20:46:54 +02:00
Mayra Cabrera 86ef822177 Makes CommitStatus and GenericCommitStatus respond to presentable
methods

Includes Presentable module into CommitStatus. This fixes presenter
methods being called on those classes.

Closes #46177
2018-05-15 14:24:11 -05:00
blackst0ne 9e78b86dd4 [Rails5] Fix enum question mark methods 2018-05-02 08:09:19 +00:00
Tomasz Maczukin 2cc0c692c0
Ensure that enqueuing a commit status always sets 'queued_at' value 2018-04-10 15:13:55 +02:00
Zeger-Jan van de Weg 16ea3315f2
Revert "Allow CI/CD Jobs being grouped on version strings"
This reverts commit 4f2cdb51df.
2018-04-04 14:10:22 +02:00
Zeger-Jan van de Weg 4f2cdb51df
Allow CI/CD Jobs being grouped on version strings
This makes grouping on version number available. In general I'd like to
group based on MAJOR.MINOR version numbers for Gitaly.
2018-03-01 12:39:30 +01:00
Takuya Noguchi 2b6307f6ad Enable RuboCop Style/RegexpLiteral 2018-02-01 02:06:07 +09:00
Shinya Maeda 67c7e0fc5d Fail jobs if its dependency is missing 2017-12-06 15:53:59 +09:00
Kamil Trzcinski 07c7ba1bf4 Allow to drop jobs for deleted projects 2017-11-27 11:56:15 +01:00
Grzegorz Bizon 164b1df590 Extract ensure stage service from commit status class 2017-11-06 11:04:09 +01:00
Grzegorz Bizon e2828a6067 Use existing pipeline stage if stage already exists 2017-11-06 11:04:09 +01:00
Grzegorz Bizon 503f213670 Make sure that every job has a stage assigned 2017-11-06 11:04:09 +01:00
Shinya Maeda 38d9b4d77d Use script_failure. Add runner_system_failure. Improve spec. 2017-09-05 15:10:34 +09:00
Shinya Maeda 68f6c61cf6 - Allow runner API to pass failure_reason
- Fix spec
2017-09-05 14:30:28 +09:00
Shinya Maeda 1d7c039072 Fix enum lists 2017-09-05 14:30:28 +09:00
Shinya Maeda b1af1f268b Fix enum wording 2017-09-05 14:30:28 +09:00
Shinya Maeda dcf09d1144 Implement `failure_reason` on `ci_builds` 2017-09-05 14:30:28 +09:00
Grzegorz Bizon 865de49b08 Update related stage status when job status is changed 2017-07-24 11:34:01 +02:00
Grzegorz Bizon 8657d5dd8a Do not implement CI/CD job to stage association yet 2017-07-24 11:33:01 +02:00
Grzegorz Bizon c7a7ef044c Use a new stage_id reference to a persisted stage 2017-07-20 12:56:27 +02:00
Grzegorz Bizon b3ee172b4e Add a workaround for a tmp job -> stage relation
We still didn't migrate `ci_builds.stage_id`, so we can't use a
belongs_to association. We also have `ci_builds.stage` string attribute,
that we need to phase out in favor of `ci_stages.name`.
2017-07-04 16:41:33 +02:00
Z.J. van de Weg 93b555af85 Handle legacy jobs without name
Older pipelines can contain jobs without a name, in which case
'nameless' is used right now, so we can properly still handle other
actions on these jobs.

Fixes gitlab-org/gitlab-ce#33403
2017-06-13 11:19:45 +02:00
Douwe Maan 6bea29649e Merge branch 'fix/import-commit-status-issue' into 'master'
Ignore commit status name validation on importing

Closes #33490

See merge request !12039
2017-06-12 15:38:09 +00:00
Filipa Lacerda 452202e36d Improve Job detail view to make it refreshed in real-time instead of reloading 2017-06-12 09:20:19 +00:00
James Lopez eaf71fc963 ignore name validation on importing 2017-06-12 10:11:08 +02:00
Grzegorz Bizon 79380fe5fb Merge branch 'master' into feature/gb/persist-pipeline-stages
* master: (524 commits)
  Improve user experience around slash commands in instant comments
  Fix LFS timeouts when trying to save large files
  retryable? is now available for CommitStatus
  Resolve "Documentation of `.gitlab-ci.yml` states incorrect example for variables"
  Fix test failures
  Add slugify project path to CI enviroment variables
  Fixed typo: craeted -> created
  32118 Make New environment empty state btn lowercase
  Expose import_status in Projects API
  32832 Remove overflow from comment form for confidential issues and vertically aligns confidential issue icon
  Fix test failures
  Allow manual bypass of auto_sign_in_with_provider
  Fix keys seed
  Allow users to be hard-deleted from the API
  fixup some classnames and media queries
  Enable the Style/PreferredHashMethods cop
  Lint our factories creation in addition to their build
  Don’t schedule workers from inside transactions
  Allow scheduling from after_commit hooks
  Forbid Sidekiq scheduling in transactions
  ...

Conflicts:
	app/serializers/pipeline_entity.rb
	db/schema.rb
	spec/factories/ci/stages.rb
	spec/lib/gitlab/import_export/safe_model_attributes.yml
	spec/services/ci/create_pipeline_service_spec.rb
	spec/spec_helper.rb
2017-06-05 12:51:59 +02:00
Kamil Trzciński 9ccb289aa1 Merge branch 'zj-job-view-goes-real-time' into 'master'
Initial implementation for real time job view

Closes #31397

See merge request !11651
2017-06-05 10:24:57 +00:00
Z.J. van de Weg 1709e5cf87 retryable? is now available for CommitStatus 2017-06-04 12:44:00 +02:00
Douwe Maan e4eac1fff1 Don’t schedule workers from inside transactions 2017-06-02 11:43:32 -05:00
Grzegorz Bizon fe0b2f81c7 Refine implementation of pipeline stage seeds 2017-06-02 12:16:11 +02:00
Z.J. van de Weg 336635f283 Test the ExpireJobCacheWorker and related changes
These were untested by the cherry picked commit.
2017-05-22 22:07:11 +02:00
Kamil Trzcinski da0c543e28 Add MISSING e-tag refresh of resource for Job, and Pipeline Graph 2017-05-22 22:07:11 +02:00
Regis Boudinot 81df0034f4 Merge branch 'retried-in-database-mysql' into 'master'
Retried in database

Closes #25737

See merge request !11115
2017-05-10 22:07:05 +00:00
Kamil Trzcinski f09dcbd9bd
Make retried to be nullable 2017-05-09 20:09:41 +02:00
Kamil Trzcinski f2a4420d66
Store retried in database for CI builds 2017-05-07 22:43:53 +02:00