Commit 9b093011 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'fix-ci-gitlab-and-foss-projects-detection' into 'master'

Fix CI detection of GitLab and GitLab FOSS projects

See merge request gitlab-org/gitlab!17490
parents 6c299a2f 6c9d848d
......@@ -126,3 +126,4 @@
only:
variables:
- $CI_PROJECT_NAME == "gitlab"
- $CI_PROJECT_NAME == "gitlab-ee" # Support former project name for forks/mirrors
......@@ -43,5 +43,6 @@ no_ee_check:
- scripts/no-ee-check
only:
variables:
- $CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAME == "gitlab-foss"
- $CI_SERVER_HOST == "dev.gitlab.org" && $CI_PROJECT_NAME == "gitlabhq"
- $CI_PROJECT_NAME == "gitlab-foss"
- $CI_PROJECT_NAME == "gitlab-ce" # Support former project name for forks/mirrors
- $CI_PROJECT_NAME == "gitlabhq" # Support former project name for dev
......@@ -35,7 +35,8 @@ module Gitlab
end
def ee?
ENV['CI_PROJECT_NAME'] == 'gitlab' || File.exist?('../../CHANGELOG-EE.md')
# Support former project name for `dev` and support local Danger run
%w[gitlab gitlab-ee].include?(ENV['CI_PROJECT_NAME']) || Dir.exist?('../../ee')
end
def gitlab_helper
......
......@@ -18,7 +18,8 @@ class AutomatedCleanup
].freeze
def self.ee?
ENV['CI_PROJECT_NAME'] == 'gitlab-ee' || File.exist?('CHANGELOG-EE.md')
# Support former project name for `dev`
%w[gitlab gitlab-ee].include?(ENV['CI_PROJECT_NAME'])
end
def initialize(project_path: ENV['CI_PROJECT_PATH'], gitlab_token: ENV['GITLAB_BOT_REVIEW_APPS_CLEANUP_TOKEN'])
......
......@@ -12,7 +12,8 @@ end
module Trigger
def self.ee?
ENV['CI_PROJECT_NAME'] == 'gitlab-ee' || File.exist?('CHANGELOG-EE.md')
# Support former project name for `dev`
%w[gitlab gitlab-ee].include?(ENV['CI_PROJECT_NAME'])
end
class Base
......
......@@ -88,28 +88,28 @@ describe Gitlab::Danger::Helper do
it 'returns true if CI_PROJECT_NAME if set to gitlab' do
stub_env('CI_PROJECT_NAME', 'gitlab')
expect(File).not_to receive(:exist?)
expect(Dir).not_to receive(:exist?)
is_expected.to be_truthy
end
it 'delegates to CHANGELOG-EE.md existence if CI_PROJECT_NAME is set to something else' do
stub_env('CI_PROJECT_NAME', 'something else')
expect(File).to receive(:exist?).with('../../CHANGELOG-EE.md') { true }
expect(Dir).to receive(:exist?).with('../../ee') { true }
is_expected.to be_truthy
end
it 'returns true if CHANGELOG-EE.md exists' do
it 'returns true if ee exists' do
stub_env('CI_PROJECT_NAME', nil)
expect(File).to receive(:exist?).with('../../CHANGELOG-EE.md') { true }
expect(Dir).to receive(:exist?).with('../../ee') { true }
is_expected.to be_truthy
end
it "returns false if CHANGELOG-EE.md doesn't exist" do
it "returns false if ee doesn't exist" do
stub_env('CI_PROJECT_NAME', nil)
expect(File).to receive(:exist?).with('../../CHANGELOG-EE.md') { false }
expect(Dir).to receive(:exist?).with('../../ee') { false }
is_expected.to be_falsy
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment