stages:
  #- test
  - package
  - test_package

variables:
  ARCH: "amd64"
  DIST: "jessie"

.job_template: &job_definition
  stage: package
  image: "0xacab.org:4567/leap/gitlab-buildpackage:build_${DIST}_${ARCH}"
  script:
    - "pwd; git describe"
    - build-build-package
    # Upload packages from the main/default branch to dev-platform deb repo  and packaes from all other branches/MRs to the experimental-platform one.
    - "[ ${CI_BUILD_REF_NAME} != 'master' ] && export REPOSITORY='/srv/experimental-gitbuildpackage'"
    - upload-package
    # sleep 1h to allow debugging of running container
    #- sleep 3600
  artifacts:
    expire_in: 1w
    paths:
    - '*_*.xz'
    - '*_*.dsc'
    - '*_amd64.changes'
    - '*.deb'
    - 'results/*'

#test:
#  image: leapcode/soledad:latest
#  stage: test
#  script:
#  - tox --recreate

package:amd64:jessie:
  <<: *job_definition

lintian:
  image: "0xacab.org:4567/leap/gitlab-buildpackage:build_${DIST}_${ARCH}"
  stage: test_package
  script: bash -x build-test-lintian --fail-on-warnings

# Todo:
#   - Move test stage at the beginning of pipeline once packaging is done
stages:
  - package
  - test


.job_template: &job_definition
  stage: package
  image: "0xacab.org:4567/leap/gitlab-buildpackage:build_${DIST}_${ARCH}"
  script:
    - "pwd; git describe"
    - build-build-package
    # Test the package with lintian
    - build-test-lintian --fail-on-warnings
    # Upload packages from the main/default branch to dev-platform deb repo  and packaes from all other branches/MRs to the experimental-platform one.
    - "[ ${CI_BUILD_REF_NAME} != 'master' ] && export REPOSITORY='/srv/experimental-gitbuildpackage'"
    - upload-package
    # sleep 1h to allow debugging of running container
    #- sleep 3600
  artifacts:
    expire_in: 1w
    paths:
    - '*_*.xz'
    - '*_*.dsc'
    - '*_amd64.changes'
    - '*.deb'
    - 'results/*'

test:
  image: leapcode/soledad:latest
  stage: test
  script:
  - tox --recreate

package:amd64_jessie:
  variables:
    ARCH: "amd64"
    DIST: "jessie"
  <<: *job_definition

Use one package job for every arch/dist combination
Use one package job for every arch/dist combination
