Skip to content

Commit

Permalink
Release 0.1.0 to main (#67)
Browse files Browse the repository at this point in the history
Release version 0.1.0 to main (again)
I appended the changelog with the new PRs
  • Loading branch information
AntonReinhard authored Sep 12, 2024
2 parents c43e326 + 838a6da commit d380874
Show file tree
Hide file tree
Showing 28 changed files with 1,328 additions and 924 deletions.
1 change: 0 additions & 1 deletion .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
style = "blue"

4 changes: 2 additions & 2 deletions .ci/SetupDevEnv/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ using Test
write(
f,
"""
name = "QED"
name = "QuantumElectrodynamics"
uuid = "bb1fba1d-cf9b-41b3-874e-4b81465537b9"
authors = ["Uwe Hernandez Acosta <[email protected]>", "Simeon Ehrig", "Klaus Steiniger", "Tom Jungnickel", "Anton Reinhard"]
version = "0.1.0"
Expand All @@ -98,7 +98,7 @@ using Test
write(
f,
"""
name = "QED"
name = "QuantumElectrodynamics"
uuid = "bb1fba1d-cf9b-41b3-874e-4b81465537b9"
authors = ["Uwe Hernandez Acosta <[email protected]>", "Simeon Ehrig", "Klaus Steiniger", "Tom Jungnickel", "Anton Reinhard"]
version = "0.1.0"
Expand Down
4 changes: 2 additions & 2 deletions .ci/integTestGen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The application `integTestGen.jl` searches for all packages that depend on the s
## Required Environment Variables

- **CI_DEPENDENCY_NAME**: Name of the searched dependency.
- **CI_PROJECT_DIR**: Directory path of a package (containing the `Project.toml`) providing the dependency graph. Usually it is the absolute base path of the `QED.jl` project.
- **CI_PROJECT_DIR**: Directory path of a package (containing the `Project.toml`) providing the dependency graph. Usually it is the absolute base path of the `QuantumElectrodynamics.jl` project.

You can set the environment variables in two different ways:

Expand All @@ -16,4 +16,4 @@ You can set the environment variables in two different ways:

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.
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/QuantumElectrodynamics.jl/setDevDepDeps`. If the environment variable is not set, the default target branch `dev` is used.
75 changes: 66 additions & 9 deletions .ci/integTestGen/src/get_target_branch.jl
Original file line number Diff line number Diff line change
@@ -1,29 +1,72 @@
module getTargetBranch

using HTTP
using JSON
using Pkg

"""
get_target_branch()::AbstractString
is_pull_request()::Bool
Checks whether the GitLab CI mirror branch was created by a GitHub pull request.
# Return
true if is a Pull Request branch, otherwise false
"""
function is_pull_request()::Bool
# GitLab CI provides the environemnt variable with the following pattern
# # pr-<PR number>/<repo owner of the source branch>/<project name>/<source branch name>
# e.g. pr-41/SimeonEhrig/QuantumElectrodynamics.jl/setDevDepDeps
if !haskey(ENV, "CI_COMMIT_REF_NAME")
error("Environment variable CI_COMMIT_REF_NAME is not set.")
end

return startswith(ENV["CI_COMMIT_REF_NAME"], "pr-")
end

"""
get_build_branch()::AbstractString
Returns the build branch except for version tags. In this case, main is returned.
# Return
build branch name
"""
function get_build_branch()::AbstractString
if !haskey(ENV, "CI_COMMIT_REF_NAME")
error("Environment variable CI_COMMIT_REF_NAME is not set.")
end

ci_commit_ref_name = string(ENV["CI_COMMIT_REF_NAME"])

try
VersionNumber(ci_commit_ref_name)
# branch is a version tag
return "main"
catch
return ci_commit_ref_name
end
end

"""
get_target_branch_pull_request()::AbstractString
Returns the name of the target branch of the pull request. The function is required for our special
setup where we mirror a PR from GitHub to GitLab CI. No merge request will be open on GitLab.
Instead, a feature branch will be created and the commit will be pushed. As a result, we lose
information about the original PR. So we need to use the GitHub Rest API to get the information
depending on the repository name and PR number.
"""
function get_target_branch()::AbstractString
function get_target_branch_pull_request()::AbstractString
# GitLab CI provides the environemnt variable with the following pattern
# # pr-<PR number>/<repo owner of the source branch>/<project name>/<source branch name>
# e.g. pr-41/SimeonEhrig/QED.jl/setDevDepDeps
# e.g. pr-41/SimeonEhrig/QuantumElectrodynamics.jl/setDevDepDeps
if !haskey(ENV, "CI_COMMIT_REF_NAME")
error("Environment variable CI_COMMIT_REF_NAME is not set.")
end

splited_commit_ref_name = split(ENV["CI_COMMIT_REF_NAME"], "/")

if (!startswith(splited_commit_ref_name[1], "pr-"))
error("CI_COMMIT_REF_NAME does not start with pr-")
# fallback for unknown branches and dev branch
return "dev"
end

# parse to Int only to check if it is a number
Expand Down Expand Up @@ -63,9 +106,23 @@ function get_target_branch()::AbstractString
return "dev"
end

if abspath(PROGRAM_FILE) == @__FILE__
target_branch = get_target_branch()
println(target_branch)
"""
get_target()::AbstractString
Return the correct target branch name for our GitLab CI mirror setup.
# Return
target branch name
"""
function get_target()::AbstractString
if is_pull_request()
return get_target_branch_pull_request()
else
return get_build_branch()
end
end

if abspath(PROGRAM_FILE) == @__FILE__
print(get_target())
end
75 changes: 59 additions & 16 deletions .ci/integTestGen/src/integTestGen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ to analyze as a dependency.
# Args
`project_path::AbstractString`: Absolute path to the project folder of the package to be analyzed
`package_infos::AbstractDict{String,PackageInfo}`: List depending QED pojects of QED.jl. Use the list to
`package_infos::AbstractDict{String,PackageInfo}`: List depending QED pojects of QuantumElectrodynamics.jl. Use the list to
add the current dev branch version of the packages to the environment or a custom repository with
custom branch.
"""
Expand Down Expand Up @@ -211,13 +211,18 @@ 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.
- `ci_project_dir::AbstractString`: Path of QED project which should be used for the integration test.
- `job_yaml::Dict`: Add generated job to this dict.
- `package_infos::AbstractDict{String,PackageInfo}`: Contains serveral information about QED packages
- `can_fail::Bool=false`: If true add `allow_failure=true` to the job yaml
"""
function generate_job_yaml!(
package_name::String,
target_branch::AbstractString,
ci_project_dir::AbstractString,
job_yaml::Dict,
package_infos::AbstractDict{String,PackageInfo},
can_fail::Bool=false,
)
package_info = package_infos[package_name]
# if modified_url is empty, use original url
Expand All @@ -238,7 +243,7 @@ function generate_job_yaml!(
if (target_branch != "main")
push!(
script,
"git clone -b dev https://github.com/QEDjl-project/QED.jl.git /integration_test_tools",
"git clone -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /integration_test_tools",
)
end
push!(script, "cd integration_test")
Expand All @@ -257,7 +262,6 @@ function generate_job_yaml!(
script,
"julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url=\"https://github.com/JuliaRegistries/General\"));'",
)
ci_project_dir = ENV["CI_PROJECT_DIR"]
push!(
script, "julia --project=. -e 'import Pkg; Pkg.develop(path=\"$ci_project_dir\");'"
)
Expand All @@ -268,12 +272,19 @@ function generate_job_yaml!(
end
push!(script, "julia --project=. -e 'import Pkg; Pkg.test(; coverage = true)'")

return job_yaml["IntegrationTest$package_name"] = Dict(
current_job_yaml = Dict(
"image" => "julia:1.9",
"interruptible" => true,
"tags" => ["cpuonly"],
"script" => script,
)

if can_fail
current_job_yaml["allow_failure"] = true
return job_yaml["IntegrationTest$(package_name)ReleaseTest"] = current_job_yaml
else
return job_yaml["IntegrationTest$package_name"] = current_job_yaml
end
end

"""
Expand All @@ -292,17 +303,16 @@ 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
"""
get_package_info()::Dict{String,PackageInfo}
package_infos = Dict(
"QED" => PackageInfo(
"https://github.com/QEDjl-project/QED.jl.git", "CI_INTG_PKG_URL_QED"
Returns a list with QED project package information.
"""
function get_package_info()::Dict{String,PackageInfo}
return Dict(
"QuantumElectrodynamics" => PackageInfo(
"https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git",
"CI_INTG_PKG_URL_QED",
),
"QEDfields" => PackageInfo(
"https://github.com/QEDjl-project/QEDfields.jl.git",
Expand All @@ -323,6 +333,17 @@ if abspath(PROGRAM_FILE) == @__FILE__
"https://github.com/QEDjl-project/QEDcore.jl.git", "CI_INTG_PKG_URL_QEDcore"
),
)
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 = get_target()
end

package_infos = get_package_info()

# custom commit message variable can be set as first argument
if length(ARGS) < 1
Expand All @@ -335,15 +356,37 @@ if abspath(PROGRAM_FILE) == @__FILE__
modified_pkg = modified_package_name(package_infos)

# the script is locate in ci/integTestGen/src
# so we need to go 3 steps upwards in hierarchy to get the QED.jl Project.toml
# so we need to go 3 steps upwards in hierarchy to get the QuantumElectrodynamics.jl Project.toml
create_working_env(abspath(joinpath((@__DIR__), "../../..")), package_infos)
depending_pkg = depending_projects(modified_pkg, collect(keys(package_infos)))

job_yaml = Dict()

if !isempty(depending_pkg)
for p in depending_pkg
generate_job_yaml!(p, target_branch, job_yaml, package_infos)
# Handles the case of merging in the main branch. 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 integration tests may or may not pass.
# 1. If all of these pass, we will not need to increase the minor version of this package.
# 2. If they do not all pass, the minor version must be increased and the failing packages
# must also be released later with an updated compat entry.
# In either case the release can proceed, as the released packages will continue to work
# because of their current compat entries.
if target_branch == "main" && is_pull_request()
generate_job_yaml!(p, "dev", ENV["CI_PROJECT_DIR"], job_yaml, package_infos)
generate_job_yaml!(
p, "main", ENV["CI_PROJECT_DIR"], job_yaml, package_infos, true
)
else
generate_job_yaml!(
p, target_branch, ENV["CI_PROJECT_DIR"], job_yaml, package_infos
)
end
end
else
generate_dummy_job_yaml!(job_yaml)
Expand Down
1 change: 1 addition & 0 deletions .ci/integTestGen/test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
PkgDependency = "9eb5382b-762c-48ca-8139-e736883fe800"
Term = "22787eb5-b846-44ae-b979-8e399b8463ab"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
Loading

0 comments on commit d380874

Please sign in to comment.