diff options
author | Sean McGivern <sean@gitlab.com> | 2019-04-05 10:18:10 +0000 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2019-04-15 12:47:35 +0200 |
commit | 026896cca27ac63795bf1d0e606f6813500d9475 (patch) | |
tree | 037d47e705869ec6baee2d6b0618f0c0c70aad08 /lib | |
parent | c32b2d3d2b7d4e2ce8b58eee12b31f1f907e57ed (diff) | |
download | gitlab-ce-026896cca27ac63795bf1d0e606f6813500d9475.tar.gz |
Merge branch 'require-all-templates-to-include-default-stages' into 'master'
Require all templates to use default stages
Closes #59992
See merge request gitlab-org/gitlab-ce!26954
(cherry picked from commit 39eb16aab2dbac3347f61f83fb60f5448d44e965)
e0df05cf Require all templates to use default stages
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/ci/config.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/ci/config/external/file/local.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml | 1 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/Android.gitlab-ci.yml | 4 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml | 1 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/Chef.gitlab-ci.yml | 6 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/Go.gitlab-ci.yml | 1 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/Mono.gitlab-ci.yml | 1 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/OpenShift.gitlab-ci.yml | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/Packer.gitlab-ci.yml | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/Serverless.gitlab-ci.yml | 1 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/Swift.gitlab-ci.yml | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/Terraform.gitlab-ci.yml | 1 | ||||
-rw-r--r-- | lib/gitlab/ci/templates/iOS-Fastlane.gitlab-ci.yml | 2 | ||||
-rw-r--r-- | lib/gitlab/template/base_template.rb | 6 |
15 files changed, 29 insertions, 13 deletions
diff --git a/lib/gitlab/ci/config.rb b/lib/gitlab/ci/config.rb index 15643fa03ac..f187e456993 100644 --- a/lib/gitlab/ci/config.rb +++ b/lib/gitlab/ci/config.rb @@ -73,17 +73,13 @@ module Gitlab def build_config(config, project:, sha:, user:) initial_config = Gitlab::Config::Loader::Yaml.new(config).load! - if project - process_external_files(initial_config, project: project, sha: sha, user: user) - else - initial_config - end + process_external_files(initial_config, project: project, sha: sha, user: user) end def process_external_files(config, project:, sha:, user:) Config::External::Processor.new(config, project: project, - sha: sha || project.repository.root_ref_sha, + sha: sha || project&.repository&.root_ref_sha, user: user, expandset: Set.new).perform end diff --git a/lib/gitlab/ci/config/external/file/local.rb b/lib/gitlab/ci/config/external/file/local.rb index 229a06451e8..cac321ec4a6 100644 --- a/lib/gitlab/ci/config/external/file/local.rb +++ b/lib/gitlab/ci/config/external/file/local.rb @@ -21,7 +21,9 @@ module Gitlab private def validate_content! - if content.nil? + if context.project&.repository.nil? + errors.push("Local file `#{location}` does not have project!") + elsif content.nil? errors.push("Local file `#{location}` does not exist!") elsif content.blank? errors.push("Local file `#{location}` is empty!") diff --git a/lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml b/lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml index 8e767b22360..120272200c6 100644 --- a/lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Android-Fastlane.gitlab-ci.yml @@ -6,6 +6,7 @@ stages: - environment - build - test + - deploy - internal - alpha - beta diff --git a/lib/gitlab/ci/templates/Android.gitlab-ci.yml b/lib/gitlab/ci/templates/Android.gitlab-ci.yml index c169e3f7686..2be7f933462 100644 --- a/lib/gitlab/ci/templates/Android.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Android.gitlab-ci.yml @@ -24,10 +24,6 @@ before_script: - yes | android-sdk-linux/tools/bin/sdkmanager --licenses - set -o pipefail -stages: - - build - - test - lintDebug: stage: build script: diff --git a/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml b/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml index b3eec2b6210..939112e6e41 100644 --- a/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml @@ -60,6 +60,7 @@ variables: stages: - build - test + - deploy # dummy stage to follow the template guidelines - review - dast - staging diff --git a/lib/gitlab/ci/templates/Chef.gitlab-ci.yml b/lib/gitlab/ci/templates/Chef.gitlab-ci.yml index 33507aa58e4..1e14aa8bea9 100644 --- a/lib/gitlab/ci/templates/Chef.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Chef.gitlab-ci.yml @@ -14,9 +14,11 @@ variables: KITCHEN_LOCAL_YAML: ".kitchen.dokken.yml" stages: + - build - lint - - unit + - test - functional + - deploy foodcritic: stage: lint @@ -29,7 +31,7 @@ cookstyle: - chef exec cookstyle . chefspec: - stage: unit + stage: test script: - chef exec rspec spec diff --git a/lib/gitlab/ci/templates/Go.gitlab-ci.yml b/lib/gitlab/ci/templates/Go.gitlab-ci.yml index d572d7a1edc..55fda1a4799 100644 --- a/lib/gitlab/ci/templates/Go.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Go.gitlab-ci.yml @@ -18,6 +18,7 @@ before_script: stages: - test - build + - deploy format: stage: test diff --git a/lib/gitlab/ci/templates/Mono.gitlab-ci.yml b/lib/gitlab/ci/templates/Mono.gitlab-ci.yml index 86d62b93313..10fb6be6c39 100644 --- a/lib/gitlab/ci/templates/Mono.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Mono.gitlab-ci.yml @@ -15,6 +15,7 @@ image: mono:latest stages: + - build - test - deploy diff --git a/lib/gitlab/ci/templates/OpenShift.gitlab-ci.yml b/lib/gitlab/ci/templates/OpenShift.gitlab-ci.yml index 290b9997084..61a925e0d2d 100644 --- a/lib/gitlab/ci/templates/OpenShift.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/OpenShift.gitlab-ci.yml @@ -1,7 +1,9 @@ image: ayufan/openshift-cli stages: + - build # dummy stage to follow the template guidelines - test + - deploy # dummy stage to follow the template guidelines - review - staging - production diff --git a/lib/gitlab/ci/templates/Packer.gitlab-ci.yml b/lib/gitlab/ci/templates/Packer.gitlab-ci.yml index fa296057c72..83e179f37c3 100644 --- a/lib/gitlab/ci/templates/Packer.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Packer.gitlab-ci.yml @@ -9,6 +9,8 @@ before_script: stages: - validate + - build + - test - deploy validate: diff --git a/lib/gitlab/ci/templates/Serverless.gitlab-ci.yml b/lib/gitlab/ci/templates/Serverless.gitlab-ci.yml index 4c92dcb7941..0fb7c57ab72 100644 --- a/lib/gitlab/ci/templates/Serverless.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Serverless.gitlab-ci.yml @@ -4,6 +4,7 @@ image: alpine:latest stages: - build + - test - deploy .serverless:build:image: diff --git a/lib/gitlab/ci/templates/Swift.gitlab-ci.yml b/lib/gitlab/ci/templates/Swift.gitlab-ci.yml index ba8a802ba4f..9aa4abd4791 100644 --- a/lib/gitlab/ci/templates/Swift.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Swift.gitlab-ci.yml @@ -2,7 +2,9 @@ # This file assumes an own GitLab CI runner, setup on a macOS system. stages: - build + - test - archive + - deploy build_project: stage: build diff --git a/lib/gitlab/ci/templates/Terraform.gitlab-ci.yml b/lib/gitlab/ci/templates/Terraform.gitlab-ci.yml index 7160fce26a8..f374bc7e26a 100644 --- a/lib/gitlab/ci/templates/Terraform.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Terraform.gitlab-ci.yml @@ -24,6 +24,7 @@ before_script: stages: - validate - build + - test - deploy validate: diff --git a/lib/gitlab/ci/templates/iOS-Fastlane.gitlab-ci.yml b/lib/gitlab/ci/templates/iOS-Fastlane.gitlab-ci.yml index df6ac4d340d..a4a9e96c1d2 100644 --- a/lib/gitlab/ci/templates/iOS-Fastlane.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/iOS-Fastlane.gitlab-ci.yml @@ -12,6 +12,8 @@ stages: - build + - test + - deploy variables: LC_ALL: "en_US.UTF-8" diff --git a/lib/gitlab/template/base_template.rb b/lib/gitlab/template/base_template.rb index 0b4cc571dc0..14c9a3e0389 100644 --- a/lib/gitlab/template/base_template.rb +++ b/lib/gitlab/template/base_template.rb @@ -16,6 +16,12 @@ module Gitlab end alias_method :key, :name + def full_name + Pathname.new(@path) + .relative_path_from(self.class.base_dir) + .to_s + end + def content @finder.read(@path) end |