From b6fb9b87846da9088e53946083be91caea0602e9 Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Thu, 7 Aug 2025 16:56:29 +0200 Subject: [PATCH 01/24] first CI commit --- .gitlab-ci.yml | 27 ++++++++++++++++++++++++++ dev_requirements.txt | 4 ++-- tests/analyze_tests.py | 43 ++++++++++++++++++++++++++++++++++++++++++ tests/ci.yml | 24 +++++++++++++++++++++++ 4 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 tests/analyze_tests.py create mode 100644 tests/ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..28d8244c --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,27 @@ +stages: + - generate + - trigger + - test + +generator: + stage: generate + image: python:3.8-alpine + tags: + - k8s-default + before_script: + - pip install pyyaml + script: + - cd test/pytest + - python analyze_tests.py + artifacts: + paths: + - test/pytests.yml + +pytests: + stage: trigger + trigger: + include: + - local: test/ci.yml + - artifact: test/pytests.yml + job: generator + strategy: depend \ No newline at end of file diff --git a/dev_requirements.txt b/dev_requirements.txt index 00c27859..c83726d5 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -3,7 +3,7 @@ onnxruntime scipy onnxmltools scikit-learn -xgboost<2.0.0 -pybind11 +xgboost<3.0.0 +pybind11<3.0.0 ydf pandas diff --git a/tests/analyze_tests.py b/tests/analyze_tests.py new file mode 100644 index 00000000..de9bb41f --- /dev/null +++ b/tests/analyze_tests.py @@ -0,0 +1,43 @@ +from pathlib import Path +import yaml + +template = ''' +pytest.{}: + extends: .pytest + image: {} + variables: + PYTESTFILE: {} +''' + +images = {'build' : 'registry.cern.ch/ci4fpga/vivado:2024.1', + 'no build' : 'registry.cern.ch/ci4fpga/ubuntu'} + +# check whether "build" method is called in the test -> needs different resources +def calls_build(test_filename): + with open(test_filename) as f: + content = f.read() + return '.build(' in content + +def generate_test_yaml(directory='.'): + # List of test files to scan + test_dir = Path(directory) + test_files = list(test_dir.glob("test_*.py")) + + yml = None + + for test_file in test_files: + file_name = str(test_file) + name = file_name.replace('test_', '').replace('.py', '') + build = 'build' if calls_build(test_file) else 'no build' + test_yml = yaml.safe_load(template.format(name, build, test_file)) + if yml is None: + yml = test_yml + else: + yml.update(test_yml) + + return yml + +if __name__ == '__main__': + yml = generate_test_yaml(Path(__file__).parent) + with open('pytests.yml', 'w') as yamlfile: + yaml.safe_dump(yml, yamlfile) \ No newline at end of file diff --git a/tests/ci.yml b/tests/ci.yml new file mode 100644 index 00000000..b53f2daf --- /dev/null +++ b/tests/ci.yml @@ -0,0 +1,24 @@ +.pytest: + stage: test + #image: registry.cern.ch/ci4fpga/vivado:2024.1 + tags: + - fpga-mid + before_script: + - # install g++ + - # apt update + - # apt install -y build-essential + - # setup conifer external requirements + - git clone --depth 1 --branch v3.12.0 https://github.com/nlohmann/json.git + - export JSON_ROOT=$(pwd)/json/single_include/ + - git clone --depth 1 https://github.com/Xilinx/HLS_arbitrary_Precision_Types.git + - export XILINX_AP_INCLUDE=$(pwd)/HLS_arbitrary_Precision_Types/include + - # setup test python environment + - pip install -r dev_requirements.txt + - pip install . + script: + - cd tests + - pytest $PYTESTFILE -rA + artifacts: + when: always + paths: + - tests/prj* \ No newline at end of file From 67aa717e060a216e3323676c33294b90d5b6f33f Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Thu, 7 Aug 2025 16:59:29 +0200 Subject: [PATCH 02/24] Fix tests path for CI generator job --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 28d8244c..e50fab9b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,17 +11,17 @@ generator: before_script: - pip install pyyaml script: - - cd test/pytest + - cd tests - python analyze_tests.py artifacts: paths: - - test/pytests.yml + - tests/pytests.yml pytests: stage: trigger trigger: include: - - local: test/ci.yml - - artifact: test/pytests.yml + - local: tests/ci.yml + - artifact: tests/pytests.yml job: generator strategy: depend \ No newline at end of file From f20b429b0c6f26e350bd75f877b772ca533663dc Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Thu, 7 Aug 2025 17:04:54 +0200 Subject: [PATCH 03/24] Fix image selection --- tests/analyze_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/analyze_tests.py b/tests/analyze_tests.py index de9bb41f..8e1d13f2 100644 --- a/tests/analyze_tests.py +++ b/tests/analyze_tests.py @@ -29,7 +29,7 @@ def generate_test_yaml(directory='.'): file_name = str(test_file) name = file_name.replace('test_', '').replace('.py', '') build = 'build' if calls_build(test_file) else 'no build' - test_yml = yaml.safe_load(template.format(name, build, test_file)) + test_yml = yaml.safe_load(template.format(name, images[build], test_file)) if yml is None: yml = test_yml else: From a14a87b48910bcd91698fa59405ea2d143e0dc54 Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Thu, 7 Aug 2025 17:13:41 +0200 Subject: [PATCH 04/24] Try fixing before_script --- tests/ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/ci.yml b/tests/ci.yml index b53f2daf..a9eb6ec1 100644 --- a/tests/ci.yml +++ b/tests/ci.yml @@ -4,15 +4,10 @@ tags: - fpga-mid before_script: - - # install g++ - - # apt update - - # apt install -y build-essential - - # setup conifer external requirements - git clone --depth 1 --branch v3.12.0 https://github.com/nlohmann/json.git - export JSON_ROOT=$(pwd)/json/single_include/ - git clone --depth 1 https://github.com/Xilinx/HLS_arbitrary_Precision_Types.git - export XILINX_AP_INCLUDE=$(pwd)/HLS_arbitrary_Precision_Types/include - - # setup test python environment - pip install -r dev_requirements.txt - pip install . script: From 661c007f3809100fe49bee1bf831de84a0e493ff Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Fri, 8 Aug 2025 20:28:09 +0200 Subject: [PATCH 05/24] Different approach to targeting ci4fpga or generic runners --- tests/analyze_tests.py | 19 +++++++++---------- tests/ci.yml | 31 +++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/tests/analyze_tests.py b/tests/analyze_tests.py index 8e1d13f2..888db0d0 100644 --- a/tests/analyze_tests.py +++ b/tests/analyze_tests.py @@ -2,16 +2,12 @@ import yaml template = ''' -pytest.{}: - extends: .pytest - image: {} - variables: - PYTESTFILE: {} +pytest.{name}: + extends: .pytest-{extends} + variables: + PYTESTFILE: {test_file} ''' -images = {'build' : 'registry.cern.ch/ci4fpga/vivado:2024.1', - 'no build' : 'registry.cern.ch/ci4fpga/ubuntu'} - # check whether "build" method is called in the test -> needs different resources def calls_build(test_filename): with open(test_filename) as f: @@ -28,8 +24,11 @@ def generate_test_yaml(directory='.'): for test_file in test_files: file_name = str(test_file) name = file_name.replace('test_', '').replace('.py', '') - build = 'build' if calls_build(test_file) else 'no build' - test_yml = yaml.safe_load(template.format(name, images[build], test_file)) + build = calls_build(test_file) + extends = 'fpga' if build else 'plain' + test_yml = yaml.safe_load(template.format(name=name, + extends=extends, + test_file=test_file)) if yml is None: yml = test_yml else: diff --git a/tests/ci.yml b/tests/ci.yml index a9eb6ec1..5d9ac8e4 100644 --- a/tests/ci.yml +++ b/tests/ci.yml @@ -1,8 +1,7 @@ -.pytest: - stage: test - #image: registry.cern.ch/ci4fpga/vivado:2024.1 - tags: - - fpga-mid +.snippets: + mambaforge_setup: + - apt update + - apt install build-essential before_script: - git clone --depth 1 --branch v3.12.0 https://github.com/nlohmann/json.git - export JSON_ROOT=$(pwd)/json/single_include/ @@ -10,10 +9,30 @@ - export XILINX_AP_INCLUDE=$(pwd)/HLS_arbitrary_Precision_Types/include - pip install -r dev_requirements.txt - pip install . + +.pytest: + stage: test script: - cd tests - pytest $PYTESTFILE -rA artifacts: when: always paths: - - tests/prj* \ No newline at end of file + - tests/prj* + +.pytest-plain: + extends: .pytest + image: condaforge/mambaforge + tags: + - k8s-default + before_script: + - !reference [.snippets, mambaforge_setup] + - !reference [.snippets, before_script] + +.pytest-fpga: + extends: .pytest + image: registry.cern.ch/ci4fpga/vivado:2024.1 + tags: + - fpga-mid + before_script: + - !reference [.snippets, before_script] \ No newline at end of file From fe666fad68376d9283fdd7d6e673dbccb498495d Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Fri, 8 Aug 2025 20:32:23 +0200 Subject: [PATCH 06/24] Fix syntax in apt install --- tests/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ci.yml b/tests/ci.yml index 5d9ac8e4..264a0654 100644 --- a/tests/ci.yml +++ b/tests/ci.yml @@ -1,7 +1,7 @@ .snippets: mambaforge_setup: - apt update - - apt install build-essential + - apt -y install build-essential before_script: - git clone --depth 1 --branch v3.12.0 https://github.com/nlohmann/json.git - export JSON_ROOT=$(pwd)/json/single_include/ From 3ab37b420fe80db0bbc04dc67096895b64f87ea7 Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Fri, 8 Aug 2025 20:41:24 +0200 Subject: [PATCH 07/24] Add skl2onnx to dev_requirements.txt --- dev_requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev_requirements.txt b/dev_requirements.txt index c83726d5..4a2cff9a 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -3,6 +3,7 @@ onnxruntime scipy onnxmltools scikit-learn +skl2onnx xgboost<3.0.0 pybind11<3.0.0 ydf From c8d20214a3e2bd3b92c852419bcf4269d22d7835 Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Fri, 8 Aug 2025 21:16:52 +0200 Subject: [PATCH 08/24] override extends and allow some jobs to fail --- tests/analyze_tests.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/analyze_tests.py b/tests/analyze_tests.py index 888db0d0..fc9f11d7 100644 --- a/tests/analyze_tests.py +++ b/tests/analyze_tests.py @@ -6,8 +6,15 @@ extends: .pytest-{extends} variables: PYTESTFILE: {test_file} + allow_failure: {allow_failure} ''' +# override the auto detection of which script to extend for the following jobs +extends_override = {'backends' : 'fpga'} + +# allow the following jobs to fail +allow_failure = ['backends', 'xgb_converter', 'onnx_to_hls'] + # check whether "build" method is called in the test -> needs different resources def calls_build(test_filename): with open(test_filename) as f: @@ -26,9 +33,13 @@ def generate_test_yaml(directory='.'): name = file_name.replace('test_', '').replace('.py', '') build = calls_build(test_file) extends = 'fpga' if build else 'plain' + if name in extends_override.keys(): + extends = extends_override[name] + allow_fail = 'True' if name in allow_failure else 'False' test_yml = yaml.safe_load(template.format(name=name, extends=extends, - test_file=test_file)) + test_file=test_file, + allow_failure=allow_fail)) if yml is None: yml = test_yml else: From e0eade8d67f5ffbfa0ad47797c7f413725c33adb Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Thu, 14 Aug 2025 14:46:31 +0200 Subject: [PATCH 09/24] Cause tests to fail when errors are logged in logging --- tests/conftest.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index bb67fec6..aacd386d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,2 +1,9 @@ import pytest -from tests.util import train_skl, hls_convert, vhdl_convert, predict \ No newline at end of file +import logging +from tests.util import train_skl, hls_convert, vhdl_convert, predict + +@pytest.fixture(autouse=True) +def no_logs_gte_error(caplog): + yield + errors = [record for record in caplog.get_records('call') if record.levelno >= logging.ERROR] + assert not errors \ No newline at end of file From 5fd60845c38eada02e97b2328ccdbc31eac01120 Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Thu, 14 Aug 2025 16:06:31 +0200 Subject: [PATCH 10/24] Use a GHDL image instead of mambaforge (easier to install mamba in GHDL image than vice versa) --- tests/ci.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/ci.yml b/tests/ci.yml index 264a0654..6f98ef60 100644 --- a/tests/ci.yml +++ b/tests/ci.yml @@ -1,7 +1,11 @@ .snippets: - mambaforge_setup: + ghdl_docker_setup: - apt update - - apt -y install build-essential + - apt install -y build-essential wget git ca-certificates + - wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" + - bash Miniforge3.sh -b -p "${HOME}/conda" + - source "${HOME}/conda/etc/profile.d/mamba.sh" + - mamba activate before_script: - git clone --depth 1 --branch v3.12.0 https://github.com/nlohmann/json.git - export JSON_ROOT=$(pwd)/json/single_include/ @@ -22,11 +26,11 @@ .pytest-plain: extends: .pytest - image: condaforge/mambaforge + image: ghdl/ghdl:6.0.0-dev-gcc-ubuntu-22.04 tags: - k8s-default before_script: - - !reference [.snippets, mambaforge_setup] + - !reference [.snippets, ghdl_docker_setup] - !reference [.snippets, before_script] .pytest-fpga: From 9b7f7b98ad85bfde0bd83fe13c58c88ce02c70fe Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Mon, 18 Aug 2025 17:28:24 +0200 Subject: [PATCH 11/24] build a docker image, and conditionally upload it to the registry, in CI --- .gitlab-ci.yml | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 25 +++++++++++++++++++++++ tests/ci.yml | 13 +++--------- 3 files changed, 82 insertions(+), 10 deletions(-) create mode 100644 Dockerfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e50fab9b..0844d8a8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,62 @@ stages: + - build + - publish - generate - trigger - test +# Build commit SHA image +build-image: + stage: build + image: + name: gcr.io/kaniko-project/executor:debug + entrypoint: [""] + variables: + IMAGE_SHA: $CI_REGISTRY_IMAGE/conifer:$CI_COMMIT_SHA + script: + # Auth for Kaniko + - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json + # Build & push SHA-tagged image + - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $IMAGE_SHA + - echo "Image pushed as $IMAGE_SHA" + rules: + - changes: + - Dockerfile + - dev_requirements.txt + +.publish-image: + stage: publish + image: quay.io/skopeo/stable + script: + - export SRC="$CI_REGISTRY_IMAGE/conifer:$CI_COMMIT_SHA" + - export DEST="$CI_REGISTRY_IMAGE/conifer:$IMAGE_VERSION" + - | + skopeo copy \ + --src-creds "$CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD" \ + --dest-creds "$CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD" \ + docker://"$SRC" docker://"$DEST" + needs: + - job: build-image + optional: true + +publish-image-latest: + extends: .publish-image + variables: + IMAGE_VERSION: latest + rules: + - if: '$CI_COMMIT_BRANCH == "master"' + changes: + - Dockerfile + - dev_requirements.txt + - if: $CI_COMMIT_TAG + +publish-image-tag: + extends: .publish-image + variables: + IMAGE_VERSION: $CI_COMMIT_TAG + rules: + - if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+$/' + generator: stage: generate image: python:3.8-alpine diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..109c39b9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM ghdl/ghdl:6.0.0-dev-gcc-ubuntu-22.04 +LABEL maintainer=sioni@cern.ch +RUN apt update && \ + apt install -y build-essential wget git ca-certificates && \ + useradd --create-home --shell /bin/bash conifer +# Add Tini +ENV TINI_VERSION=v0.19.0 +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +RUN chmod +x /tini +ENTRYPOINT ["/tini", "--"] +USER conifer +ENV WORKDIR=/home/conifer +WORKDIR $WORKDIR +COPY dev_requirements.txt . +RUN wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" && \ + bash Miniforge3.sh -b -p "${HOME}/conda" && \ + source "${HOME}/conda/etc/profile.d/mamba.sh" && \ + mamba activate && \ + mamba shell init && \ + pip install -r dev_requirements.txt && \ + git clone --depth 1 --branch v3.12.0 https://github.com/nlohmann/json.git && \ + git clone --depth 1 https://github.com/Xilinx/HLS_arbitrary_Precision_Types.git +ENV JSON_ROOT=${WORKDIR}/json/single_include +ENV XILINX_AP_INCLUDE=${WORKDIR}/HLS_arbitrary_Precision_Types/include +CMD ["/bin/bash"] \ No newline at end of file diff --git a/tests/ci.yml b/tests/ci.yml index 6f98ef60..31a66def 100644 --- a/tests/ci.yml +++ b/tests/ci.yml @@ -1,16 +1,10 @@ .snippets: - ghdl_docker_setup: - - apt update - - apt install -y build-essential wget git ca-certificates - - wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" - - bash Miniforge3.sh -b -p "${HOME}/conda" - - source "${HOME}/conda/etc/profile.d/mamba.sh" - - mamba activate before_script: - git clone --depth 1 --branch v3.12.0 https://github.com/nlohmann/json.git - export JSON_ROOT=$(pwd)/json/single_include/ - git clone --depth 1 https://github.com/Xilinx/HLS_arbitrary_Precision_Types.git - export XILINX_AP_INCLUDE=$(pwd)/HLS_arbitrary_Precision_Types/include + - pip uninstall -y conifer - pip install -r dev_requirements.txt - pip install . @@ -26,12 +20,11 @@ .pytest-plain: extends: .pytest - image: ghdl/ghdl:6.0.0-dev-gcc-ubuntu-22.04 + image: gitlab-registry.cern.ch/ssummers/conifer:latest tags: - k8s-default before_script: - - !reference [.snippets, ghdl_docker_setup] - - !reference [.snippets, before_script] + - pip uninstall -y conifer .pytest-fpga: extends: .pytest From 55be28af21a587ea57a956f92746b67aaa0d1671 Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Mon, 18 Aug 2025 17:40:09 +0200 Subject: [PATCH 12/24] Install conifer into the Dockerfile environment --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 109c39b9..7638d995 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ ENTRYPOINT ["/tini", "--"] USER conifer ENV WORKDIR=/home/conifer WORKDIR $WORKDIR -COPY dev_requirements.txt . +COPY . . RUN wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" && \ bash Miniforge3.sh -b -p "${HOME}/conda" && \ source "${HOME}/conda/etc/profile.d/mamba.sh" && \ @@ -19,7 +19,8 @@ RUN wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/lat mamba shell init && \ pip install -r dev_requirements.txt && \ git clone --depth 1 --branch v3.12.0 https://github.com/nlohmann/json.git && \ - git clone --depth 1 https://github.com/Xilinx/HLS_arbitrary_Precision_Types.git + git clone --depth 1 https://github.com/Xilinx/HLS_arbitrary_Precision_Types.git && \ + pip install . ENV JSON_ROOT=${WORKDIR}/json/single_include ENV XILINX_AP_INCLUDE=${WORKDIR}/HLS_arbitrary_Precision_Types/include CMD ["/bin/bash"] \ No newline at end of file From e28626b077250b3263b81207910e4fbab08d238d Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Mon, 18 Aug 2025 17:40:43 +0200 Subject: [PATCH 13/24] Change conifer image destination path --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0844d8a8..2cf23a17 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,7 +12,7 @@ build-image: name: gcr.io/kaniko-project/executor:debug entrypoint: [""] variables: - IMAGE_SHA: $CI_REGISTRY_IMAGE/conifer:$CI_COMMIT_SHA + IMAGE_SHA: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA script: # Auth for Kaniko - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json @@ -28,8 +28,8 @@ build-image: stage: publish image: quay.io/skopeo/stable script: - - export SRC="$CI_REGISTRY_IMAGE/conifer:$CI_COMMIT_SHA" - - export DEST="$CI_REGISTRY_IMAGE/conifer:$IMAGE_VERSION" + - export SRC="$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA" + - export DEST="$CI_REGISTRY_IMAGE:$IMAGE_VERSION" - | skopeo copy \ --src-creds "$CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD" \ From ad132b8ab62428f13378819aa09456fa8847fbd3 Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Mon, 18 Aug 2025 17:41:06 +0200 Subject: [PATCH 14/24] Reinstall conifer in CI job --- tests/ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/ci.yml b/tests/ci.yml index 31a66def..eb6f0cb5 100644 --- a/tests/ci.yml +++ b/tests/ci.yml @@ -4,8 +4,9 @@ - export JSON_ROOT=$(pwd)/json/single_include/ - git clone --depth 1 https://github.com/Xilinx/HLS_arbitrary_Precision_Types.git - export XILINX_AP_INCLUDE=$(pwd)/HLS_arbitrary_Precision_Types/include - - pip uninstall -y conifer - pip install -r dev_requirements.txt + conifer_reinstall: + - pip uninstall -y conifer - pip install . .pytest: @@ -24,7 +25,7 @@ tags: - k8s-default before_script: - - pip uninstall -y conifer + - !reference [.snippets, conifer_reinstall] .pytest-fpga: extends: .pytest @@ -32,4 +33,5 @@ tags: - fpga-mid before_script: - - !reference [.snippets, before_script] \ No newline at end of file + - !reference [.snippets, before_script] + - !reference [.snippets, conifer_reinstall] \ No newline at end of file From f58247abc81ca33cb15b83362e405e5b61bcaf9d Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Tue, 19 Aug 2025 14:27:37 +0200 Subject: [PATCH 15/24] Propagate the conifer docker image tag through the pipeline in order to use the correct image for the .pytest-plain jobs --- .gitlab-ci.yml | 22 ++++++++++++++++++++++ tests/ci.yml | 7 ++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2cf23a17..a4b0cc76 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,6 +19,8 @@ build-image: # Build & push SHA-tagged image - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $IMAGE_SHA - echo "Image pushed as $IMAGE_SHA" + # leave some trace that the image was built + - echo '$IMAGE_SHA' > build-image.txt rules: - changes: - Dockerfile @@ -57,6 +59,26 @@ publish-image-tag: rules: - if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+$/' +# set the image tag to use based on whether build-image ran or not +# - build-image ran: use the commit SHA +# - build-image didn't run: use "latest" +set-image-tag: + stage: publish + script: + - if [[ -s "build-image.txt" ]]; then + echo "IMAGE_TAG=$CI_COMMIT_SHA" > image.env; + else + echo "IMAGE_TAG=latest" > image.env; + fi + artifacts: + reports: + dotenv: image.env + rules: + - when: always + needs: + - job: build-image + optional: true + generator: stage: generate image: python:3.8-alpine diff --git a/tests/ci.yml b/tests/ci.yml index eb6f0cb5..79005837 100644 --- a/tests/ci.yml +++ b/tests/ci.yml @@ -18,10 +18,15 @@ when: always paths: - tests/prj* + rules: + - when: always +# the $IMAGE_TAG is provided by set-image-tag job .pytest-plain: extends: .pytest - image: gitlab-registry.cern.ch/ssummers/conifer:latest + image: $CI_REGISTRY_IMAGE:$IMAGE_TAG + needs: + - set-image-tag tags: - k8s-default before_script: From cf0eb6cc261380217cf9b74fed328a073cc08872 Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Thu, 21 Aug 2025 13:09:00 +0200 Subject: [PATCH 16/24] Propagate the variable from parent to child pipeline --- .gitlab-ci.yml | 4 +++- tests/ci.yml | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a4b0cc76..c5177be4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -100,4 +100,6 @@ pytests: - local: tests/ci.yml - artifact: tests/pytests.yml job: generator - strategy: depend \ No newline at end of file + strategy: depend + variables: + PARENT_PIPELINE_ID: $CI_PIPELINE_ID \ No newline at end of file diff --git a/tests/ci.yml b/tests/ci.yml index 79005837..a411effc 100644 --- a/tests/ci.yml +++ b/tests/ci.yml @@ -26,7 +26,8 @@ extends: .pytest image: $CI_REGISTRY_IMAGE:$IMAGE_TAG needs: - - set-image-tag + - pipeline: $PARENT_PIPELINE_ID + job: set-image-tag tags: - k8s-default before_script: From 89234ebae9caa591cb0a7d1c4701be4e47cb23d2 Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Thu, 21 Aug 2025 13:50:17 +0200 Subject: [PATCH 17/24] Add a dummy commit to docker file to trigger a build --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7638d995..f1fd5c89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,4 +23,4 @@ RUN wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/lat pip install . ENV JSON_ROOT=${WORKDIR}/json/single_include ENV XILINX_AP_INCLUDE=${WORKDIR}/HLS_arbitrary_Precision_Types/include -CMD ["/bin/bash"] \ No newline at end of file +CMD ["/bin/bash"] From 5063c8d0dde581bb3252260cd6f52239977865cd Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Thu, 21 Aug 2025 13:50:30 +0200 Subject: [PATCH 18/24] Print the conifer version in the before script --- tests/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ci.yml b/tests/ci.yml index a411effc..ebc02007 100644 --- a/tests/ci.yml +++ b/tests/ci.yml @@ -8,6 +8,7 @@ conifer_reinstall: - pip uninstall -y conifer - pip install . + - pip show conifer .pytest: stage: test From 13910ba88bb72a28b07b900c02d682578a2803d0 Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Thu, 21 Aug 2025 14:05:55 +0200 Subject: [PATCH 19/24] Add a dummy commit to docker file to trigger a build --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f1fd5c89..7638d995 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,4 +23,4 @@ RUN wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/lat pip install . ENV JSON_ROOT=${WORKDIR}/json/single_include ENV XILINX_AP_INCLUDE=${WORKDIR}/HLS_arbitrary_Precision_Types/include -CMD ["/bin/bash"] +CMD ["/bin/bash"] \ No newline at end of file From 5f0b8da9716fd1141092a35d852bcb3b74c6b9b8 Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Thu, 21 Aug 2025 14:06:07 +0200 Subject: [PATCH 20/24] Fix to propagating image tag through pipeline --- .gitlab-ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c5177be4..46647d2b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,11 +20,15 @@ build-image: - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $IMAGE_SHA - echo "Image pushed as $IMAGE_SHA" # leave some trace that the image was built - - echo '$IMAGE_SHA' > build-image.txt + - echo '$IMAGE_SHA' | tee build-image.txt rules: - changes: - Dockerfile - dev_requirements.txt + artifacts: + paths: + - build-image.txt + .publish-image: stage: publish From b64915328b743c953cac0e5b6400d8f66487b621 Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Thu, 21 Aug 2025 14:33:26 +0200 Subject: [PATCH 21/24] Use tee to print the image tag to job log --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 46647d2b..91cf38a1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -70,9 +70,9 @@ set-image-tag: stage: publish script: - if [[ -s "build-image.txt" ]]; then - echo "IMAGE_TAG=$CI_COMMIT_SHA" > image.env; + echo "IMAGE_TAG=$CI_COMMIT_SHA" | tee image.env; else - echo "IMAGE_TAG=latest" > image.env; + echo "IMAGE_TAG=latest" | tee image.env; fi artifacts: reports: From 626b7fc993b89b8db67ce67f955426939ff2491f Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Thu, 21 Aug 2025 14:33:42 +0200 Subject: [PATCH 22/24] Move conifer reinstall to test script --- tests/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/ci.yml b/tests/ci.yml index ebc02007..52b5cf31 100644 --- a/tests/ci.yml +++ b/tests/ci.yml @@ -13,6 +13,7 @@ .pytest: stage: test script: + - !reference [.snippets, conifer_reinstall] - cd tests - pytest $PYTESTFILE -rA artifacts: @@ -31,8 +32,6 @@ job: set-image-tag tags: - k8s-default - before_script: - - !reference [.snippets, conifer_reinstall] .pytest-fpga: extends: .pytest @@ -40,5 +39,4 @@ tags: - fpga-mid before_script: - - !reference [.snippets, before_script] - - !reference [.snippets, conifer_reinstall] \ No newline at end of file + - !reference [.snippets, before_script] \ No newline at end of file From e483612ed7f5b19633d6ee7aea2d2fd9c5166110 Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Thu, 21 Aug 2025 15:18:41 +0200 Subject: [PATCH 23/24] Try including mamba in the environment, and reinstate conifer reinstall to the before_script --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 7638d995..d1d397f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,4 +23,5 @@ RUN wget -O Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/lat pip install . ENV JSON_ROOT=${WORKDIR}/json/single_include ENV XILINX_AP_INCLUDE=${WORKDIR}/HLS_arbitrary_Precision_Types/include +ENV PATH="${WORKDIR}/conda/bin:${PATH}" CMD ["/bin/bash"] \ No newline at end of file From 6c58f8782c0e415400c1dfb1bae9de4172033149 Mon Sep 17 00:00:00 2001 From: Sioni Summers <14807534+thesps@users.noreply.github.com> Date: Thu, 21 Aug 2025 15:51:40 +0200 Subject: [PATCH 24/24] Dummy update to gitlab-ci yml to run a pipeline with latest tag --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 91cf38a1..851e3a2c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -106,4 +106,5 @@ pytests: job: generator strategy: depend variables: - PARENT_PIPELINE_ID: $CI_PIPELINE_ID \ No newline at end of file + PARENT_PIPELINE_ID: $CI_PIPELINE_ID + \ No newline at end of file