variables:
    GIT_SUBMODULE_STRATEGY: none
    SBROAD_DEV_IMAGE: docker-public.binary.picodata.io/sbroad-builder:0.6.0

stages:
    - build
    - test
    - deploy

cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
        - target

default:
    tags:
        - picodata
    image: ${SBROAD_DEV_IMAGE}
build:
    stage: build
    script:
        - make
    artifacts:
      paths:
        - target/release/libsbroad.so
      expire_in: 1 week

lint:
    stage: test
    script:
        - make lint

unit:
    stage: test
    script:
        - make test

integration:
    stage: test
    script:
        - make test_integration

bench:
    stage: test
    script:
        - make bench_check

deploy-luarocks:
    stage: deploy
    tags:
        - shell
    only:
        - web
        - tags
    before_script:
        - eval $(ssh-agent -s)
        - echo "$DEPLOY_PROD_SSH_KEY" | base64 -d | ssh-add -
    script:
        - make release_rock
        - echo "Deploying luarocks..."
        - scp -o stricthostkeychecking=no sbroad*rock luarocks@94.26.239.246:/data/nginx/www/packrepo/luarocks
        - ssh -o stricthostkeychecking=no luarocks@94.26.239.246 "luarocks-admin make_manifest /data/nginx/www/packrepo/luarocks"