Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add script, which set QED dependencies of QED dependencies to the development version in integration tests #41

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ci/integTestGen/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ version = "0.1.0"
[deps]
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PkgDependency = "9eb5382b-762c-48ca-8139-e736883fe800"
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
Expand Down
2 changes: 2 additions & 0 deletions .ci/integTestGen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ You can set the environment variables in two different ways:
## Optional Environment Variables

By default, if an integration test is generated it clones the develop branch of the upstream project. The clone can be overwritten by the environment variable `CI_INTG_PKG_URL_<dep_name>=https://url/to/the/repository#<commit_hash>`. You can find all available environment variables in the dictionary `package_infos` in the `integTestGen.jl`.

Set the environment variable `CI_COMMIT_REF_NAME` to determine the target branch of a GitHub pull request. The form must be `CI_COMMIT_REF_NAME=pr-<PR number>/<repo owner of source branch>/<project name>/<source branch name>`. Here is an example: `CI_COMMIT_REF_NAME=pr-41/SimeonEhrig/QED.jl/setDevDepDeps`. If the environment variable is not set, the default target branch `dev` is used.
33 changes: 30 additions & 3 deletions .ci/integTestGen/src/integTestGen.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
module integTestGen

include("get_target_branch.jl")

using Pkg: Pkg
using PkgDependency: PkgDependency
using YAML: YAML
using Logging

"""
Contains all git-related information about a package.
Expand Down Expand Up @@ -207,10 +210,14 @@ Generate GitLab CI job yaml for integration testing of a given package.

# Args
- `package_name::String`: Name of the package to test.
- `target_branch::AbstractString`: Name of the target branch of the pull request.
- `job_yaml::Dict`: Add generated job to this dict.
"""
function generate_job_yaml!(
package_name::String, job_yaml::Dict, package_infos::AbstractDict{String,PackageInfo}
package_name::String,
target_branch::AbstractString,
job_yaml::Dict,
package_infos::AbstractDict{String,PackageInfo},
)
package_info = package_infos[package_name]
# if modified_url is empty, use original url
Expand All @@ -227,9 +234,17 @@ function generate_job_yaml!(
error("Ill formed url: $(url)")
end

push!(script, "git clone $(split_url[1]) integration_test")
push!(script, "git clone -b $target_branch $(split_url[1]) integration_test")
if (target_branch != "main")
push!(
script,
"git clone -b dev https://github.com/QEDjl-project/QED.jl.git /integration_test_tools",
)
end
push!(script, "cd integration_test")

# checkout specfic branch given by the environemnt variable
# CI_INTG_PKG_URL_<dep_name>=https://url/to/the/repository#<commit_hash>
if length(split_url) == 2
push!(script, "git checkout $(split_url[2])")
end
Expand All @@ -246,6 +261,11 @@ function generate_job_yaml!(
push!(
script, "julia --project=. -e 'import Pkg; Pkg.develop(path=\"$ci_project_dir\");'"
)
if (target_branch != "main")
push!(
script, "julia --project=. /integration_test_tools/.ci/set_dev_dependencies.jl"
)
end
push!(script, "julia --project=. -e 'import Pkg; Pkg.test(; coverage = true)'")

return job_yaml["IntegrationTest$package_name"] = Dict(
Expand Down Expand Up @@ -273,6 +293,13 @@ function generate_dummy_job_yaml!(job_yaml::Dict)
end

if abspath(PROGRAM_FILE) == @__FILE__
if !haskey(ENV, "CI_COMMIT_REF_NAME")
@warn "Environemnt variable CI_COMMIT_REF_NAME not defined. Use default branch `dev`."
target_branch = "dev"
else
target_branch = getTargetBranch.get_target_branch()
end

package_infos = Dict(
"QED" => PackageInfo(
"https://github.com/QEDjl-project/QED.jl.git", "CI_INTG_PKG_URL_QED"
Expand Down Expand Up @@ -316,7 +343,7 @@ if abspath(PROGRAM_FILE) == @__FILE__

if !isempty(depending_pkg)
for p in depending_pkg
generate_job_yaml!(p, job_yaml, package_infos)
generate_job_yaml!(p, target_branch, job_yaml, package_infos)
end
else
generate_dummy_job_yaml!(job_yaml)
Expand Down
Loading