Skip to content
代码片段 群组 项目
未验证 提交 3f928ee7 编辑于 作者: Furkan Ayhan's avatar Furkan Ayhan 提交者: GitLab
浏览文件

Merge branch '513365-fix-before-sha-in-pipeline-execution-policy' into 'master'

No related branches found
No related tags found
2 合并请求!3031Merge per-main-jh to main-jh by luzhiyuan,!3030Merge per-main-jh to main-jh
...@@ -130,6 +130,8 @@ def create_pipeline(policy, partition_id) ...@@ -130,6 +130,8 @@ def create_pipeline(policy, partition_id)
::Ci::CreatePipelineService ::Ci::CreatePipelineService
.new(project, command.current_user, .new(project, command.current_user,
ref: command.ref, ref: command.ref,
before: command.before_sha,
after: command.after_sha,
source_sha: command.source_sha, source_sha: command.source_sha,
checkout_sha: command.checkout_sha, checkout_sha: command.checkout_sha,
target_sha: command.target_sha, target_sha: command.target_sha,
......
...@@ -70,6 +70,17 @@ ...@@ -70,6 +70,17 @@
end end
end end
it 'passes the right shas to the pipeline' do
perform
context.policy_pipelines.each do |policy_pipeline|
expect(policy_pipeline.pipeline.ref).to eq(pipeline.ref)
expect(policy_pipeline.pipeline.before_sha).to eq(pipeline.before_sha)
expect(policy_pipeline.pipeline.source_sha).to eq(pipeline.source_sha)
expect(policy_pipeline.pipeline.target_sha).to eq(pipeline.target_sha)
end
end
it 'propagates partition_id to policy pipelines' do it 'propagates partition_id to policy pipelines' do
perform perform
......
...@@ -315,6 +315,72 @@ ...@@ -315,6 +315,72 @@
end end
end end
context 'with jobs using rules:changes' do
let(:project_policy_content) do
{
project_policy_job: {
stage: 'test',
script: 'project script',
rules: [
{
changes: [
'development.txt'
]
}
]
}
}
end
it 'includes the job' do
builds = execute.payload.builds
expect(builds.map(&:name)).to include('project_policy_job')
end
context 'when a file is touched in a commit' do
before_all do
group.add_owner(user)
end
let(:before_sha) { project.repository.commit.sha }
let(:opts) do
{ origin_ref: project.default_branch_or_main, before_sha: before_sha, source_sha: before_sha,
target_sha: new_sha }
end
let(:new_sha) do
create_file_in_repo(
project,
project.default_branch_or_main,
project.default_branch_or_main,
touched_tile_name, 'This is a test',
commit_message: 'Touch file'
)[:result]
end
context 'when the file listed in changes is not touched' do
let(:touched_tile_name) { 'production.txt' }
it 'does not include the job' do
builds = execute.payload.builds
expect(builds.map(&:name)).not_to include('project_policy_job')
end
end
context 'when the file listed in changes is touched' do
let(:touched_tile_name) { 'development.txt' }
it 'includes the job' do
builds = execute.payload.builds
expect(builds.map(&:name)).to include('project_policy_job')
end
end
end
end
context 'when any policy contains `override_project_ci` strategy' do context 'when any policy contains `override_project_ci` strategy' do
let(:project_policy) do let(:project_policy) do
build(:pipeline_execution_policy, :override_project_ci, build(:pipeline_execution_policy, :override_project_ci,
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册