gitlab/ci_template.yml: rework the CI stages
[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 ${REF} ${CONTEXT_DIR}
45     - docker image tag ${REF} ${LATEST}
46
47     # If we are in a fork, push the image to the reigstry regardless the branch
48     - |
49       if [ "$CI_PROJECT_NAMESPACE" != "gstreamer" ]; then
50         docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
51         docker push ${REF}
52         docker push ${LATEST}
53       fi
54
55     # Push the images to the upstream registry
56     - |
57       if [ "$CI_COMMIT_REF_NAME" = "master" -a "$CI_PROJECT_NAMESPACE" = "gstreamer" ]; then
58         docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
59         docker push ${REF}
60         docker push ${LATEST}
61       fi
62
63 alpine amd64 manifest builder docker:
64   stage: "build runtime"
65   variables:
66     ARCH: "amd64"
67     TAG: "alpine-manifest-build"
68     CONTEXT_DIR: "docker/runtime-images/"
69     DOCKERFILE: "docker/runtime-images/Dockerfile-manifest-builder"
70   extends: .base
71   only:
72     changes:
73       - 'docker/runtime-images/Dockerfile-manifest-builder'
74       - 'gitlab/build_manifest.py'
75
76 fedora amd64 run docker:
77   stage: "build runtime"
78   variables:
79     ARCH: "amd64"
80     TAG: "fedora-runtime"
81     CONTEXT_DIR: "docker/runtime-images/"
82     DOCKERFILE: "docker/runtime-images/Dockerfile-fedora"
83   extends: .base
84   only:
85     changes:
86       - 'docker/runtime-images/Dockerfile-fedora'
87
88 fedora amd64 build docker:
89   stage: "build base"
90   variables:
91     ARCH: "amd64"
92     TAG: "fedora-build"
93     CONTEXT_DIR: "docker/build-base-images/"
94     DOCKERFILE: "docker/build-base-images/Dockerfile-fedora"
95   extends: .base
96   only:
97     changes:
98       - 'docker/build-base-images/Dockerfile-fedora'
99
100 ubuntu amd64 run docker:
101   stage: "build runtime"
102   variables:
103     ARCH: "amd64"
104     TAG: "ubuntu-runtime"
105     CONTEXT_DIR: "docker/runtime-images/"
106     DOCKERFILE: "docker/runtime-images/Dockerfile-ubuntu"
107   extends: .base
108   only:
109     changes:
110       - 'docker/runtime-images/Dockerfile-ubuntu'
111
112 ubuntu amd64 build docker:
113   stage: "build base"
114   variables:
115     ARCH: "amd64"
116     TAG: "ubuntu-build"
117     CONTEXT_DIR: "docker/build-base-images/"
118     DOCKERFILE: "docker/build-base-images/Dockerfile-ubuntu"
119   extends: .base
120   only:
121     changes:
122       - 'docker/build-base-images/Dockerfile-ubuntu'
123
124 include: "gitlab/ci_template.yml"
125
126 # Test the build job against the latest build image tag and the local manifest
127 build fedora x86_64 local:
128   extends: '.build'
129   stage: 'build'
130   image: "${CI_REGISTRY_IMAGE}/amd64/fedora-build:latest"
131
132 build ubuntu x86_64 local:
133   extends: '.build'
134   variables:
135     MESON_ARGS: "${DEFAULT_MESON_ARGS} -Dlibav=disabled"
136   image: "${CI_REGISTRY_IMAGE}/amd64/ubuntu-build:latest"