diff options
author | Robert Speicher <rspeicher@gmail.com> | 2019-06-19 13:43:39 -0500 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2019-06-19 13:43:39 -0500 |
commit | 29c0bd7e2b0c46e94eb8c455c2c8212768c65a9d (patch) | |
tree | b46483d8d9c81679cb34737395430f71d6749bc3 | |
parent | f41d39f97288d17e0d88a60e61c1b046bd12aa66 (diff) | |
parent | 2fd3f055115b5fb81520599054e160b3485d8554 (diff) | |
download | gitlab-ce-29c0bd7e2b0c46e94eb8c455c2c8212768c65a9d.tar.gz |
Merge branch '12-1-auto-deploy-0010836' into 12-0-stable
-rw-r--r-- | GITALY_SERVER_VERSION | 2 | ||||
-rw-r--r-- | app/assets/javascripts/ide/services/index.js | 8 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/modules/commit/actions.js | 1 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/utils.js | 11 | ||||
-rw-r--r-- | app/services/ci/pipeline_schedule_service.rb | 13 | ||||
-rw-r--r-- | changelogs/unreleased/59023-fix-web-ide-creating-branches-off-new-commits.yml | 5 | ||||
-rw-r--r-- | changelogs/unreleased/gitaly-version-v1.47.0.yml | 5 | ||||
-rw-r--r-- | changelogs/unreleased/revert-concurrent-pipeline-schedule-creation.yml | 5 | ||||
-rw-r--r-- | db/migrate/20190521174505_add_report_type_to_approval_merge_request_rules.rb | 13 | ||||
-rw-r--r-- | db/schema.rb | 1 | ||||
-rw-r--r-- | doc/user/project/pipelines/settings.md | 3 | ||||
-rw-r--r-- | spec/frontend/ide/services/index_spec.js | 55 | ||||
-rw-r--r-- | spec/javascripts/ide/stores/modules/commit/actions_spec.js | 18 | ||||
-rw-r--r-- | spec/javascripts/ide/stores/utils_spec.js | 4 | ||||
-rw-r--r-- | spec/services/ci/pipeline_schedule_service_spec.rb | 32 |
15 files changed, 163 insertions, 13 deletions
diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index 0a3db35b241..21998d3c2d9 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -1.46.0 +1.47.0 diff --git a/app/assets/javascripts/ide/services/index.js b/app/assets/javascripts/ide/services/index.js index ba33b6826d6..840761f68db 100644 --- a/app/assets/javascripts/ide/services/index.js +++ b/app/assets/javascripts/ide/services/index.js @@ -56,7 +56,13 @@ export default { return Api.branchSingle(projectId, currentBranchId); }, commit(projectId, payload) { - return Api.commitMultiple(projectId, payload); + // Currently the `commit` endpoint does not support `start_sha` so we + // have to make the request in the FE. This is not ideal and will be + // resolved soon. https://gitlab.com/gitlab-org/gitlab-ce/issues/59023 + const { branch, start_sha: ref } = payload; + const branchPromise = ref ? Api.createBranch(projectId, { ref, branch }) : Promise.resolve(); + + return branchPromise.then(() => Api.commitMultiple(projectId, payload)); }, getFiles(projectUrl, branchId) { const url = `${projectUrl}/files/${branchId}`; diff --git a/app/assets/javascripts/ide/stores/modules/commit/actions.js b/app/assets/javascripts/ide/stores/modules/commit/actions.js index 51062f092ad..ff1255ce749 100644 --- a/app/assets/javascripts/ide/stores/modules/commit/actions.js +++ b/app/assets/javascripts/ide/stores/modules/commit/actions.js @@ -142,6 +142,7 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo getters, state, rootState, + rootGetters, }); return service.commit(rootState.currentProjectId, payload); diff --git a/app/assets/javascripts/ide/stores/utils.js b/app/assets/javascripts/ide/stores/utils.js index bcc9ca60d9b..4e7a8765abe 100644 --- a/app/assets/javascripts/ide/stores/utils.js +++ b/app/assets/javascripts/ide/stores/utils.js @@ -135,7 +135,14 @@ export const getCommitFiles = stagedFiles => }); }, []); -export const createCommitPayload = ({ branch, getters, newBranch, state, rootState }) => ({ +export const createCommitPayload = ({ + branch, + getters, + newBranch, + state, + rootState, + rootGetters, +}) => ({ branch, commit_message: state.commitMessage || getters.preBuiltCommitMessage, actions: getCommitFiles(rootState.stagedFiles).map(f => ({ @@ -146,7 +153,7 @@ export const createCommitPayload = ({ branch, getters, newBranch, state, rootSta encoding: f.base64 ? 'base64' : 'text', last_commit_id: newBranch || f.deleted || f.prevPath ? undefined : f.lastCommitSha, })), - start_branch: newBranch ? rootState.currentBranchId : undefined, + start_sha: newBranch ? rootGetters.lastCommit.short_id : undefined, }); export const createNewMergeRequestUrl = (projectUrl, source, target) => diff --git a/app/services/ci/pipeline_schedule_service.rb b/app/services/ci/pipeline_schedule_service.rb index 5b5e9a26520..ef90d91c936 100644 --- a/app/services/ci/pipeline_schedule_service.rb +++ b/app/services/ci/pipeline_schedule_service.rb @@ -7,7 +7,18 @@ module Ci # Otherwise, multiple pipelines could be created in a short interval. schedule.schedule_next_run! - RunPipelineScheduleWorker.perform_async(schedule.id, schedule.owner&.id) + if Feature.enabled?(:ci_pipeline_schedule_async) + RunPipelineScheduleWorker.perform_async(schedule.id, schedule.owner&.id) + else + begin + RunPipelineScheduleWorker.new.perform(schedule.id, schedule.owner&.id) + ensure + ## + # This is the temporary solution for avoiding the memory bloat. + # See more https://gitlab.com/gitlab-org/gitlab-ce/issues/61955 + GC.start if Feature.enabled?(:ci_pipeline_schedule_force_gc, default_enabled: true) + end + end end end end diff --git a/changelogs/unreleased/59023-fix-web-ide-creating-branches-off-new-commits.yml b/changelogs/unreleased/59023-fix-web-ide-creating-branches-off-new-commits.yml new file mode 100644 index 00000000000..f7e0ee333aa --- /dev/null +++ b/changelogs/unreleased/59023-fix-web-ide-creating-branches-off-new-commits.yml @@ -0,0 +1,5 @@ +--- +title: Fix IDE commit using latest ref in branch and overriding contents +merge_request: 29769 +author: +type: fixed diff --git a/changelogs/unreleased/gitaly-version-v1.47.0.yml b/changelogs/unreleased/gitaly-version-v1.47.0.yml new file mode 100644 index 00000000000..b369506b336 --- /dev/null +++ b/changelogs/unreleased/gitaly-version-v1.47.0.yml @@ -0,0 +1,5 @@ +--- +title: Upgrade to Gitaly v1.47.0 +merge_request: 29789 +author: +type: changed diff --git a/changelogs/unreleased/revert-concurrent-pipeline-schedule-creation.yml b/changelogs/unreleased/revert-concurrent-pipeline-schedule-creation.yml new file mode 100644 index 00000000000..77423463d22 --- /dev/null +++ b/changelogs/unreleased/revert-concurrent-pipeline-schedule-creation.yml @@ -0,0 +1,5 @@ +--- +title: Revert concurrent pipeline creation for pipeline schedules +merge_request: 29794 +author: +type: fixed diff --git a/db/migrate/20190521174505_add_report_type_to_approval_merge_request_rules.rb b/db/migrate/20190521174505_add_report_type_to_approval_merge_request_rules.rb new file mode 100644 index 00000000000..eafffd4f5a3 --- /dev/null +++ b/db/migrate/20190521174505_add_report_type_to_approval_merge_request_rules.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AddReportTypeToApprovalMergeRequestRules < ActiveRecord::Migration[5.1] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + change_table :approval_merge_request_rules do |t| + t.integer :report_type, limit: 2 + end + end +end diff --git a/db/schema.rb b/db/schema.rb index b003fdd5a9b..0261767d152 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -248,6 +248,7 @@ ActiveRecord::Schema.define(version: 20190613030606) do t.boolean "code_owner", default: false, null: false t.string "name", null: false t.integer "rule_type", limit: 2, default: 1, null: false + t.integer "report_type", limit: 2 t.index ["merge_request_id", "code_owner", "name"], name: "approval_rule_name_index_for_code_owners", unique: true, where: "(code_owner = true)", using: :btree t.index ["merge_request_id", "code_owner"], name: "index_approval_merge_request_rules_1", using: :btree t.index ["merge_request_id", "rule_type", "name"], name: "index_approval_rule_name_for_code_owners_rule_type", unique: true, where: "(rule_type = 2)", using: :btree diff --git a/doc/user/project/pipelines/settings.md b/doc/user/project/pipelines/settings.md index 16f48c462eb..24e15a37a40 100644 --- a/doc/user/project/pipelines/settings.md +++ b/doc/user/project/pipelines/settings.md @@ -24,7 +24,8 @@ in `.gitlab-ci.yml`. > [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/28919) in GitLab 12.0. -NOTE: **Note**: As of GitLab 12.0, newly created projects will automaticallyl have a default +NOTE: **Note**: +As of GitLab 12.0, newly created projects will automatically have a default `git depth` value of `50`. It is possible to limit the number of changes that GitLab CI/CD will fetch when cloning diff --git a/spec/frontend/ide/services/index_spec.js b/spec/frontend/ide/services/index_spec.js new file mode 100644 index 00000000000..499fa8fc012 --- /dev/null +++ b/spec/frontend/ide/services/index_spec.js @@ -0,0 +1,55 @@ +import services from '~/ide/services'; +import Api from '~/api'; + +jest.mock('~/api'); + +const TEST_PROJECT_ID = 'alice/wonderland'; +const TEST_BRANCH = 'master-patch-123'; +const TEST_COMMIT_SHA = '123456789'; + +describe('IDE services', () => { + describe('commit', () => { + let payload; + + beforeEach(() => { + payload = { + branch: TEST_BRANCH, + commit_message: 'Hello world', + actions: [], + start_sha: undefined, + }; + + Api.createBranch.mockReturnValue(Promise.resolve()); + Api.commitMultiple.mockReturnValue(Promise.resolve()); + }); + + describe.each` + startSha | shouldCreateBranch + ${undefined} | ${false} + ${TEST_COMMIT_SHA} | ${true} + `('when start_sha is $startSha', ({ startSha, shouldCreateBranch }) => { + beforeEach(() => { + payload.start_sha = startSha; + + return services.commit(TEST_PROJECT_ID, payload); + }); + + if (shouldCreateBranch) { + it('should create branch', () => { + expect(Api.createBranch).toHaveBeenCalledWith(TEST_PROJECT_ID, { + ref: TEST_COMMIT_SHA, + branch: TEST_BRANCH, + }); + }); + } else { + it('should not create branch', () => { + expect(Api.createBranch).not.toHaveBeenCalled(); + }); + } + + it('should commit', () => { + expect(Api.commitMultiple).toHaveBeenCalledWith(TEST_PROJECT_ID, payload); + }); + }); + }); +}); diff --git a/spec/javascripts/ide/stores/modules/commit/actions_spec.js b/spec/javascripts/ide/stores/modules/commit/actions_spec.js index 5f7272311c8..8a3c132972e 100644 --- a/spec/javascripts/ide/stores/modules/commit/actions_spec.js +++ b/spec/javascripts/ide/stores/modules/commit/actions_spec.js @@ -6,9 +6,11 @@ import eventHub from '~/ide/eventhub'; import consts from '~/ide/stores/modules/commit/constants'; import * as mutationTypes from '~/ide/stores/modules/commit/mutation_types'; import * as actions from '~/ide/stores/modules/commit/actions'; -import testAction from '../../../../helpers/vuex_action_helper'; import { commitActionTypes } from '~/ide/constants'; import { resetStore, file } from 'spec/ide/helpers'; +import testAction from '../../../../helpers/vuex_action_helper'; + +const TEST_COMMIT_SHA = '123456789'; describe('IDE commit module actions', () => { beforeEach(() => { @@ -139,6 +141,9 @@ describe('IDE commit module actions', () => { branches: { master: { workingReference: '', + commit: { + short_id: TEST_COMMIT_SHA, + }, }, }, }; @@ -239,6 +244,9 @@ describe('IDE commit module actions', () => { branches: { master: { workingReference: '1', + commit: { + short_id: TEST_COMMIT_SHA, + }, }, }, }; @@ -247,7 +255,7 @@ describe('IDE commit module actions', () => { ...file('changed'), type: 'blob', active: true, - lastCommitSha: '123456789', + lastCommitSha: TEST_COMMIT_SHA, }; store.state.stagedFiles.push(f); store.state.changedFiles = [ @@ -307,7 +315,7 @@ describe('IDE commit module actions', () => { previous_path: undefined, }, ], - start_branch: 'master', + start_sha: TEST_COMMIT_SHA, }); done(); @@ -330,11 +338,11 @@ describe('IDE commit module actions', () => { file_path: jasmine.anything(), content: undefined, encoding: jasmine.anything(), - last_commit_id: '123456789', + last_commit_id: TEST_COMMIT_SHA, previous_path: undefined, }, ], - start_branch: undefined, + start_sha: undefined, }); done(); diff --git a/spec/javascripts/ide/stores/utils_spec.js b/spec/javascripts/ide/stores/utils_spec.js index debe1c4acee..e3bf6d40245 100644 --- a/spec/javascripts/ide/stores/utils_spec.js +++ b/spec/javascripts/ide/stores/utils_spec.js @@ -132,7 +132,7 @@ describe('Multi-file store utils', () => { previous_path: undefined, }, ], - start_branch: undefined, + start_sha: undefined, }); }); @@ -187,7 +187,7 @@ describe('Multi-file store utils', () => { previous_path: undefined, }, ], - start_branch: undefined, + start_sha: undefined, }); }); }); diff --git a/spec/services/ci/pipeline_schedule_service_spec.rb b/spec/services/ci/pipeline_schedule_service_spec.rb index 867ed0acc0d..f7590720f66 100644 --- a/spec/services/ci/pipeline_schedule_service_spec.rb +++ b/spec/services/ci/pipeline_schedule_service_spec.rb @@ -25,6 +25,38 @@ describe Ci::PipelineScheduleService do subject end + context 'when ci_pipeline_schedule_async feature flag is disabled' do + before do + stub_feature_flags(ci_pipeline_schedule_async: false) + end + + it 'runs RunPipelineScheduleWorker synchronously' do + expect_next_instance_of(RunPipelineScheduleWorker) do |worker| + expect(worker).to receive(:perform).with(schedule.id, schedule.owner.id) + end + + subject + end + + it 'calls Garbage Collection manually' do + expect(GC).to receive(:start) + + subject + end + + context 'when ci_pipeline_schedule_force_gc feature flag is disabled' do + before do + stub_feature_flags(ci_pipeline_schedule_force_gc: false) + end + + it 'does not call Garbage Collection manually' do + expect(GC).not_to receive(:start) + + subject + end + end + end + context 'when owner is nil' do let(:schedule) { create(:ci_pipeline_schedule, project: project, owner: nil) } |