Docker registry: only tag images for the upstream repository
[platform/upstream/gstreamer.git] / .gitlab-ci.yml
1 stages:
2   - "build runtime"
3   - "build base"
4   - "preparation"
5   # Test just one basic build, if succeds procced to test the rest
6   - "build"
7   - "test"
8   # Run multiple builds and tests, multi-distro, multi-arch
9   - "full builds"
10   - "full tests"
11
12 test manifest:
13   variables:
14     GIT_STRATEGY: fetch
15   image: "fedora"
16   stage: "preparation"
17   before_script:
18     - dnf install -y python3-pytest python3-pytest-cov python3-requests
19   script:
20     - pytest-3 --junitxml=junit.xml --cov=build_manifest gitlab/build_manifest.py
21   coverage: '/TOTAL.*\s+(\d+%)$/'
22   artifacts:
23     reports:
24       junit:
25         - "junit.xml"
26   only:
27     changes:
28       - 'gitlab/build_manifest.py'
29
30 .base:
31   image: "docker:stable"
32   services:
33     - docker:dind
34   variables:
35     # When using dind, it's wise to use the overlayfs driver for
36     # improved performance.
37     DOCKER_DRIVER: "overlay2"
38     GIT_STRATEGY: fetch
39   script:
40     - export IMAGE="${CI_REGISTRY_IMAGE}/${ARCH}/${TAG}"
41     - export REF="${IMAGE}:${CI_COMMIT_SHA}"
42     - export LATEST="${IMAGE}:latest"
43
44     - docker build --pull -f ${DOCKERFILE} -t ${LATEST} ${CONTEXT_DIR}
45
46     # If we are in a fork, push the image to the reigstry regardless the branch
47     - |
48       if [ "$CI_PROJECT_NAMESPACE" != "gstreamer" ]; then
49         docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
50         docker push ${LATEST}
51       fi
52
53     # Push the images to the upstream registry
54     - |
55       if [ "$CI_COMMIT_REF_NAME" = "master" -a "$CI_PROJECT_NAMESPACE" = "gstreamer" ]; then
56         # Tag the image with the git ref
57         docker image tag ${LATEST} ${REF}
58         # Push the tags
59         docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
60         docker push ${REF}
61         docker push ${LATEST}
62       fi
63
64 alpine amd64 manifest builder docker:
65   stage: "build runtime"
66   variables:
67     ARCH: "amd64"
68     TAG: "alpine-manifest-build"
69     CONTEXT_DIR: "docker/runtime-images/"
70     DOCKERFILE: "docker/runtime-images/Dockerfile-manifest-builder"
71   extends: .base
72   only:
73     changes:
74       - 'docker/runtime-images/Dockerfile-manifest-builder'
75       - 'gitlab/build_manifest.py'
76
77 fedora amd64 run docker:
78   stage: "build runtime"
79   variables:
80     ARCH: "amd64"
81     TAG: "fedora-runtime"
82     CONTEXT_DIR: "docker/runtime-images/"
83     DOCKERFILE: "docker/runtime-images/Dockerfile-fedora"
84   extends: .base
85   only:
86     changes:
87       - 'docker/runtime-images/Dockerfile-fedora'
88
89 fedora amd64 build docker:
90   stage: "build base"
91   variables:
92     ARCH: "amd64"
93     TAG: "fedora-build"
94     CONTEXT_DIR: "docker/build-base-images/"
95     DOCKERFILE: "docker/build-base-images/Dockerfile-fedora"
96   extends: .base
97   only:
98     changes:
99       - 'docker/build-base-images/Dockerfile-fedora'
100
101 ubuntu amd64 run docker:
102   stage: "build runtime"
103   variables:
104     ARCH: "amd64"
105     TAG: "ubuntu-runtime"
106     CONTEXT_DIR: "docker/runtime-images/"
107     DOCKERFILE: "docker/runtime-images/Dockerfile-ubuntu"
108   extends: .base
109   only:
110     changes:
111       - 'docker/runtime-images/Dockerfile-ubuntu'
112
113 ubuntu amd64 build docker:
114   stage: "build base"
115   variables:
116     ARCH: "amd64"
117     TAG: "ubuntu-build"
118     CONTEXT_DIR: "docker/build-base-images/"
119     DOCKERFILE: "docker/build-base-images/Dockerfile-ubuntu"
120   extends: .base
121   only:
122     changes:
123       - 'docker/build-base-images/Dockerfile-ubuntu'
124
125 include: "gitlab/ci_template.yml"
126
127 # Test the build job against the latest build image tag and the local manifest
128 build fedora x86_64 local:
129   extends: '.build'
130   stage: 'build'
131   image: "${CI_REGISTRY_IMAGE}/amd64/fedora-build:latest"
132
133 build ubuntu x86_64 local:
134   extends: '.build'
135   variables:
136     MESON_ARGS: "${DEFAULT_MESON_ARGS} -Dlibav=disabled"
137   image: "${CI_REGISTRY_IMAGE}/amd64/ubuntu-build:latest"