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
scheduler_failure: 2
}.freeze
CODE_NAVIGATION_JOB_NAME = 'code_navigation'
DEGRADATION_THRESHOLD_VARIABLE_NAME = 'DEGRADATION_THRESHOLD'
has_one :deployment, as: :deployable, class_name: 'Deployment'
......
......@@ -5,7 +5,6 @@ module Gitlab
include Gitlab::Utils::StrongMemoize
include Gitlab::Routing
CODE_NAVIGATION_JOB_NAME = 'code_navigation'
LATEST_COMMITS_LIMIT = 10
def initialize(project, commit_sha)
......@@ -17,7 +16,7 @@ module Gitlab
return if Feature.disabled?(:code_navigation, project)
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
private
......@@ -29,10 +28,11 @@ module Gitlab
latest_commits_shas =
project.repository.commits(commit_sha, limit: LATEST_COMMITS_LIMIT).map(&:sha)
artifact = ::Ci::JobArtifact
.for_sha(latest_commits_shas, project.id)
.for_job_name(CODE_NAVIGATION_JOB_NAME)
.last
artifact =
::Ci::JobArtifact
.with_file_types(['lsif'])
.for_sha(latest_commits_shas, project.id)
.last
artifact&.job
end
......
......@@ -6,9 +6,8 @@ describe Gitlab::CodeNavigationPath do
context 'when there is an artifact with code navigation data' do
let_it_be(:project) { create(:project, :repository) }
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(: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(:commit_sha) { sha }
......@@ -18,7 +17,7 @@ describe Gitlab::CodeNavigationPath do
context 'when a pipeline exist for a sha' 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
......@@ -26,7 +25,7 @@ describe Gitlab::CodeNavigationPath do
let(:commit_sha) { project.commit.id }
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
......
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