2019-07-25 05:11:48 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-21 08:34:12 +00:00
|
|
|
include ActionDispatch::TestProcess
|
|
|
|
|
2017-12-14 00:13:44 +00:00
|
|
|
FactoryBot.define do
|
2020-01-09 18:07:52 +00:00
|
|
|
factory :ci_job_artifact, class: 'Ci::JobArtifact' do
|
2017-09-21 08:34:12 +00:00
|
|
|
job factory: :ci_build
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :archive }
|
|
|
|
file_format { :zip }
|
2017-09-21 08:34:12 +00:00
|
|
|
|
2019-08-24 21:16:44 +00:00
|
|
|
trait :expired do
|
|
|
|
expire_at { Date.yesterday }
|
|
|
|
end
|
|
|
|
|
2017-12-05 14:31:33 +00:00
|
|
|
trait :remote_store do
|
2020-04-15 18:09:36 +00:00
|
|
|
file_store { JobArtifactUploader::Store::REMOTE}
|
2017-12-05 14:31:33 +00:00
|
|
|
end
|
|
|
|
|
2017-11-02 11:16:50 +00:00
|
|
|
after :build do |artifact|
|
|
|
|
artifact.project ||= artifact.job.project
|
|
|
|
end
|
|
|
|
|
2018-09-27 21:15:08 +00:00
|
|
|
trait :raw do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_format { :raw }
|
2018-09-27 21:15:08 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, _|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/trace/sample_trace'), 'text/plain')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :zip do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_format { :zip }
|
2018-09-27 21:15:08 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, _|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), 'application/zip')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :gzip do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_format { :gzip }
|
2018-09-27 21:15:08 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, _|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'), 'application/x-gzip')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-11-23 17:51:20 +00:00
|
|
|
trait :archive do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :archive }
|
|
|
|
file_format { :zip }
|
2017-11-30 17:32:16 +00:00
|
|
|
|
2019-03-22 12:38:45 +00:00
|
|
|
transient do
|
|
|
|
file { fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), 'application/zip') }
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = evaluator.file
|
2017-09-21 08:34:12 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-17 04:33:15 +00:00
|
|
|
trait :legacy_archive do
|
|
|
|
archive
|
|
|
|
|
2019-10-02 00:06:26 +00:00
|
|
|
file_location { :legacy_path }
|
2018-08-17 04:33:15 +00:00
|
|
|
end
|
|
|
|
|
2017-11-23 17:51:20 +00:00
|
|
|
trait :metadata do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :metadata }
|
|
|
|
file_format { :gzip }
|
2017-11-30 17:32:16 +00:00
|
|
|
|
2019-03-22 12:38:45 +00:00
|
|
|
transient do
|
|
|
|
file { fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'), 'application/x-gzip') }
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = evaluator.file
|
2017-11-23 17:51:20 +00:00
|
|
|
end
|
2017-09-21 08:34:12 +00:00
|
|
|
end
|
2018-02-06 14:18:32 +00:00
|
|
|
|
|
|
|
trait :trace do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :trace }
|
|
|
|
file_format { :raw }
|
2018-02-06 14:18:32 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/trace/sample_trace'), 'text/plain')
|
|
|
|
end
|
|
|
|
end
|
2018-03-06 18:46:36 +00:00
|
|
|
|
2018-07-27 05:04:35 +00:00
|
|
|
trait :junit do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :junit }
|
|
|
|
file_format { :gzip }
|
2018-07-27 05:04:35 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
2018-08-02 08:15:25 +00:00
|
|
|
Rails.root.join('spec/fixtures/junit/junit.xml.gz'), 'application/x-gzip')
|
2018-07-27 05:04:35 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-03 06:09:14 +00:00
|
|
|
trait :junit_with_attachment do
|
|
|
|
file_type { :junit }
|
|
|
|
file_format { :gzip }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/junit/junit_with_attachment.xml.gz'), 'application/x-gzip')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-02 06:05:07 +00:00
|
|
|
trait :junit_with_ant do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :junit }
|
|
|
|
file_format { :gzip }
|
2018-08-02 06:05:07 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
2018-08-02 08:15:25 +00:00
|
|
|
Rails.root.join('spec/fixtures/junit/junit_ant.xml.gz'), 'application/x-gzip')
|
2018-08-02 06:05:07 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :junit_with_three_testsuites do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :junit }
|
|
|
|
file_format { :gzip }
|
2018-08-02 06:05:07 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/junit/junit_with_three_testsuites.xml.gz'), 'application/x-gzip')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :junit_with_corrupted_data do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :junit }
|
|
|
|
file_format { :gzip }
|
2018-08-02 06:05:07 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/junit/junit_with_corrupted_data.xml.gz'), 'application/x-gzip')
|
2020-03-17 18:09:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :cobertura do
|
|
|
|
file_type { :cobertura }
|
|
|
|
file_format { :gzip }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/cobertura/coverage.xml.gz'), 'application/x-gzip')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-21 15:21:10 +00:00
|
|
|
trait :terraform do
|
|
|
|
file_type { :terraform }
|
|
|
|
file_format { :raw }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/terraform/tfplan.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :terraform_with_corrupted_data do
|
|
|
|
file_type { :terraform }
|
|
|
|
file_format { :raw }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/terraform/tfplan_with_corrupted_data.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-17 18:09:44 +00:00
|
|
|
trait :coverage_gocov_xml do
|
|
|
|
file_type { :cobertura }
|
|
|
|
file_format { :gzip }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/cobertura/coverage_gocov_xml.xml.gz'), 'application/x-gzip')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :coverage_with_corrupted_data do
|
|
|
|
file_type { :cobertura }
|
|
|
|
file_format { :gzip }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/cobertura/coverage_with_corrupted_data.xml.gz'), 'application/x-gzip')
|
2018-08-02 06:05:07 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-02 17:01:26 +00:00
|
|
|
trait :codequality do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :codequality }
|
|
|
|
file_format { :raw }
|
2018-10-02 17:01:26 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
2018-10-15 10:17:21 +00:00
|
|
|
Rails.root.join('spec/fixtures/codequality/codequality.json'), 'application/json')
|
2018-10-02 17:01:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-02-10 15:08:54 +00:00
|
|
|
trait :lsif do
|
|
|
|
file_type { :lsif }
|
2020-02-18 12:09:15 +00:00
|
|
|
file_format { :gzip }
|
2020-02-10 15:08:54 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
2020-02-18 12:09:15 +00:00
|
|
|
Rails.root.join('spec/fixtures/lsif.json.gz'), 'application/x-gzip')
|
2020-02-10 15:08:54 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-13 21:09:38 +00:00
|
|
|
trait :dotenv do
|
|
|
|
file_type { :dotenv }
|
|
|
|
file_format { :gzip }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/build.env.gz'), 'application/x-gzip')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-06 18:46:36 +00:00
|
|
|
trait :correct_checksum do
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file_sha256 = Digest::SHA256.file(artifact.file.path).hexdigest
|
|
|
|
end
|
|
|
|
end
|
2017-09-21 08:34:12 +00:00
|
|
|
end
|
|
|
|
end
|