diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 1468a17feb16940ae658d3ca6b885af7139ce3d8..14c3c1efc5b3974f6952b5ed439723c58b4627a5 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,3 +1,26 @@ +############################### +###### Temporary Image ######## +############################### +FROM debian:bookworm as git_base + +# Check for availability of DNS +RUN if getent hosts indiscale.com > /dev/null; \ + then echo "Connected to the internet and DNS available"; \ + else echo "No internet connection or DNS not available"; \ + fi + +COPY . /git + +# Delete .git because it is huge. +RUN rm -r /git/.git + +# Install pycaosdb.ini for the tests +RUN mv /git/.docker/tester_pycaosdb.ini /git/integrationtests/pycaosdb.ini + +############################### +###### Main Image Build ####### +############################### + FROM debian:bookworm RUN apt-get update && \ apt-get install \ @@ -26,13 +49,8 @@ ADD https://gitlab.indiscale.com/api/v4/projects/104/repository/commits/${ADVANC advanced_version.json RUN git clone https://gitlab.indiscale.com/caosdb/src/caosdb-advanced-user-tools.git && \ cd caosdb-advanced-user-tools && git checkout ${ADVANCED} && pip3 install --break-system-packages .[h5-crawler] -COPY . /git - -# Delete .git because it is huge. -RUN rm -r /git/.git -# Install pycaosdb.ini for the tests -RUN mv /git/.docker/tester_pycaosdb.ini /git/integrationtests/pycaosdb.ini +COPY --from=git_base /git /git RUN cd /git/ && pip3 install --break-system-packages .[h5-crawler,spss,rocrate] diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e43223568252b2e7a1504610692fe20dc9d78348..f295e0b9480d56359ec1f1d30bc3be5bd54aea57 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -104,6 +104,27 @@ stages: CAOSDB_TAG=${REFTAG}; fi - echo $CAOSDB_TAG + - if [ -z "$PYLIB" ]; then + if echo "$CI_COMMIT_REF_NAME" | grep -c "^f-" ; then + echo "Check if pylib has branch $CI_COMMIT_REF_NAME" ; + if wget -O /dev/null https://gitlab.indiscale.com/api/v4/projects/97/repository/branches/${CI_COMMIT_REF_NAME}>/dev/null ; then + PYLIB=$CI_COMMIT_REF_NAME ; + fi; + fi; + fi; + - PYLIB=${PYLIB:-dev} + - echo $PYLIB + + - if [ -z "$ADVANCED" ]; then + if echo "$CI_COMMIT_REF_NAME" | grep -c "^f-" ; then + echo "Check if advanced user tools have branch $CI_COMMIT_REF_NAME" ; + if wget -O /dev/null https://gitlab.indiscale.com/api/v4/projects/104/repository/branches/${CI_COMMIT_REF_NAME} ; then + ADVANCED=$CI_COMMIT_REF_NAME ; + fi; + fi; + fi; + - ADVANCED=${ADVANCED:-dev} + - echo $ADVANCED info: tags: [cached-dind] @@ -113,47 +134,58 @@ info: script: - *env -unittest_py3.11: - tags: [cached-dind] - stage: test - image: $CI_REGISTRY_IMAGE - script: - - python3 -c "import sys; assert sys.version.startswith('3.11')" - - tox - unittest_py3.9: tags: [cached-dind] stage: test + variables: + PYVER: "3.9" image: python:3.9 script: &python_test_script # install dependencies + - *env - pip install pytest pytest-cov - # TODO: Use f-branch logic here - - pip install git+https://gitlab.indiscale.com/caosdb/src/caosdb-pylib.git@dev - - pip install git+https://gitlab.indiscale.com/caosdb/src/caosdb-advanced-user-tools.git@dev + - pip install git+https://gitlab.indiscale.com/caosdb/src/caosdb-pylib.git@${PYLIB} + - pip install git+https://gitlab.indiscale.com/caosdb/src/caosdb-advanced-user-tools.git@${ADVANCED} - pip install .[h5-crawler,spss,rocrate] + - echo "import sys; assert sys.version.startswith('$PYVER')" + - python3 -c "import sys; assert sys.version.startswith('$PYVER')" # actual test - caosdb-crawler --help - - pytest --cov=caosdb -vv ./unittests + - make unittest unittest_py3.10: - tags: [cached-dind] + variables: + PYVER: "3.10" stage: test + tags: [cached-dind] image: python:3.10 script: *python_test_script -unittest_py3.12: +unittest_py3.11: + variables: + PYVER: "3.11" tags: [cached-dind] stage: test + image: python:3.11 + script: *python_test_script + +unittest_py3.12: + variables: + PYVER: "3.12" + stage: test + tags: [cached-dind] image: python:3.12 script: *python_test_script unittest_py3.13: + variables: + PYVER: "3.13" tags: [cached-dind] stage: test image: python:3.13 script: *python_test_script + inttest: tags: [docker] services: @@ -170,6 +202,8 @@ inttest: - *env - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - echo $CAOSDB_TAG + - echo $PYLIB + - echo $ADVANCED - cd .docker # Store mariadb version @@ -231,34 +265,14 @@ build-testenv: - pushes needs: [] script: + - *env - df -h - command -v wget - - if [ -z "$PYLIB" ]; then - if echo "$CI_COMMIT_REF_NAME" | grep -c "^f-" ; then - echo "Check if pylib has branch $CI_COMMIT_REF_NAME" ; - if wget https://gitlab.indiscale.com/api/v4/projects/97/repository/branches/${CI_COMMIT_REF_NAME} ; then - PYLIB=$CI_COMMIT_REF_NAME ; - fi; - fi; - fi; - - PYLIB=${PYLIB:-dev} - - echo $PYLIB - - - if [ -z "$ADVANCED" ]; then - if echo "$CI_COMMIT_REF_NAME" | grep -c "^f-" ; then - echo "Check if advanced user tools have branch $CI_COMMIT_REF_NAME" ; - if wget https://gitlab.indiscale.com/api/v4/projects/104/repository/branches/${CI_COMMIT_REF_NAME} ; then - ADVANCED=$CI_COMMIT_REF_NAME ; - fi; - fi; - fi; - - ADVANCED=${ADVANCED:-dev} - - echo $ADVANCED - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY # use here general latest or specific branch latest... - docker build - --build-arg PYLIB=${PYLIB} + --build-arg PYLIB=${PYLIB:dev} --build-arg ADVANCED=${ADVANCED:dev} --file .docker/Dockerfile -t $CI_REGISTRY_IMAGE . diff --git a/Makefile b/Makefile index 95fc2bf61473b94decfb43d0c5ba0d3fda535a07..7167ebfdf106f5129ce7941706b9e871d51e551f 100644 --- a/Makefile +++ b/Makefile @@ -44,5 +44,5 @@ lint: .PHONY: lint unittest: - tox -r + pytest --cov=caoscrawler -vv ./unittests .PHONY: unittest diff --git a/tox.ini b/tox.ini index e003e26ecd16861c3b8a8d991fc789c78d203e5b..d44fbb6d50c58f44fe7944a2a49711b8def18cd6 100644 --- a/tox.ini +++ b/tox.ini @@ -6,9 +6,8 @@ skip_missing_interpreters = true deps = .[h5-crawler,spss,rocrate] pytest pytest-cov - # TODO: Make this f-branch sensitive - git+https://gitlab.indiscale.com/caosdb/src/caosdb-pylib.git@dev - git+https://gitlab.indiscale.com/caosdb/src/caosdb-advanced-user-tools.git@dev + linkahead + caosadvancedtools commands = caosdb-crawler --help py.test --cov=caoscrawler -vv {posargs}