-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix integration test for merge in the main branch (#63)
If we want to merge in the main branch, we do it because we want to publish the package. Therefore, we need to be sure that there is an existing version of the dependent QED packages that works with the new version of the package we want to release. The integration tests are tested against the development branch and the release version. - The dev branch version must pass, as this means that the latest version of the other QED packages is compatible with our release version. - The release version can exist. If they exist, it means that we do not need to release a new version of this package. I will open an test PR to test if the feature is correctly working. If it is working, I mark the PR for ready for review.
- Loading branch information
1 parent
90cf1a9
commit b7d3484
Showing
4 changed files
with
252 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
using YAML | ||
|
||
""" | ||
yaml_diff(given, expected)::AbstractString | ||
Generates an error string that shows a given and an expected data structure in yaml | ||
representation. | ||
# Returns | ||
- Human readable error message for the comparison of two job yaml's. | ||
""" | ||
function yaml_diff(given, expected)::AbstractString | ||
output = "\ngiven:\n" | ||
output *= String(YAML.yaml(given)) | ||
output *= "\nexpected:\n" | ||
output *= String(YAML.yaml(expected)) | ||
return output | ||
end | ||
|
||
@testset "generate_job_yaml()" begin | ||
package_infos = integTestGen.get_package_info() | ||
|
||
@testset "target main branch, no PR" begin | ||
job_yaml = Dict() | ||
integTestGen.generate_job_yaml!( | ||
"QEDcore", "main", "/path/to/QEDcore.jl", job_yaml, package_infos | ||
) | ||
@test length(job_yaml) == 1 | ||
|
||
expected_job_yaml = Dict() | ||
expected_job_yaml["IntegrationTestQEDcore"] = Dict( | ||
"image" => "julia:1.9", | ||
"interruptible" => true, | ||
"tags" => ["cpuonly"], | ||
"script" => [ | ||
"apt update", | ||
"apt install -y git", | ||
"cd /", | ||
"git clone -b main $(package_infos["QEDcore"].url) integration_test", | ||
"cd integration_test", | ||
"julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url=\"https://github.com/QEDjl-project/registry.git\"));'", | ||
"julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url=\"https://github.com/JuliaRegistries/General\"));'", | ||
"julia --project=. -e 'import Pkg; Pkg.develop(path=\"/path/to/QEDcore.jl\");'", | ||
"julia --project=. -e 'import Pkg; Pkg.test(; coverage = true)'", | ||
], | ||
) | ||
|
||
@test ( | ||
@assert job_yaml["IntegrationTestQEDcore"]["script"] == | ||
expected_job_yaml["IntegrationTestQEDcore"]["script"] yaml_diff( | ||
job_yaml["IntegrationTestQEDcore"]["script"], | ||
expected_job_yaml["IntegrationTestQEDcore"]["script"], | ||
); | ||
true | ||
) | ||
|
||
@test ( | ||
@assert job_yaml["IntegrationTestQEDcore"] == | ||
expected_job_yaml["IntegrationTestQEDcore"] yaml_diff( | ||
job_yaml["IntegrationTestQEDcore"], | ||
expected_job_yaml["IntegrationTestQEDcore"], | ||
); | ||
true | ||
) | ||
end | ||
|
||
@testset "target non main branch, if PR or not is the same" begin | ||
job_yaml = Dict() | ||
integTestGen.generate_job_yaml!( | ||
"QEDcore", "feature3", "/path/to/QEDcore.jl", job_yaml, package_infos | ||
) | ||
@test length(job_yaml) == 1 | ||
|
||
expected_job_yaml = Dict() | ||
expected_job_yaml["IntegrationTestQEDcore"] = Dict( | ||
"image" => "julia:1.9", | ||
"interruptible" => true, | ||
"tags" => ["cpuonly"], | ||
"script" => [ | ||
"apt update", | ||
"apt install -y git", | ||
"cd /", | ||
"git clone -b feature3 $(package_infos["QEDcore"].url) integration_test", | ||
"git clone -b dev https://github.com/QEDjl-project/QED.jl.git /integration_test_tools", | ||
"cd integration_test", | ||
"julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url=\"https://github.com/QEDjl-project/registry.git\"));'", | ||
"julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url=\"https://github.com/JuliaRegistries/General\"));'", | ||
"julia --project=. -e 'import Pkg; Pkg.develop(path=\"/path/to/QEDcore.jl\");'", | ||
"julia --project=. /integration_test_tools/.ci/set_dev_dependencies.jl", | ||
"julia --project=. -e 'import Pkg; Pkg.test(; coverage = true)'", | ||
], | ||
) | ||
|
||
@test ( | ||
@assert job_yaml["IntegrationTestQEDcore"]["script"] == | ||
expected_job_yaml["IntegrationTestQEDcore"]["script"] yaml_diff( | ||
job_yaml["IntegrationTestQEDcore"]["script"], | ||
expected_job_yaml["IntegrationTestQEDcore"]["script"], | ||
); | ||
true | ||
) | ||
|
||
@test ( | ||
@assert job_yaml["IntegrationTestQEDcore"] == | ||
expected_job_yaml["IntegrationTestQEDcore"] yaml_diff( | ||
job_yaml["IntegrationTestQEDcore"], | ||
expected_job_yaml["IntegrationTestQEDcore"], | ||
); | ||
true | ||
) | ||
end | ||
|
||
@testset "target main branch, PR" begin | ||
job_yaml = Dict() | ||
integTestGen.generate_job_yaml!( | ||
"QEDcore", "dev", "/path/to/QEDcore.jl", job_yaml, package_infos | ||
) | ||
integTestGen.generate_job_yaml!( | ||
"QEDcore", "main", "/path/to/QEDcore.jl", job_yaml, package_infos, true | ||
) | ||
@test length(job_yaml) == 2 | ||
|
||
expected_job_yaml = Dict() | ||
expected_job_yaml["IntegrationTestQEDcore"] = Dict( | ||
"image" => "julia:1.9", | ||
"interruptible" => true, | ||
"tags" => ["cpuonly"], | ||
"script" => [ | ||
"apt update", | ||
"apt install -y git", | ||
"cd /", | ||
"git clone -b dev $(package_infos["QEDcore"].url) integration_test", | ||
"git clone -b dev https://github.com/QEDjl-project/QED.jl.git /integration_test_tools", | ||
"cd integration_test", | ||
"julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url=\"https://github.com/QEDjl-project/registry.git\"));'", | ||
"julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url=\"https://github.com/JuliaRegistries/General\"));'", | ||
"julia --project=. -e 'import Pkg; Pkg.develop(path=\"/path/to/QEDcore.jl\");'", | ||
"julia --project=. /integration_test_tools/.ci/set_dev_dependencies.jl", | ||
"julia --project=. -e 'import Pkg; Pkg.test(; coverage = true)'", | ||
], | ||
) | ||
|
||
@test ( | ||
@assert job_yaml["IntegrationTestQEDcore"]["script"] == | ||
expected_job_yaml["IntegrationTestQEDcore"]["script"] yaml_diff( | ||
job_yaml["IntegrationTestQEDcore"]["script"], | ||
expected_job_yaml["IntegrationTestQEDcore"]["script"], | ||
); | ||
true | ||
) | ||
|
||
@test ( | ||
@assert job_yaml["IntegrationTestQEDcore"] == | ||
expected_job_yaml["IntegrationTestQEDcore"] yaml_diff( | ||
job_yaml["IntegrationTestQEDcore"], | ||
expected_job_yaml["IntegrationTestQEDcore"], | ||
); | ||
true | ||
) | ||
|
||
expected_job_yaml["IntegrationTestQEDcoreReleaseTest"] = Dict( | ||
"image" => "julia:1.9", | ||
"interruptible" => true, | ||
"tags" => ["cpuonly"], | ||
"allow_failure" => true, | ||
"script" => [ | ||
"apt update", | ||
"apt install -y git", | ||
"cd /", | ||
"git clone -b main $(package_infos["QEDcore"].url) integration_test", | ||
"cd integration_test", | ||
"julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url=\"https://github.com/QEDjl-project/registry.git\"));'", | ||
"julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url=\"https://github.com/JuliaRegistries/General\"));'", | ||
"julia --project=. -e 'import Pkg; Pkg.develop(path=\"/path/to/QEDcore.jl\");'", | ||
"julia --project=. -e 'import Pkg; Pkg.test(; coverage = true)'", | ||
], | ||
) | ||
|
||
@test ( | ||
@assert job_yaml["IntegrationTestQEDcoreReleaseTest"]["script"] == | ||
expected_job_yaml["IntegrationTestQEDcoreReleaseTest"]["script"] yaml_diff( | ||
job_yaml["IntegrationTestQEDcoreReleaseTest"]["script"], | ||
expected_job_yaml["IntegrationTestQEDcoreReleaseTest"]["script"], | ||
); | ||
true | ||
) | ||
|
||
@test ( | ||
@assert job_yaml["IntegrationTestQEDcoreReleaseTest"] == | ||
expected_job_yaml["IntegrationTestQEDcoreReleaseTest"] yaml_diff( | ||
job_yaml["IntegrationTestQEDcoreReleaseTest"], | ||
expected_job_yaml["IntegrationTestQEDcoreReleaseTest"], | ||
); | ||
true | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ using Test | |
|
||
include("./integTestGen.jl") | ||
include("./get_target_branch.jl") | ||
include("./generate_job_yaml.jl") |