-
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.
verify in the last CI stage, that unit tests does not rely on feature…
… branches
- Loading branch information
1 parent
ec24176
commit f406741
Showing
7 changed files
with
50 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
stages: | ||
- unit-test | ||
- verify-unit-test-deps | ||
|
||
unit_tests_julia1.9: | ||
image: julia:1.9 | ||
stage: unit-test | ||
script: | ||
- 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=. ${CI_PROJECT_DIR}/SetupDevEnv/src/SetupDevEnv.jl ${CI_PROJECT_DIR}/Project.toml | ||
- julia --project=. ${CI_PROJECT_DIR}/ci/SetupDevEnv/src/SetupDevEnv.jl ${CI_PROJECT_DIR}/Project.toml | ||
- julia --project=. -e 'import Pkg; Pkg.instantiate()' | ||
- julia --project=. -e 'import Pkg; Pkg.test(; coverage = true)' | ||
tags: | ||
- cpuonly | ||
|
||
verify-unit-test-deps_julia1.9: | ||
image: julia:1.9 | ||
stage: verify-unit-test-deps | ||
script: | ||
- julia ${CI_PROJECT_DIR}/ci/verify_env.jl | ||
tags: | ||
- cpuonly |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,40 @@ | ||
""" | ||
The script checks, if custom dependency for unit tests via `CI_UNIT_PKG_URL_<package_name>` are set. | ||
If yes, the script fails, which means in practice, that the PR rely on non merged code. | ||
""" | ||
|
||
""" | ||
extract_env_vars_from_git_message!() | ||
Parse the commit message, if set via variable `CI_COMMIT_MESSAGE` and set custom urls. | ||
""" | ||
function extract_env_vars_from_git_message!() | ||
if haskey(ENV, "CI_COMMIT_MESSAGE") | ||
println("Found env variable CI_COMMIT_MESSAGE") | ||
for line in split(ENV["CI_COMMIT_MESSAGE"], "\n") | ||
line = strip(line) | ||
if startswith(line, "CI_UNIT_PKG_URL_") | ||
(var_name, url) = split(line, ":"; limit=2) | ||
println("add " * var_name * "=" * strip(url)) | ||
ENV[var_name] = strip(url) | ||
end | ||
end | ||
end | ||
end | ||
|
||
if abspath(PROGRAM_FILE) == @__FILE__ | ||
extract_env_vars_from_git_message!() | ||
filtered_env = filter((env_name)-> startswith(env_name, "CI_UNIT_PKG_URL_"), keys(ENV)) | ||
|
||
if isempty(filtered_env) | ||
printstyled("No custom dependencies for unit tests detected.\n"; color = :green) | ||
exit(0) | ||
else | ||
printstyled("Found custom dependencies for unit tests detected.\n"; color = :red) | ||
for env in filtered_env | ||
printstyled(" $env\n"; color = :red) | ||
end | ||
printstyled("\nPlease merge the custom dependency before and run the CI with custom dependency again.\n"; color = :red) | ||
exit(1) | ||
end | ||
end |