diff options
-rw-r--r-- | .gitlab-ci.yml | 39 | ||||
-rw-r--r-- | app/models/repository.rb | 2 | ||||
-rw-r--r-- | app/services/ci/pipeline_trigger_service.rb | 10 | ||||
-rw-r--r-- | doc/api/merge_requests.md | 1 | ||||
-rw-r--r-- | spec/models/repository_spec.rb | 21 |
5 files changed, 54 insertions, 19 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 16c56747711..ee9eaeae723 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -120,9 +120,8 @@ stages: variables: &single-script-job-variables GIT_STRATEGY: none before_script: - # We need to download the script rather than clone the repo since the - # package-and-qa job will not be able to run when the branch gets - # deleted (when merging the MR). + # We don't clone the repo by using GIT_STRATEGY: none and only download the + # single script we need here so it's much faster than cloning. - export SCRIPT_NAME="${SCRIPT_NAME:-$CI_JOB_NAME}" - apk add --update openssl - wget $CI_PROJECT_URL/raw/$CI_COMMIT_SHA/scripts/$SCRIPT_NAME @@ -228,20 +227,21 @@ stages: # Trigger a package build in omnibus-gitlab repository # package-and-qa: - <<: *single-script-job + image: ruby:2.5-alpine + stage: test + before_script: [] + dependencies: [] + cache: {} variables: - <<: *single-script-job-variables + GIT_DEPTH: "1" API_TOKEN: "${GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN}" - SCRIPT_NAME: trigger-build retry: 0 script: - - gem install gitlab --no-document - apk add --update openssl curl jq - - wget $CI_PROJECT_URL/raw/$CI_COMMIT_SHA/scripts/review_apps/review-apps.sh - - chmod 755 review-apps.sh - - source ./review-apps.sh + - gem install gitlab --no-document + - source ./scripts/review_apps/review-apps.sh - wait_for_job_to_be_done "gitlab:assets:compile" - - ./$SCRIPT_NAME omnibus + - ./scripts/trigger-build omnibus when: manual only: - //@gitlab-org/gitlab-ce @@ -951,20 +951,21 @@ no_ee_check: # GitLab Review apps review-build-cng: - <<: *single-script-job <<: *review-only + image: ruby:2.5-alpine + stage: test + before_script: [] + dependencies: [] + cache: {} variables: - <<: *single-script-job-variables - SCRIPT_NAME: trigger-build + GIT_DEPTH: "1" API_TOKEN: "${GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN}" script: - - gem install gitlab --no-document - apk add --update openssl curl jq - - wget $CI_PROJECT_URL/raw/$CI_COMMIT_SHA/scripts/review_apps/review-apps.sh - - chmod 755 review-apps.sh - - source ./review-apps.sh + - gem install gitlab --no-document + - source ./scripts/review_apps/review-apps.sh - wait_for_job_to_be_done "gitlab:assets:compile" - - BUILD_TRIGGER_TOKEN=$REVIEW_APPS_BUILD_TRIGGER_TOKEN ./$SCRIPT_NAME cng + - BUILD_TRIGGER_TOKEN=$REVIEW_APPS_BUILD_TRIGGER_TOKEN ./scripts/trigger-build cng review-deploy: <<: *review-base diff --git a/app/models/repository.rb b/app/models/repository.rb index b47238b52f1..e6ab3b484a2 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -525,6 +525,8 @@ class Repository # items is an Array like: [[oid, path], [oid1, path1]] def blobs_at(items) + return [] unless exists? + raw_repository.batch_blobs(items).map { |blob| Blob.decorate(blob, project) } end diff --git a/app/services/ci/pipeline_trigger_service.rb b/app/services/ci/pipeline_trigger_service.rb index f54574b026b..4ba3f5fb8ba 100644 --- a/app/services/ci/pipeline_trigger_service.rb +++ b/app/services/ci/pipeline_trigger_service.rb @@ -7,6 +7,8 @@ module Ci def execute if trigger_from_token create_pipeline_from_trigger(trigger_from_token) + elsif job_from_token + create_pipeline_from_job(job_from_token) end end @@ -35,6 +37,14 @@ module Ci end end + def create_pipeline_from_job(job) + # overriden in EE + end + + def job_from_token + # overriden in EE + end + def variables params[:variables].to_h.map do |key, value| { key: key, value: value } diff --git a/doc/api/merge_requests.md b/doc/api/merge_requests.md index c9b271eada3..b3548391228 100644 --- a/doc/api/merge_requests.md +++ b/doc/api/merge_requests.md @@ -182,6 +182,7 @@ Parameters: | `source_branch` | string | no | Return merge requests with the given source branch | | `target_branch` | string | no | Return merge requests with the given target branch | | `search` | string | no | Search merge requests against their `title` and `description` | +| `wip` | string | no | Filter merge requests against their `wip` status. `yes` to return *only* WIP merge requests, `no` to return *non* WIP merge requests | ```json [ diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index ac5874fd0f7..4978c43c9b5 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1237,6 +1237,27 @@ describe Repository do end end + describe '#blobs_at' do + let(:empty_repository) { create(:project_empty_repo).repository } + + it 'returns empty array for an empty repository' do + # rubocop:disable Style/WordArray + expect(empty_repository.blobs_at(['master', 'foobar'])).to eq([]) + # rubocop:enable Style/WordArray + end + + it 'returns blob array for a non-empty repository' do + repository.create_file(User.last, 'foobar', 'CONTENT', message: 'message', branch_name: 'master') + + # rubocop:disable Style/WordArray + blobs = repository.blobs_at([['master', 'foobar']]) + # rubocop:enable Style/WordArray + + expect(blobs.first.name).to eq('foobar') + expect(blobs.size).to eq(1) + end + end + describe '#root_ref' do it 'returns a branch name' do expect(repository.root_ref).to be_an_instance_of(String) |