From e4da9eeee1b87147bf7a4d073af2437c2b908ce1 Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Thu, 6 Jun 2024 11:24:39 +0200 Subject: [PATCH 1/3] added gitlab-ci.yml and dummy function --- .gitlab-ci.yml | 120 +++++++++++++++++++++++++++++++++++++++++++++++ src/QEDcore.jl | 4 ++ test/runtests.jl | 4 +- 3 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..e67fab7 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,120 @@ +stages: + - unit-test + - generate_integration_test + - run_integration_test + - verify-unit-test-deps + +.untit_test_template: + stage: unit-test + script: + - apt update && apt install -y git + - git clone --depth 1 -b dev https://github.com/QEDjl-project/QED.jl.git /QEDjl + - > + if [[ $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_REF_NAME == "dev" ]]; then + # set name of the commit message from CI_COMMIT_MESSAGE to NO_MESSAGE, that the script does not read accidentally custom packages from the commit message of a merge commit + julia --project=. /QEDjl/.ci/SetupDevEnv/src/SetupDevEnv.jl ${CI_PROJECT_DIR}/Project.toml NO_MESSAGE + else + julia --project=. /QEDjl/.ci/SetupDevEnv/src/SetupDevEnv.jl ${CI_PROJECT_DIR}/Project.toml + fi + - julia --project=. -e 'import Pkg; Pkg.instantiate()' + - julia --project=. -e 'import Pkg; Pkg.test(; coverage = true)' + interruptible: true + tags: + - cpuonly + +unit_tests_releases: + extends: .untit_test_template + parallel: + matrix: + - JULIA_VERSION: ["1.6", "1.7", "1.8", "1.9"] + image: julia:$JULIA_VERSION + +unit_tests_nightly: + extends: .untit_test_template + # use the same baseimage like the official julia images + image: debian:bookworm-slim + variables: + # path where julia tar bal should be downloaded + JULIA_DONWLOAD: /julia/download + # path where julia should be extracted + JULIA_EXTRACT: /julia/extract + before_script: + - apt update && apt install -y wget + - mkdir -p $JULIA_DONWLOAD + - mkdir -p $JULIA_EXTRACT + - > + if [[ $CI_RUNNER_EXECUTABLE_ARCH == "linux/arm64" ]]; then + wget https://julialangnightlies-s3.julialang.org/bin/linux/aarch64/julia-latest-linux-aarch64.tar.gz -O $JULIA_DONWLOAD/julia-nightly.tar.gz + elif [[ $CI_RUNNER_EXECUTABLE_ARCH == "linux/amd64" ]]; then + wget https://julialangnightlies-s3.julialang.org/bin/linux/x86_64/julia-latest-linux-x86_64.tar.gz -O $JULIA_DONWLOAD/julia-nightly.tar.gz + else + echo "unknown runner architecture -> $CI_RUNNER_EXECUTABLE_ARCH" + exit 1 + fi + - tar -xf $JULIA_DONWLOAD/julia-nightly.tar.gz -C $JULIA_EXTRACT + # we need to search for the julia base folder name, because the second part of the name is the git commit hash + # e.g. julia-b0c6781676f + - JULIA_EXTRACT_FOLDER=${JULIA_EXTRACT}/$(ls $JULIA_EXTRACT | grep -m1 julia) + # copy everything to /usr to make julia public available + # mv is not possible, because it cannot merge folder + - cp -r $JULIA_EXTRACT_FOLDER/* /usr + allow_failure: true + tags: + - cpuonly + +generate_integration_tests: + image: julia:1.9 + stage: generate_integration_test + script: + # extract package name + - export CI_DEPENDENCY_NAME=$(cat $CI_PROJECT_DIR/Project.toml | grep name | awk '{ print $3 }' | tr -d '"') + - echo "CI_DEPENDENCY_NAME -> $CI_DEPENDENCY_NAME" + - apt update && apt install -y git + - git clone --depth 1 -b dev https://github.com/QEDjl-project/QED.jl.git /QEDjl + - cd /QEDjl/.ci/integTestGen/ + # use local registry of the QED project + - julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/QEDjl-project/registry.git"));' + # needs to add General registry again, if local registry was added + - julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/JuliaRegistries/General"));' + - julia --project=. -e 'import Pkg; Pkg.instantiate()' + # paths of artifacts are relative to CI_PROJECT_DIR + - > + if [[ $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_REF_NAME == "dev" ]]; then + # set name of the commit message from CI_COMMIT_MESSAGE to NO_MESSAGE, that the script does not read accidentally custom packages from the commit message of a merge commit + julia --project=. src/integTestGen.jl NO_MESSAGE > $CI_PROJECT_DIR/integrationjobs.yaml + else + julia --project=. src/integTestGen.jl > $CI_PROJECT_DIR/integrationjobs.yaml + fi + - cat $CI_PROJECT_DIR/integrationjobs.yaml + artifacts: + paths: + - integrationjobs.yaml + expire_in: 1 week + interruptible: true + tags: + - cpuonly + +run_integration_tests: + stage: run_integration_test + trigger: + include: + - artifact: integrationjobs.yaml + job: generate_integration_tests + strategy: depend + +verify-unit-test-deps_julia1.9: + image: julia:1.9 + stage: verify-unit-test-deps + script: + - apt update && apt install -y git + - git clone --depth 1 -b dev https://github.com/QEDjl-project/QED.jl.git /QEDjl + - > + if [[ $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_REF_NAME == "dev" ]]; then + # does not check for custom package URLs on the main and dev branch + echo "no custom package URL check necessary" + else + julia /QEDjl/.ci/verify_env.jl + fi + interruptible: true + tags: + - cpuonly diff --git a/src/QEDcore.jl b/src/QEDcore.jl index c2f5cc7..e44697d 100644 --- a/src/QEDcore.jl +++ b/src/QEDcore.jl @@ -2,4 +2,8 @@ module QEDcore # Write your package code here. +function greet(x) + return "Hello $x" +end + end diff --git a/test/runtests.jl b/test/runtests.jl index 2290068..cf60087 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,5 +2,7 @@ using QEDcore using Test @testset "QEDcore.jl" begin - # Write your tests here. + @testset "dummy" begin + @test QEDcore.greet("World!") == "Hello World!" + end end From 2c161c19bda447e736e99e269117ed4df9f28902 Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Mon, 10 Jun 2024 14:56:54 +0200 Subject: [PATCH 2/3] removed integration test --- .gitlab-ci.yml | 60 -------------------------------------------------- 1 file changed, 60 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e67fab7..5b8b321 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,5 @@ stages: - unit-test - - generate_integration_test - - run_integration_test - - verify-unit-test-deps .untit_test_template: stage: unit-test @@ -61,60 +58,3 @@ unit_tests_nightly: allow_failure: true tags: - cpuonly - -generate_integration_tests: - image: julia:1.9 - stage: generate_integration_test - script: - # extract package name - - export CI_DEPENDENCY_NAME=$(cat $CI_PROJECT_DIR/Project.toml | grep name | awk '{ print $3 }' | tr -d '"') - - echo "CI_DEPENDENCY_NAME -> $CI_DEPENDENCY_NAME" - - apt update && apt install -y git - - git clone --depth 1 -b dev https://github.com/QEDjl-project/QED.jl.git /QEDjl - - cd /QEDjl/.ci/integTestGen/ - # use local registry of the QED project - - julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/QEDjl-project/registry.git"));' - # needs to add General registry again, if local registry was added - - julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/JuliaRegistries/General"));' - - julia --project=. -e 'import Pkg; Pkg.instantiate()' - # paths of artifacts are relative to CI_PROJECT_DIR - - > - if [[ $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_REF_NAME == "dev" ]]; then - # set name of the commit message from CI_COMMIT_MESSAGE to NO_MESSAGE, that the script does not read accidentally custom packages from the commit message of a merge commit - julia --project=. src/integTestGen.jl NO_MESSAGE > $CI_PROJECT_DIR/integrationjobs.yaml - else - julia --project=. src/integTestGen.jl > $CI_PROJECT_DIR/integrationjobs.yaml - fi - - cat $CI_PROJECT_DIR/integrationjobs.yaml - artifacts: - paths: - - integrationjobs.yaml - expire_in: 1 week - interruptible: true - tags: - - cpuonly - -run_integration_tests: - stage: run_integration_test - trigger: - include: - - artifact: integrationjobs.yaml - job: generate_integration_tests - strategy: depend - -verify-unit-test-deps_julia1.9: - image: julia:1.9 - stage: verify-unit-test-deps - script: - - apt update && apt install -y git - - git clone --depth 1 -b dev https://github.com/QEDjl-project/QED.jl.git /QEDjl - - > - if [[ $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_REF_NAME == "dev" ]]; then - # does not check for custom package URLs on the main and dev branch - echo "no custom package URL check necessary" - else - julia /QEDjl/.ci/verify_env.jl - fi - interruptible: true - tags: - - cpuonly From 42a179e8f92e7e5038b144395bdd1ac8e8fe21ef Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Mon, 10 Jun 2024 14:59:23 +0200 Subject: [PATCH 3/3] fixed ci, added 1.10 to tested julia versions --- .gitlab-ci.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5b8b321..d24301b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,14 +5,6 @@ stages: stage: unit-test script: - apt update && apt install -y git - - git clone --depth 1 -b dev https://github.com/QEDjl-project/QED.jl.git /QEDjl - - > - if [[ $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_REF_NAME == "dev" ]]; then - # set name of the commit message from CI_COMMIT_MESSAGE to NO_MESSAGE, that the script does not read accidentally custom packages from the commit message of a merge commit - julia --project=. /QEDjl/.ci/SetupDevEnv/src/SetupDevEnv.jl ${CI_PROJECT_DIR}/Project.toml NO_MESSAGE - else - julia --project=. /QEDjl/.ci/SetupDevEnv/src/SetupDevEnv.jl ${CI_PROJECT_DIR}/Project.toml - fi - julia --project=. -e 'import Pkg; Pkg.instantiate()' - julia --project=. -e 'import Pkg; Pkg.test(; coverage = true)' interruptible: true @@ -23,7 +15,7 @@ unit_tests_releases: extends: .untit_test_template parallel: matrix: - - JULIA_VERSION: ["1.6", "1.7", "1.8", "1.9"] + - JULIA_VERSION: ["1.6", "1.7", "1.8", "1.9", "1.10"] image: julia:$JULIA_VERSION unit_tests_nightly: