shouriha
shouriha

Reputation: 109

Skip build and use last successful artifact gitlab CI

I have a project with a mix of C++ and Python code. The python code uses some bindings and therefore depends on the build.

What I want is to be able to skip the build step if I have not changed any cpp, hpp, or ipp files but be able to download the artifacts from a previous, successful build stage so I can run tests. Is this possible in gitlab?

# Configure CMake, which sets up the build directory and adds any files that CMake produces with the configure_file command
configure-cmake:
  stage: configure
  image: $UPSTREAM_REGISTRY/$CONDA_ENV_IMAGE:latest
  script:
    - cmake ${CMAKE_ARGS} -DCMAKE_EXPORT_COMPILE_COMMANDS=true -B $BUILD_DIR -S .
  artifacts:
    expire_in: 2h
    paths:
      - $BUILD_DIR/
      # there might be an easier way to auto-detect the artifacts below, which are made by CMake's configure_file
      - src/version.hpp
      - bayeswavecpp_bindings/autoload_cppyy.py


####################################################################################################
############################################### BUILD ##############################################
####################################################################################################

# Build the library with CMake (includes clang-tidy static analysis)
build-cpp-library:
  stage: build
  image: $UPSTREAM_REGISTRY/$CONDA_ENV_IMAGE:latest
  needs: ["configure-cmake"]
  script:
    - cmake --build $BUILD_DIR --target bayeswavecpp -- VERBOSE=1
  dependencies:
    - configure-cmake
  artifacts:
    expire_in: 2h
    paths:
      - $BUILD_DIR/


# This is what I want to run, especially when there have been no c++ changes 
test-python-binding-import:
  stage: test
  image: $UPSTREAM_REGISTRY/$CONDA_ENV_IMAGE:latest
  needs: ["configure-cmake", "build-cpp-library"]
  # for now, install cppyy through pip because the version from conda is out of date and has bugs
  script:
    - pip install cppyy-cling cppyy-backend CPyCppyy cppyy
    - pip install -e .
    - cd test/python_binding_tests
    - python -m unittest -v -b test_cppyy_imports.py
  dependencies:
    - configure-cmake
    - build-cpp-library

Upvotes: 0

Views: 41

Answers (0)

Related Questions