build:
  stage: build
  # instead of calling g++ directly you can also use some build toolkit like make
  # install the necessary build tools when needed
  # before_script: 
  #   - apt update && apt -y install make autoconf 
  artifacts:
    paths:
    - target-dir
  script: 
    - ./configure --prefix=${CI_PROJECT_DIR}/target-dir/
    - make
    - make install
  rules:
    - if: $CI_COMMIT_BRANCH == "develop"
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  
# run self-tests using the binary built before
test-self:
  stage: test
  dependencies:
    - build
  script:
    - ./configure --prefix=${CI_PROJECT_DIR}/target-dir/
    - make check
  rules:
    - if: $CI_COMMIT_BRANCH == "develop"
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"


# run ansi-tests using the binary built before
test-ansi:
  stage: test
  dependencies:
    - build
  script:
    - ./configure --prefix=${CI_PROJECT_DIR}/target-dir/
    - make ansi-test
  rules:
    - if: $CI_COMMIT_BRANCH == "develop"
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
