diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-03-14 23:06:50 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-03-14 23:06:50 +0300 |
commit | ca3fc2296f13f8dc7c89c4361b448ed46708cab7 (patch) | |
tree | 4c6c2a0f4b23869bce0ef8ea7926504a728a3ee7 /spec | |
parent | 29b186e49d6873f6e5173e940436fc35737ce4c0 (diff) | |
parent | 7ebb932070f03e8fb6116b9f54148cae2d782776 (diff) |
Merge branch 'gitlab-ci-yaml-updates' into 'master'
New CI YAML features
This introduces a couple of small `.gitlab-ci.yml` features:
1. Documentation for: Allow to use YAML anchors when parsing the `.gitlab-ci.yml`: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/2958
2. Ignore jobs that start with `.`
3. Allow to pass name of created artifacts archive in `.gitlab-ci.yml`
4. Allow to define on which builds the current one depends on
These are really small changes so it makes not sense to create a separate merge requests for them.
@axil Could you review the documentation part?
The implementation on GitLab Runner side: https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/merge_requests/113.
Fixes: https://gitlab.com/gitlab-org/gitlab-ce/issues/13755 https://gitlab.com/gitlab-org/gitlab-ce/issues/14211 https://gitlab.com/gitlab-org/gitlab-ce/issues/3423
cc @grzesiek @axil @DouweM
See merge request !3182
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 84 |
1 files changed, 83 insertions, 1 deletions
diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index 1e98280d045..fab6412d29f 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -397,7 +397,7 @@ module Ci services: ["mysql"], before_script: ["pwd"], rspec: { - artifacts: { paths: ["logs/", "binaries/"], untracked: true }, + artifacts: { paths: ["logs/", "binaries/"], untracked: true, name: "custom_name" }, script: "rspec" } }) @@ -417,6 +417,7 @@ module Ci image: "ruby:2.1", services: ["mysql"], artifacts: { + name: "custom_name", paths: ["logs/", "binaries/"], untracked: true } @@ -427,6 +428,73 @@ module Ci end end + describe "Dependencies" do + let(:config) do + { + build1: { stage: 'build', script: 'test' }, + build2: { stage: 'build', script: 'test' }, + test1: { stage: 'test', script: 'test', dependencies: dependencies }, + test2: { stage: 'test', script: 'test' }, + deploy: { stage: 'test', script: 'test' } + } + end + + subject { GitlabCiYamlProcessor.new(YAML.dump(config)) } + + context 'no dependencies' do + let(:dependencies) { } + + it { expect { subject }.to_not raise_error } + end + + context 'dependencies to builds' do + let(:dependencies) { [:build1, :build2] } + + it { expect { subject }.to_not raise_error } + end + + context 'undefined dependency' do + let(:dependencies) { [:undefined] } + + it { expect { subject }.to raise_error(GitlabCiYamlProcessor::ValidationError, 'test1 job: undefined dependency: undefined') } + end + + context 'dependencies to deploy' do + let(:dependencies) { [:deploy] } + + it { expect { subject }.to raise_error(GitlabCiYamlProcessor::ValidationError, 'test1 job: dependency deploy is not defined in prior stages') } + end + end + + describe "Hidden jobs" do + let(:config) do + YAML.dump({ + '.hidden_job' => { script: 'test' }, + 'normal_job' => { script: 'test' } + }) + end + + let(:config_processor) { GitlabCiYamlProcessor.new(config) } + + subject { config_processor.builds_for_stage_and_ref("test", "master") } + + it "doesn't create jobs that starts with dot" do + expect(subject.size).to eq(1) + expect(subject.first).to eq({ + except: nil, + stage: "test", + stage_idx: 1, + name: :normal_job, + only: nil, + commands: "\ntest", + tag_list: [], + options: {}, + when: "on_success", + allow_failure: false + }) + end + end + describe "YAML Alias/Anchor" do it "is correctly supported for jobs" do config = <<EOT @@ -629,6 +697,13 @@ EOT end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: when parameter should be on_success, on_failure or always") end + it "returns errors if job artifacts:name is not an a string" do + config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", artifacts: { name: 1 } } }) + expect do + GitlabCiYamlProcessor.new(config) + end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: artifacts:name parameter should be a string") + end + it "returns errors if job artifacts:untracked is not an array of strings" do config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", artifacts: { untracked: "string" } } }) expect do @@ -684,6 +759,13 @@ EOT GitlabCiYamlProcessor.new(config) end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: cache:paths parameter should be an array of strings") end + + it "returns errors if job dependencies is not an array of strings" do + config = YAML.dump({ types: ["build", "test"], rspec: { script: "test", dependencies: "string" } }) + expect do + GitlabCiYamlProcessor.new(config) + end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: dependencies parameter should be an array of strings") + end end end end |