.gitlab-ci.yml 2.76 KB
Newer Older
1
stages:
2
  - "test"
3 4
  - "build runtime"
  - "build base"
5 6
  - "manifest"
  - "build"
7 8

test manifest:
9 10
  variables:
    GIT_STRATEGY: fetch
11 12 13 14 15 16
  image: "fedora"
  stage: "test"
  before_script:
    - dnf install -y python3-pytest python3-pytest-cov python3-requests
  script:
    - pytest-3 --junitxml=junit.xml --cov=build_manifest gitlab/build_manifest.py
17 18 19
  only:
    changes:
      - "gitlab/build_manifest.py"
20 21 22 23
  coverage: '/TOTAL.*\s+(\d+%)$/'
  artifacts:
    reports:
      junit:
24
        - "junit.xml"
25 26 27
  only:
    changes:
      - gitlab/build_manifest.py
28 29 30 31 32 33 34 35 36

.base:
  image: "docker:stable"
  services:
    - docker:dind
  variables:
    # When using dind, it's wise to use the overlayfs driver for
    # improved performance.
    DOCKER_DRIVER: "overlay2"
37
    GIT_STRATEGY: fetch
38 39 40 41 42 43 44 45
  script:
    - export IMAGE="${CI_REGISTRY_IMAGE}/${ARCH}/${TAG}"
    - export REF="${IMAGE}:${CI_COMMIT_SHA}"
    - export LATEST="${IMAGE}:latest"

    - docker build --pull -f ${DOCKERFILE} -t ${REF} ${CONTEXT_DIR}
    - docker image tag ${REF} ${LATEST}

46
    # If we are in a fork, push the image to the reigstry regardless the branch
47
    - |
48 49 50 51 52 53 54 55
      if [ "$CI_PROJECT_NAMESPACE" != "gstreamer" ]; then
        docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
        docker push ${REF}
        docker push ${LATEST}
      fi

    # Push the images to the upstream registry
    - |
56
      if [ "$CI_COMMIT_REF_NAME" = "master" -a "$CI_PROJECT_NAMESPACE" = "gstreamer" ]; then
57 58 59 60 61
        docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
        docker push ${REF}
        docker push ${LATEST}
      fi

62 63 64 65 66 67 68 69
alpine amd64 manifest builder docker:
  stage: "build runtime"
  variables:
    ARCH: "amd64"
    TAG: "alpine-manifest-build"
    CONTEXT_DIR: "docker/runtime-images/"
    DOCKERFILE: "docker/runtime-images/Dockerfile-manifest-builder"
  extends: .base
70 71 72 73
  only:
    changes:
      - 'docker/runtime-images/Dockerfile-manifest-builder'
      - 'gitlab/build_manifest.py'
74

75
fedora amd64 run docker:
76 77 78 79 80 81 82
  stage: "build runtime"
  variables:
    ARCH: "amd64"
    TAG: "fedora-runtime"
    CONTEXT_DIR: "docker/runtime-images/"
    DOCKERFILE: "docker/runtime-images/Dockerfile-fedora"
  extends: .base
83 84 85
  only:
    changes:
      - 'docker/runtime-images/Dockerfile-fedora'
86

87
fedora amd64 build docker:
88 89 90 91 92 93 94
  stage: "build base"
  variables:
    ARCH: "amd64"
    TAG: "fedora-build"
    CONTEXT_DIR: "docker/build-base-images/"
    DOCKERFILE: "docker/build-base-images/Dockerfile-fedora"
  extends: .base
95 96 97
  only:
    changes:
      - 'docker/build-base-images/Dockerfile-fedora'
98

99
include: "gitlab/ci_template.yml"
100

101 102 103 104 105 106
# Test the build job against the latest build image tag and the local manifest
build fedora x86_64 local:
  extends: '.build'
  image: "${CI_REGISTRY_IMAGE}/amd64/fedora-build:latest"
  dependencies:
    - 'manifest'