From 81d22c8a2b57fdeb30b229b774683de8c92287da Mon Sep 17 00:00:00 2001 From: Christine Kim Date: Wed, 20 Sep 2023 11:41:54 -0700 Subject: [PATCH] Update pipeline to run tests --- .gitlab-ci.yml | 142 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 112 insertions(+), 30 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f55aac5..38fa5be 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,30 +1,112 @@ -image: ubuntu:18.04 - -clone_github: - stage: deploy - before_script: - - apt-get update -y && apt-get install openssh-client -y - - apt install git -y - - eval $(ssh-agent -s) - - echo "$GIT_SSH_PRIVATE_KEY" | openssl base64 -A -d | ssh-add - - - mkdir -p ~/.ssh - - chmod 700 ~/.ssh - - ssh-keyscan $GIT_LAB_HOST >> ~/.ssh/known_hosts - - chmod 644 ~/.ssh/known_hosts - - git config --global user.name "krodriguez" - - git config --global user.email "krodriguez@usgs.gov" - - ssh "git@$GIT_LAB_HOST" - script: - - echo $SOURCE_REPOSITORY - - git config --global http.sslVerify false - - rm -rf spiceql # Needed to allow multiple CI runs - - git config --global user.name "krodriguez" - - git config --global user.email "krodriguez@usgs.gov" - - git clone --mirror https://github.com/DOI-USGS/SpiceQL.git spiceql - - cd spiceql - - git remote remove origin - - git remote add origin $DESTINATION_REPOSITORY - - git push -f --prune --all - - git push -f --prune --tags - only: - - branches +image: continuumio/miniconda3:latest + +stages: # List of stages for jobs, and their order of execution + - build + - test + +variables: + SSPICE_DEBUG : y + +before_script: + - conda init bash + - source ~/.bashrc + +build-and-ctest: # This job runs in the build stage, which runs first. + variables: + SSPICE_DEBUG : y + BUILD_TYPE : Release + stage: build + tags: + - dind + script: + - ls $CI_PROJECT_DIR + - git config http.sslVerify "false" + - git config --global url."https://github.com/".insteadOf "git@github.com:" + - git config --global url."https://".insteadOf git:// + - GIT_SSL_NO_VERIFY=true git submodule update --init --recursive + - touch /etc/pip.conf + - echo -e "[global]\n + trusted-host = pypi.python.org\n + \tpypi.org\n + \tfiles.pythonhosted.org" >> /etc/pip.conf + - cat /etc/pip.conf + - SSL_NO_VERIFY=1 conda env create -f environment.yml --prefix $CI_PROJECT_DIR/env + - conda init bash + - source ~/.bashrc + - conda activate $CI_PROJECT_DIR/env + - SSL_NO_VERIFY=1 conda install make gcc_linux-64 gxx_linux-64 pthread-stubs + - conda info + - conda list + - cmake -E make_directory $CI_PROJECT_DIR/build + - cmake -E make_directory $CI_PROJECT_DIR/install + - cd $CI_PROJECT_DIR/build/ + - cmake $CI_PROJECT_DIR -DCSpice_DIR=$CONDA_PREFIX/lib/cmake/cspice/ -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSPICEQL_BUILD_DOCS=OFF -DCMAKE_INSTALL_PREFIX=$CI_PROJECT_DIR/install + - cmake --build . + - cmake --install . + - echo "Running unit tests... This will take about 60 seconds." + - cd $CI_PROJECT_DIR/build/ + - ctest -VV -C $BUILD_TYPE + artifacts: + paths: + - $CI_PROJECT_DIR/build + - $CI_PROJECT_DIR/install + + +check-install-binaries: # This job also runs in the test stage. + stage: test # It can run at the same time as unit-test-job (in parallel). + tags: + - dind + dependencies: + - build-and-ctest + script: + - cd $CI_PROJECT_DIR/install/ + - test -e lib/libSpiceQL.so + - test -e include/SpiceQL/spiceql.h + +check-installed-json-files: + stage: test + tags: + - dind + dependencies: + - build-and-ctest + script: + - cd $CI_PROJECT_DIR/install + - pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org jsonschema + - cd $CI_PROJECT_DIR/SpiceQL/db + - | + for file in *.json; + do + pwd + jsonschema --instance "$file" schema/spiceMissionSchmea.schema.json + done; + + +# clone_github: +# stage: deploy +# image: ubuntu:18.04 +# before_script: +# - apt-get update -y && apt-get install openssh-client -y +# - apt install git -y +# - eval $(ssh-agent -s) +# - echo "$GIT_SSH_PRIVATE_KEY" | openssl base64 -A -d | ssh-add - +# - mkdir -p ~/.ssh +# - chmod 700 ~/.ssh +# - ssh-keyscan $GIT_LAB_HOST >> ~/.ssh/known_hosts +# - chmod 644 ~/.ssh/known_hosts +# - git config --global user.name "krodriguez" +# - git config --global user.email "krodriguez@usgs.gov" +# - ssh "git@$GIT_LAB_HOST" +# script: +# - echo $SOURCE_REPOSITORY +# - git config --global http.sslVerify false +# - rm -rf spiceql # Needed to allow multiple CI runs +# - git config --global user.name "krodriguez" +# - git config --global user.email "krodriguez@usgs.gov" +# - git clone --mirror https://github.com/DOI-USGS/SpiceQL.git spiceql +# - cd spiceql +# - git remote remove origin +# - git remote add origin $DESTINATION_REPOSITORY +# - git push -f --prune --all +# - git push -f --prune --tags +# only: +# - branches -- GitLab