From 65f044f5fc2f3b8d1610a7edce29558f2c25d975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Galy-Fajou?= Date: Thu, 19 May 2022 16:22:01 +0200 Subject: [PATCH 01/12] Add Gitlab to Coveralls --- src/coveralls.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/coveralls.jl b/src/coveralls.jl index 77eb00b..ae19f5d 100644 --- a/src/coveralls.jl +++ b/src/coveralls.jl @@ -105,6 +105,10 @@ function prepare_request(fcs::Vector{FileCoverage}, local_env::Bool, git_info=qu github_pr = get(github_pr_info, "number", "") github_pr::Union{AbstractString, Integer} ((github_pr isa Integer) || (!isempty(github_pr))) && (data["service_pull_request"] = strip(string(github_pr))) + elseif haskey(ENV, "GITLAB_CI") + data["service_job_id"] = ENV["CI_JOB_ID"] + data["service_name"] = "gitlab" + data["git"] = parse_git_info(git_info) else data["git"] = parse_git_info(git_info) end From 4a87822d068a66f0d16e5dfb223d88b04747a02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Galy-Fajou?= Date: Thu, 19 May 2022 16:25:21 +0200 Subject: [PATCH 02/12] First try at Codecov.io --- src/codecovio.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/codecovio.jl b/src/codecovio.jl index c6f93cb..ad52fd3 100644 --- a/src/codecovio.jl +++ b/src/codecovio.jl @@ -175,6 +175,15 @@ function add_ci_to_kwargs(kwargs::Dict) if ENV["BUILDKITE_PULL_REQUEST"] != "false" kwargs = set_defaults(kwargs, pr = ENV["BUILDKITE_PULL_REQUEST"]) end + elseif haskey(ENV, "GITLAB_CI") + kwargs = set_defaults(kwargs, + service = "gitlab", + branch = ENV["CI_COMMIT_REF_NAME"], + commit = ENV["CI_COMMIT_SHA"], + job = ENV["CI_JOB_ID"], + build = ENV["CI_JOB_NAME"], + build_url = ENV["CI_REPOSITORY_URL"] + ) else error("No compatible CI platform detected") end From 2aa4aa32c7408cc3b9545b434b8721fb2f3d22c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Galy-Fajou?= Date: Thu, 19 May 2022 17:37:26 +0200 Subject: [PATCH 03/12] Update coveralls.jl --- src/coveralls.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coveralls.jl b/src/coveralls.jl index ae19f5d..f07ce10 100644 --- a/src/coveralls.jl +++ b/src/coveralls.jl @@ -106,7 +106,7 @@ function prepare_request(fcs::Vector{FileCoverage}, local_env::Bool, git_info=qu github_pr::Union{AbstractString, Integer} ((github_pr isa Integer) || (!isempty(github_pr))) && (data["service_pull_request"] = strip(string(github_pr))) elseif haskey(ENV, "GITLAB_CI") - data["service_job_id"] = ENV["CI_JOB_ID"] +# data["service_job_id"] = ENV["CI_JOB_ID"] data["service_name"] = "gitlab" data["git"] = parse_git_info(git_info) else From 7993fee1d6f2cab8268635f063bc1e285cf08552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Galy-Fajou?= Date: Thu, 19 May 2022 17:41:05 +0200 Subject: [PATCH 04/12] Update coveralls.jl --- src/coveralls.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coveralls.jl b/src/coveralls.jl index f07ce10..ae19f5d 100644 --- a/src/coveralls.jl +++ b/src/coveralls.jl @@ -106,7 +106,7 @@ function prepare_request(fcs::Vector{FileCoverage}, local_env::Bool, git_info=qu github_pr::Union{AbstractString, Integer} ((github_pr isa Integer) || (!isempty(github_pr))) && (data["service_pull_request"] = strip(string(github_pr))) elseif haskey(ENV, "GITLAB_CI") -# data["service_job_id"] = ENV["CI_JOB_ID"] + data["service_job_id"] = ENV["CI_JOB_ID"] data["service_name"] = "gitlab" data["git"] = parse_git_info(git_info) else From f9ced6bf2cb80a1ae3de1c444d711cc263536d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Galy-Fajou?= Date: Thu, 19 May 2022 17:46:38 +0200 Subject: [PATCH 05/12] Update codecovio.jl --- src/codecovio.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/codecovio.jl b/src/codecovio.jl index ad52fd3..a398caf 100644 --- a/src/codecovio.jl +++ b/src/codecovio.jl @@ -181,7 +181,6 @@ function add_ci_to_kwargs(kwargs::Dict) branch = ENV["CI_COMMIT_REF_NAME"], commit = ENV["CI_COMMIT_SHA"], job = ENV["CI_JOB_ID"], - build = ENV["CI_JOB_NAME"], build_url = ENV["CI_REPOSITORY_URL"] ) else From 7c042bf71895889b2b44038aef125cad73b0e7b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Galy-Fajou?= Date: Sun, 22 May 2022 20:18:26 +0100 Subject: [PATCH 06/12] Add tests and correct API --- src/codecovio.jl | 10 ++-- src/coveralls.jl | 5 +- test/runtests.jl | 118 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 4 deletions(-) diff --git a/src/codecovio.jl b/src/codecovio.jl index a398caf..576a60b 100644 --- a/src/codecovio.jl +++ b/src/codecovio.jl @@ -71,6 +71,7 @@ end add_ci_to_kwargs(; kwargs...) = add_ci_to_kwargs(Dict{Symbol,Any}(kwargs)) function add_ci_to_kwargs(kwargs::Dict) + # https://docs.codecov.com/reference/upload if lowercase(get(ENV, "APPVEYOR", "false")) == "true" appveyor_pr = get(ENV, "APPVEYOR_PULL_REQUEST_NUMBER", "") appveyor_job = join( @@ -175,13 +176,16 @@ function add_ci_to_kwargs(kwargs::Dict) if ENV["BUILDKITE_PULL_REQUEST"] != "false" kwargs = set_defaults(kwargs, pr = ENV["BUILDKITE_PULL_REQUEST"]) end - elseif haskey(ENV, "GITLAB_CI") + elseif haskey(ENV, "GITLAB_CI") + # Gitlab API: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html kwargs = set_defaults(kwargs, service = "gitlab", - branch = ENV["CI_COMMIT_REF_NAME"], + branch = ENV["CI_COMMIT_BRANCH"], commit = ENV["CI_COMMIT_SHA"], job = ENV["CI_JOB_ID"], - build_url = ENV["CI_REPOSITORY_URL"] + build_url = ENV["CI_PIPELINE_URL"], + build = ENV["CI_PIPELINE_IID"], + pull_request = ENV["CI_MERGE_REQUEST_TITLE"], ) else error("No compatible CI platform detected") diff --git a/src/coveralls.jl b/src/coveralls.jl index ae19f5d..200d0da 100644 --- a/src/coveralls.jl +++ b/src/coveralls.jl @@ -69,7 +69,7 @@ end function prepare_request(fcs::Vector{FileCoverage}, local_env::Bool, git_info=query_git_info) data = Dict{String,Any}("source_files" => map(to_json, fcs)) - + # Coveralls API : https://docs.coveralls.io/api-reference if local_env # Attempt to parse git info via git_info, unless the user explicitly disables it by setting git_info to nothing data["service_name"] = "local" @@ -106,9 +106,12 @@ function prepare_request(fcs::Vector{FileCoverage}, local_env::Bool, git_info=qu github_pr::Union{AbstractString, Integer} ((github_pr isa Integer) || (!isempty(github_pr))) && (data["service_pull_request"] = strip(string(github_pr))) elseif haskey(ENV, "GITLAB_CI") + # Gitlab API: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html + data["service_number"] = ENV["CI_PIPELINE_IID"] data["service_job_id"] = ENV["CI_JOB_ID"] data["service_name"] = "gitlab" data["git"] = parse_git_info(git_info) + data["git"]["branch"] = ENV["CI_COMMIT_BRANCH"] else data["git"] = parse_git_info(git_info) end diff --git a/test/runtests.jl b/test/runtests.jl index b81a76f..8e06110 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -482,6 +482,81 @@ withenv( end end + # test Gitlab ci submission process + + # set up Gitlab ci env + # test circle ci submission process + + # set up circle ci env + withenv( + "GITLAB_CI" => "true", + "CI_MERGE_REQUEST_TITLE" => "t_pr", + "CI_JOB_ID" => "t_proj", + "CI_COMMIT_REF_NAME" => "t_branch", + "CI_COMMIT_SHA" => "t_commit", + "CI_PROJECT_NAME" => "t_repo", + "CI_REPOSITORY_URL" => "t_url", + "CI_MERGE_REQUEST_ID" => "t_num", + ) do + + # default values + codecov_url = construct_uri_string_ci() + @test occursin("codecov.io", codecov_url) + @test occursin("service=gitlab", codecov_url) + @test occursin("branch=t_branch", codecov_url) + @test occursin("commit=t_commit", codecov_url) + @test occursin("pull_request=t_pr", codecov_url) + @test occursin("build_url=t_url", codecov_url) + @test occursin("build=t_num", codecov_url) + + # env var url override + withenv( "CODECOV_URL" => "https://enterprise-codecov-1.com" ) do + + codecov_url = construct_uri_string_ci() + @test occursin("enterprise-codecov-1.com", codecov_url) + @test occursin("service=gitlab", codecov_url) + @test occursin("branch=t_branch", codecov_url) + @test occursin("commit=t_commit", codecov_url) + @test occursin("pull_request=t_pr", codecov_url) + @test occursin("build_url=t_url", codecov_url) + @test occursin("build=t_num", codecov_url) + + # function argument url override + codecov_url = construct_uri_string_ci(codecov_url="https://enterprise-codecov-2.com") + @test occursin("enterprise-codecov-2.com", codecov_url) + @test occursin("service=gitlab", codecov_url) + @test occursin("branch=t_branch", codecov_url) + @test occursin("commit=t_commit", codecov_url) + @test occursin("pull_request=t_pr", codecov_url) + @test occursin("build_url=t_url", codecov_url) + @test occursin("build=t_num", codecov_url) + + # env var token + withenv( "CODECOV_TOKEN" => "token_name_1" ) do + + codecov_url = construct_uri_string_ci() + @test occursin("enterprise-codecov-1.com", codecov_url) + @test occursin("token=token_name_1", codecov_url) + @test occursin("service=gitlab", codecov_url) + @test occursin("branch=t_branch", codecov_url) + @test occursin("commit=t_commit", codecov_url) + @test occursin("pull_request=t_pr", codecov_url) + @test occursin("build_url=t_url", codecov_url) + @test occursin("build=t_num", codecov_url) + + # function argument token url override + codecov_url = construct_uri_string_ci(token="token_name_2") + @test occursin("enterprise-codecov-1.com", codecov_url) + @test occursin("service=gitlab", codecov_url) + @test occursin("branch=t_branch", codecov_url) + @test occursin("commit=t_commit", codecov_url) + @test occursin("pull_request=t_pr", codecov_url) + @test occursin("build_url=t_url", codecov_url) + @test occursin("build=t_num", codecov_url) + end + end + end + # test codecov token masking withenv( "APPVEYOR" => "true", @@ -637,6 +712,49 @@ withenv( end end + # test Travis + withenv("TRAVIS" => "true", + "TRAVIS_BUILD_NUMBER" => "my_job_num", + "TRAVIS_JOB_ID" => "my_job_id", + "TRAVIS_PULL_REQUEST" => "t_pr", + "COVERALLS_PARALLEL" => "true") do + request = Coverage.Coveralls.prepare_request(fcs, false) + @test request["repo_token"] == "token_name_1" + @test request["service_number"] == "my_job_num" + @test request["service_job_id"] == "my_job_id" + @test request["service_name"] == "travis-ci" + @test request["service_pull_request"] == "t_pr" + @test request["parallel"] == "true" + end + + # test Travis + withenv("TRAVIS" => "true", + "TRAVIS_BUILD_NUMBER" => "my_job_num", + "TRAVIS_JOB_ID" => "my_job_id", + "TRAVIS_PULL_REQUEST" => "t_pr", + "COVERALLS_PARALLEL" => "true") do + request = Coverage.Coveralls.prepare_request(fcs, false) + @test request["repo_token"] == "token_name_1" + @test request["service_number"] == "my_job_num" + @test request["service_job_id"] == "my_job_id" + @test request["service_name"] == "travis-ci" + @test request["service_pull_request"] == "t_pr" + @test request["parallel"] == "true" + end + + # test Gitlab see https://docs.coveralls.io/api-reference + withenv("GITLAB_CI" => "true", + "CI_PIPELINE_IID" => "my_job_num", + "CI_JOB_ID" => "my_job_id",) do + request = Coverage.Coveralls.prepare_request(fcs, false) + @test request["repo_token"] == "token_name_1" + @test request["service_number"] == "my_job_num" + @test request["service_job_id"] == "my_job_id" + @test request["service_name"] == "gitlab" + @test request["service_pull_request"] == "t_pr" + @test request["parallel"] == "true" + end + # test git_info (only works with Jenkins & local at the moment) withenv("JENKINS" => "true", "BUILD_ID" => "my_job_id", From 3030e595c8482b40d85603ca818b3c54c885bf26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Galy-Fajou?= Date: Mon, 23 May 2022 10:33:43 +0200 Subject: [PATCH 07/12] Fix tests and behaviour --- src/codecovio.jl | 6 ++++-- src/coveralls.jl | 5 ++++- test/runtests.jl | 18 +++++++++--------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/codecovio.jl b/src/codecovio.jl index 576a60b..a619bc0 100644 --- a/src/codecovio.jl +++ b/src/codecovio.jl @@ -178,14 +178,16 @@ function add_ci_to_kwargs(kwargs::Dict) end elseif haskey(ENV, "GITLAB_CI") # Gitlab API: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html + branch = ENV["CI_COMMIT_BRANCH"] + num_mr = branch == ENV["CI_DEFAULT_BRANCH"] ? "false" : ENV["CI_MERGE_REQUEST_IID"] kwargs = set_defaults(kwargs, service = "gitlab", - branch = ENV["CI_COMMIT_BRANCH"], + branch = branch, commit = ENV["CI_COMMIT_SHA"], job = ENV["CI_JOB_ID"], build_url = ENV["CI_PIPELINE_URL"], build = ENV["CI_PIPELINE_IID"], - pull_request = ENV["CI_MERGE_REQUEST_TITLE"], + pull_request = num_mr, ) else error("No compatible CI platform detected") diff --git a/src/coveralls.jl b/src/coveralls.jl index 200d0da..a2fb542 100644 --- a/src/coveralls.jl +++ b/src/coveralls.jl @@ -107,11 +107,14 @@ function prepare_request(fcs::Vector{FileCoverage}, local_env::Bool, git_info=qu ((github_pr isa Integer) || (!isempty(github_pr))) && (data["service_pull_request"] = strip(string(github_pr))) elseif haskey(ENV, "GITLAB_CI") # Gitlab API: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html + branch = ENV["CI_COMMIT_BRANCH"] + num_mr = branch == ENV["CI_DEFAULT_BRANCH"] ? "false" : ENV["CI_MERGE_REQUEST_IID"] + data["service_pull_request"] = num_mr data["service_number"] = ENV["CI_PIPELINE_IID"] data["service_job_id"] = ENV["CI_JOB_ID"] data["service_name"] = "gitlab" data["git"] = parse_git_info(git_info) - data["git"]["branch"] = ENV["CI_COMMIT_BRANCH"] + data["git"]["branch"] = branch else data["git"] = parse_git_info(git_info) end diff --git a/test/runtests.jl b/test/runtests.jl index 8e06110..72848c0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -485,18 +485,16 @@ withenv( # test Gitlab ci submission process # set up Gitlab ci env - # test circle ci submission process - - # set up circle ci env withenv( "GITLAB_CI" => "true", - "CI_MERGE_REQUEST_TITLE" => "t_pr", + "CI_MERGE_REQUEST_IID" => "t_pr", "CI_JOB_ID" => "t_proj", - "CI_COMMIT_REF_NAME" => "t_branch", + "CI_COMMIT_BRANCH" => "t_branch", "CI_COMMIT_SHA" => "t_commit", "CI_PROJECT_NAME" => "t_repo", - "CI_REPOSITORY_URL" => "t_url", - "CI_MERGE_REQUEST_ID" => "t_num", + "CI_PIPELINE_URL" => "t_url", + "CI_PIPELINE_IID" => "t_num", + "CI_DEFAULT_BRANCH" => "master", ) do # default values @@ -745,14 +743,16 @@ withenv( # test Gitlab see https://docs.coveralls.io/api-reference withenv("GITLAB_CI" => "true", "CI_PIPELINE_IID" => "my_job_num", - "CI_JOB_ID" => "my_job_id",) do + "CI_JOB_ID" => "my_job_id", + "CI_COMMIT_BRANCH" => "test", + "CI_DEFAULT_BRANCH" => "master", + "CI_MERGE_REQUEST_IID" => "t_pr") do request = Coverage.Coveralls.prepare_request(fcs, false) @test request["repo_token"] == "token_name_1" @test request["service_number"] == "my_job_num" @test request["service_job_id"] == "my_job_id" @test request["service_name"] == "gitlab" @test request["service_pull_request"] == "t_pr" - @test request["parallel"] == "true" end # test git_info (only works with Jenkins & local at the moment) From 9a4e40f7a7770c7ccc558b4a3a9ea2a9335f0d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Galy-Fajou?= Date: Mon, 23 May 2022 11:06:51 +0200 Subject: [PATCH 08/12] Remove duplicate test --- test/runtests.jl | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 72848c0..12e267a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -710,36 +710,6 @@ withenv( end end - # test Travis - withenv("TRAVIS" => "true", - "TRAVIS_BUILD_NUMBER" => "my_job_num", - "TRAVIS_JOB_ID" => "my_job_id", - "TRAVIS_PULL_REQUEST" => "t_pr", - "COVERALLS_PARALLEL" => "true") do - request = Coverage.Coveralls.prepare_request(fcs, false) - @test request["repo_token"] == "token_name_1" - @test request["service_number"] == "my_job_num" - @test request["service_job_id"] == "my_job_id" - @test request["service_name"] == "travis-ci" - @test request["service_pull_request"] == "t_pr" - @test request["parallel"] == "true" - end - - # test Travis - withenv("TRAVIS" => "true", - "TRAVIS_BUILD_NUMBER" => "my_job_num", - "TRAVIS_JOB_ID" => "my_job_id", - "TRAVIS_PULL_REQUEST" => "t_pr", - "COVERALLS_PARALLEL" => "true") do - request = Coverage.Coveralls.prepare_request(fcs, false) - @test request["repo_token"] == "token_name_1" - @test request["service_number"] == "my_job_num" - @test request["service_job_id"] == "my_job_id" - @test request["service_name"] == "travis-ci" - @test request["service_pull_request"] == "t_pr" - @test request["parallel"] == "true" - end - # test Gitlab see https://docs.coveralls.io/api-reference withenv("GITLAB_CI" => "true", "CI_PIPELINE_IID" => "my_job_num", From 27d8c708c7cf73eec6eec646016e8531b59231eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Galy-Fajou?= Date: Mon, 23 May 2022 11:25:41 +0200 Subject: [PATCH 09/12] Add fixes --- src/codecovio.jl | 4 ++-- src/coveralls.jl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/codecovio.jl b/src/codecovio.jl index a619bc0..a610d86 100644 --- a/src/codecovio.jl +++ b/src/codecovio.jl @@ -178,7 +178,7 @@ function add_ci_to_kwargs(kwargs::Dict) end elseif haskey(ENV, "GITLAB_CI") # Gitlab API: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html - branch = ENV["CI_COMMIT_BRANCH"] + branch = ENV["CI_COMMIT_REF_NAME"] num_mr = branch == ENV["CI_DEFAULT_BRANCH"] ? "false" : ENV["CI_MERGE_REQUEST_IID"] kwargs = set_defaults(kwargs, service = "gitlab", @@ -187,7 +187,7 @@ function add_ci_to_kwargs(kwargs::Dict) job = ENV["CI_JOB_ID"], build_url = ENV["CI_PIPELINE_URL"], build = ENV["CI_PIPELINE_IID"], - pull_request = num_mr, + pr = num_mr, ) else error("No compatible CI platform detected") diff --git a/src/coveralls.jl b/src/coveralls.jl index a2fb542..dbbb90d 100644 --- a/src/coveralls.jl +++ b/src/coveralls.jl @@ -107,7 +107,7 @@ function prepare_request(fcs::Vector{FileCoverage}, local_env::Bool, git_info=qu ((github_pr isa Integer) || (!isempty(github_pr))) && (data["service_pull_request"] = strip(string(github_pr))) elseif haskey(ENV, "GITLAB_CI") # Gitlab API: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html - branch = ENV["CI_COMMIT_BRANCH"] + branch = ENV["CI_COMMIT_REF_NAME"] num_mr = branch == ENV["CI_DEFAULT_BRANCH"] ? "false" : ENV["CI_MERGE_REQUEST_IID"] data["service_pull_request"] = num_mr data["service_number"] = ENV["CI_PIPELINE_IID"] From 52e41a2ffdd30cbaa79588d66eb16cdb6a786cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Galy-Fajou?= Date: Mon, 23 May 2022 11:41:40 +0200 Subject: [PATCH 10/12] Readapt used env --- src/codecovio.jl | 2 +- test/runtests.jl | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/codecovio.jl b/src/codecovio.jl index a610d86..b1b594a 100644 --- a/src/codecovio.jl +++ b/src/codecovio.jl @@ -187,7 +187,7 @@ function add_ci_to_kwargs(kwargs::Dict) job = ENV["CI_JOB_ID"], build_url = ENV["CI_PIPELINE_URL"], build = ENV["CI_PIPELINE_IID"], - pr = num_mr, + pr = num_mr, ) else error("No compatible CI platform detected") diff --git a/test/runtests.jl b/test/runtests.jl index 12e267a..530f1bf 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -489,7 +489,7 @@ withenv( "GITLAB_CI" => "true", "CI_MERGE_REQUEST_IID" => "t_pr", "CI_JOB_ID" => "t_proj", - "CI_COMMIT_BRANCH" => "t_branch", + "CI_COMMIT_REF_NAME" => "t_branch", "CI_COMMIT_SHA" => "t_commit", "CI_PROJECT_NAME" => "t_repo", "CI_PIPELINE_URL" => "t_url", @@ -503,7 +503,7 @@ withenv( @test occursin("service=gitlab", codecov_url) @test occursin("branch=t_branch", codecov_url) @test occursin("commit=t_commit", codecov_url) - @test occursin("pull_request=t_pr", codecov_url) + @test occursin("pr=t_pr", codecov_url) @test occursin("build_url=t_url", codecov_url) @test occursin("build=t_num", codecov_url) @@ -515,7 +515,7 @@ withenv( @test occursin("service=gitlab", codecov_url) @test occursin("branch=t_branch", codecov_url) @test occursin("commit=t_commit", codecov_url) - @test occursin("pull_request=t_pr", codecov_url) + @test occursin("pr=t_pr", codecov_url) @test occursin("build_url=t_url", codecov_url) @test occursin("build=t_num", codecov_url) @@ -525,7 +525,7 @@ withenv( @test occursin("service=gitlab", codecov_url) @test occursin("branch=t_branch", codecov_url) @test occursin("commit=t_commit", codecov_url) - @test occursin("pull_request=t_pr", codecov_url) + @test occursin("pr=t_pr", codecov_url) @test occursin("build_url=t_url", codecov_url) @test occursin("build=t_num", codecov_url) @@ -538,7 +538,7 @@ withenv( @test occursin("service=gitlab", codecov_url) @test occursin("branch=t_branch", codecov_url) @test occursin("commit=t_commit", codecov_url) - @test occursin("pull_request=t_pr", codecov_url) + @test occursin("pr=t_pr", codecov_url) @test occursin("build_url=t_url", codecov_url) @test occursin("build=t_num", codecov_url) @@ -548,7 +548,7 @@ withenv( @test occursin("service=gitlab", codecov_url) @test occursin("branch=t_branch", codecov_url) @test occursin("commit=t_commit", codecov_url) - @test occursin("pull_request=t_pr", codecov_url) + @test occursin("pr=t_pr", codecov_url) @test occursin("build_url=t_url", codecov_url) @test occursin("build=t_num", codecov_url) end @@ -714,7 +714,7 @@ withenv( withenv("GITLAB_CI" => "true", "CI_PIPELINE_IID" => "my_job_num", "CI_JOB_ID" => "my_job_id", - "CI_COMMIT_BRANCH" => "test", + "CI_COMMIT_REF_NAME" => "test", "CI_DEFAULT_BRANCH" => "master", "CI_MERGE_REQUEST_IID" => "t_pr") do request = Coverage.Coveralls.prepare_request(fcs, false) From cf2b3b24a9317e23ba82321c7c072fb1aa10879b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Galy-Fajou?= Date: Mon, 23 May 2022 13:11:14 +0200 Subject: [PATCH 11/12] Adressed comments --- src/codecovio.jl | 2 +- src/coveralls.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/codecovio.jl b/src/codecovio.jl index b1b594a..0cf2129 100644 --- a/src/codecovio.jl +++ b/src/codecovio.jl @@ -176,7 +176,7 @@ function add_ci_to_kwargs(kwargs::Dict) if ENV["BUILDKITE_PULL_REQUEST"] != "false" kwargs = set_defaults(kwargs, pr = ENV["BUILDKITE_PULL_REQUEST"]) end - elseif haskey(ENV, "GITLAB_CI") + elseif lowercase(get(ENV, "GITLAB_CI", "false")) == "true" # Gitlab API: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html branch = ENV["CI_COMMIT_REF_NAME"] num_mr = branch == ENV["CI_DEFAULT_BRANCH"] ? "false" : ENV["CI_MERGE_REQUEST_IID"] diff --git a/src/coveralls.jl b/src/coveralls.jl index dbbb90d..19cd14f 100644 --- a/src/coveralls.jl +++ b/src/coveralls.jl @@ -105,7 +105,7 @@ function prepare_request(fcs::Vector{FileCoverage}, local_env::Bool, git_info=qu github_pr = get(github_pr_info, "number", "") github_pr::Union{AbstractString, Integer} ((github_pr isa Integer) || (!isempty(github_pr))) && (data["service_pull_request"] = strip(string(github_pr))) - elseif haskey(ENV, "GITLAB_CI") + elseif lowercase(get(ENV, "GITLAB_CI", "false")) == "true" # Gitlab API: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html branch = ENV["CI_COMMIT_REF_NAME"] num_mr = branch == ENV["CI_DEFAULT_BRANCH"] ? "false" : ENV["CI_MERGE_REQUEST_IID"] From 0f0258d69d801d7cac1bbb18beed0145cbe6994c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Galy-Fajou?= Date: Tue, 24 May 2022 16:58:27 +0200 Subject: [PATCH 12/12] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 8223321..a11430c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Coverage" uuid = "a2441757-f6aa-5fb2-8edb-039e3f45d037" authors = ["Iain Dunning ", "contributors"] -version = "1.4.0" +version = "1.5.0" [deps] CoverageTools = "c36e975a-824b-4404-a568-ef97ca766997"