Commit b1f50a52 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'id-fix-code-nav-link' into 'master'

Fetch last LSIF artifact for code-nav path

See merge request gitlab-org/gitlab!31958
parents d3846406 cb2750b2
...@@ -33,7 +33,6 @@ module Ci ...@@ -33,7 +33,6 @@ module Ci
scheduler_failure: 2 scheduler_failure: 2
}.freeze }.freeze
CODE_NAVIGATION_JOB_NAME = 'code_navigation'
DEGRADATION_THRESHOLD_VARIABLE_NAME = 'DEGRADATION_THRESHOLD' DEGRADATION_THRESHOLD_VARIABLE_NAME = 'DEGRADATION_THRESHOLD'
has_one :deployment, as: :deployable, class_name: 'Deployment' has_one :deployment, as: :deployable, class_name: 'Deployment'
......
...@@ -5,7 +5,6 @@ module Gitlab ...@@ -5,7 +5,6 @@ module Gitlab
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
include Gitlab::Routing include Gitlab::Routing
CODE_NAVIGATION_JOB_NAME = 'code_navigation'
LATEST_COMMITS_LIMIT = 10 LATEST_COMMITS_LIMIT = 10
def initialize(project, commit_sha) def initialize(project, commit_sha)
...@@ -17,7 +16,7 @@ module Gitlab ...@@ -17,7 +16,7 @@ module Gitlab
return if Feature.disabled?(:code_navigation, project) return if Feature.disabled?(:code_navigation, project)
return unless build return unless build
raw_project_job_artifacts_path(project, build, path: "lsif/#{path}.json") raw_project_job_artifacts_path(project, build, path: "lsif/#{path}.json", file_type: :lsif)
end end
private private
...@@ -29,10 +28,11 @@ module Gitlab ...@@ -29,10 +28,11 @@ module Gitlab
latest_commits_shas = latest_commits_shas =
project.repository.commits(commit_sha, limit: LATEST_COMMITS_LIMIT).map(&:sha) project.repository.commits(commit_sha, limit: LATEST_COMMITS_LIMIT).map(&:sha)
artifact = ::Ci::JobArtifact artifact =
.for_sha(latest_commits_shas, project.id) ::Ci::JobArtifact
.for_job_name(CODE_NAVIGATION_JOB_NAME) .with_file_types(['lsif'])
.last .for_sha(latest_commits_shas, project.id)
.last
artifact&.job artifact&.job
end end
......
...@@ -6,9 +6,8 @@ describe Gitlab::CodeNavigationPath do ...@@ -6,9 +6,8 @@ describe Gitlab::CodeNavigationPath do
context 'when there is an artifact with code navigation data' do context 'when there is an artifact with code navigation data' do
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let_it_be(:sha) { project.repository.commits('master', limit: 5).last.id } let_it_be(:sha) { project.repository.commits('master', limit: 5).last.id }
let_it_be(:build_name) { Gitlab::CodeNavigationPath::CODE_NAVIGATION_JOB_NAME }
let_it_be(:pipeline) { create(:ci_pipeline, project: project, sha: sha) } let_it_be(:pipeline) { create(:ci_pipeline, project: project, sha: sha) }
let_it_be(:job) { create(:ci_build, pipeline: pipeline, name: build_name) } let_it_be(:job) { create(:ci_build, pipeline: pipeline) }
let_it_be(:artifact) { create(:ci_job_artifact, :lsif, job: job) } let_it_be(:artifact) { create(:ci_job_artifact, :lsif, job: job) }
let(:commit_sha) { sha } let(:commit_sha) { sha }
...@@ -18,7 +17,7 @@ describe Gitlab::CodeNavigationPath do ...@@ -18,7 +17,7 @@ describe Gitlab::CodeNavigationPath do
context 'when a pipeline exist for a sha' do context 'when a pipeline exist for a sha' do
it 'returns path to a file in the artifact' do it 'returns path to a file in the artifact' do
expect(subject).to eq("/#{project.full_path}/-/jobs/#{job.id}/artifacts/raw/lsif/#{path}.json") expect(subject).to eq("/#{project.full_path}/-/jobs/#{job.id}/artifacts/raw/lsif/#{path}.json?file_type=lsif")
end end
end end
...@@ -26,7 +25,7 @@ describe Gitlab::CodeNavigationPath do ...@@ -26,7 +25,7 @@ describe Gitlab::CodeNavigationPath do
let(:commit_sha) { project.commit.id } let(:commit_sha) { project.commit.id }
it 'returns path to a file in the artifact' do it 'returns path to a file in the artifact' do
expect(subject).to eq("/#{project.full_path}/-/jobs/#{job.id}/artifacts/raw/lsif/#{path}.json") expect(subject).to eq("/#{project.full_path}/-/jobs/#{job.id}/artifacts/raw/lsif/#{path}.json?file_type=lsif")
end end
end 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