310f8ee2b23b5c544f76562bb288bf1c9aeb4a0a
[platform/upstream/gstreamer.git] / .gitlab-ci.yml
1 include: "gitlab/ci_template.yml"
2
3 stages:
4   - "build docker"
5   - "preparation"
6   - "pre-build"
7   - "build"
8   - "test"
9   # use the binaries in some way
10   - "integrate"
11
12 test manifest:
13   variables:
14     GIT_STRATEGY: fetch
15   rules:
16     - when: 'always'
17   image: 'registry.freedesktop.org/gstreamer/gst-ci/amd64/test-manifest:2019-10-23-793476'
18   stage: "preparation"
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
27 # have a special definition for the test if the image already exists
28 .check_image: &check_image_exists |
29   # if-not-exists steps
30   set -x
31
32   if [[ -z "$GST_FORCE_REBUILD" ]]
33   then
34     # disable exit on failure
35     set +e
36
37     # check if our image is already in the current registry
38     # we store the sha of the digest and the layers
39     skopeo inspect docker://$LOCAL_IMAGE | jq '[.Digest, .Layers]' > local_sha
40
41     # check if our image is already in the upstream registry
42     if [[ -z "$GST_UPSTREAM_REPO" ]]
43     then
44       echo "WARNING! Variable \$GST_UPSTREAM_REPO is undefined, cannot check for images"
45     else
46       skopeo inspect docker://$GST_UPSTREAM_IMAGE | jq '[.Digest, .Layers]' > upstream_sha
47     fi
48
49     # reenable exit on failure
50     set -e
51
52     # if the upstream repo has an image, ensure we use the same
53     if [ -s upstream_sha ]
54     then
55
56       # ensure we use the same image from upstream
57       diff upstream_sha local_sha && exit 0 || true
58
59       # copy the original image into the current project registry namespace
60       # we do 2 attempts with skopeo copy at most
61       skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
62                   docker://$GST_UPSTREAM_IMAGE \
63                   docker://$LOCAL_IMAGE || \
64       skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
65                   docker://$GST_UPSTREAM_IMAGE \
66                   docker://$LOCAL_IMAGE
67
68       exit 0
69     fi
70
71     # if we have a local image but none in the upstream repo, use our
72     if [ -s local_sha ]
73     then
74       exit 0
75     fi
76   fi
77
78   set +x
79
80 .base:
81   image: 'registry.fedoraproject.org/fedora:32'
82   extends:
83     - '.global_ci_policy'
84   tags: ['gstreamer']
85   rules:
86     - when: 'manual'
87       allow_failure: true
88   variables:
89     STORAGE_DRIVER: 'vfs'
90     BUILDAH_FORMAT: 'docker'
91     BUILDAH_ISOLATION: 'chroot'
92
93     # FIXME: Probably needs to be changed to none and clone gst-ci repo each time, sigh
94     # as these jobs *could* run potentially in a fork of smth like -bad
95     # though given our current setup, its only possible to tweak the CI from a gst-ci
96     # fork so it might be fine
97     GIT_STRATEGY: fetch
98   script:
99     - echo $TAG
100     - echo $REPO_SUFFIX
101
102     - export LOCAL_IMAGE="$CI_REGISTRY_IMAGE/$REPO_SUFFIX:$TAG"
103     - export GST_UPSTREAM_IMAGE="$GST_UPSTREAM_REPO/$REPO_SUFFIX:$TAG"
104
105     - echo $LOCAL_IMAGE
106     - echo $GST_UPSTREAM_IMAGE
107
108     # FIXME: make an image since there will be multiple jobs running every pipeline
109     - dnf install -y buildah skopeo jq runc
110
111     # Newer versions of podman/buildah try to set overlayfs mount options when
112     # using the vfs driver, and this causes errors.
113     - sed -i '/^mountopt =.*/d' /etc/containers/storage.conf
114
115     - *check_image_exists
116
117     - echo "Building image $LOCAL_IMAGE"
118
119     - >
120       buildah bud
121       --build-arg DEFAULT_BRANCH=$GST_UPSTREAM_BRANCH
122       --arch=${ARCH:=amd64}
123       --label ci.job_id=$CI_JOB_ID
124       --label pipeline.url=$CI_PIPELINE_URL
125       --label git.ref_name=$CI_COMMIT_REF_NAME
126       --label git.sha=$CI_COMMIT_SHA
127       --label gitlab.project_path=$CI_PROJECT_PATH
128       --label gitlab.project_url=$CI_PROJECT_URL
129       --label fdo.upstream-repo=$GST_UPSTREAM_REPO
130       --label fdo.expires-after="3w"
131       -f $DOCKERFILE
132       -t $LOCAL_IMAGE
133       $CONTEXT_DIR
134
135     - buildah login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
136
137
138     # Sanity check
139     - |
140       if [ "$CI_PROJECT_PATH" = "gstreamer/gst-ci" ]; then
141         if [ "$LOCAL_IMAGE" != "$GST_UPSTREAM_IMAGE" ]; then
142           echo "ERROR!!! AAAAA! THE IMAGE URI DOES NOT MATCH THE EXPECTED UPSTREAM ONE"
143           echo $LOCAL_IMAGE
144           echo $GST_UPSTRAM_IMAGE
145           exit 1
146         fi
147       fi
148
149     -  buildah push $LOCAL_IMAGE
150
151 alpine amd64 manifest builder docker:
152   stage: "build docker"
153   variables:
154     TAG: "build-manifest"
155     CONTEXT_DIR: "docker/build_manifest/"
156     DOCKERFILE: "docker/build_manifest/Dockerfile"
157   extends: .base
158
159 test manifest amd64 docker:
160   stage: "build docker"
161   variables:
162     TAG: "test-manifest"
163     CONTEXT_DIR: "docker/test_manifest/"
164     DOCKERFILE: "docker/test_manifest/Dockerfile"
165   extends: .base
166
167 gst-indent amd64 docker:
168   stage: "build docker"
169   variables:
170     TAG: "gst-indent"
171     CONTEXT_DIR: "docker/indent/"
172     DOCKERFILE: "docker/indent/Dockerfile"
173   extends: .base
174
175 fedora amd64 docker:
176   stage: "build docker"
177   variables:
178     REPO_SUFFIX: "amd64/fedora"
179     TAG: "2020-06-18.0-$GST_UPSTREAM_BRANCH"
180
181     CONTEXT_DIR: "docker/fedora/"
182     DOCKERFILE: "docker/fedora/Dockerfile"
183   extends: .base
184
185 cerbero fedora amd64 docker:
186   stage: "build docker"
187   variables:
188     TAG: "cerbero-fedora"
189     CONTEXT_DIR: "docker/cerbero/"
190     DOCKERFILE: "docker/cerbero/Dockerfile-fedora"
191   extends: .base
192
193 android docker:
194   stage: "build docker"
195   variables:
196     TAG: "android"
197     CONTEXT_DIR: "docker/android/"
198     DOCKERFILE: "docker/android/Dockerfile"
199   extends: .base
200
201 .local_rules: &local_rules
202   rules:
203     - if: '$CI_COMMIT_REF_NAME == "master" && $CI_PROJECT_PATH == "gstreamer/gst-ci"'
204       when: 'never'
205     - when: 'manual'
206       allow_failure: true
207
208 .local_template: &local_template
209   <<: *local_rules
210   needs:
211     - 'manifest'
212
213 # Test the build job against the latest build image tag and the local manifest
214 build fedora x86_64 local:
215   extends: '.build'
216   stage: 'build'
217   image: "${CI_REGISTRY_IMAGE}/amd64/fedora:latest"
218   artifacts:
219     expire_in: '5 days'
220     when: always
221     paths:
222       - "manifest.xml"
223       - "gst-build/"
224   <<: *local_template
225
226 build cerbero fedora x86_64 local:
227   extends: 'build cerbero fedora x86_64'
228   image: "${CI_REGISTRY_IMAGE}/amd64/cerbero-fedora:latest"
229   <<: *local_template
230
231 build cerbero cross-android universal local:
232   extends: 'build cerbero cross-android universal'
233   image: "${CI_REGISTRY_IMAGE}/amd64/cerbero-fedora:latest"
234   <<: *local_template
235
236 build cerbero cross win32 local:
237   extends: 'build cerbero cross win32'
238   image: "${CI_REGISTRY_IMAGE}/amd64/cerbero-fedora:latest"
239   <<: *local_template
240
241 build cerbero cross win64 local:
242   extends: 'build cerbero cross win64'
243   image: "${CI_REGISTRY_IMAGE}/amd64/cerbero-fedora:latest"
244   <<: *local_template
245
246 # Note: dependencies: will be deprecated in the future, but current manual
247 # jobs with needs: (even if they are allowed to fail) will leave the pipeline
248 # pending.
249 .test fedora x86_64 local:
250   image: '${CI_REGISTRY_IMAGE}/amd64/fedora:latest'
251   extends: '.test'
252   <<: *local_rules
253
254 check fedora local:
255   extends: '.test fedora x86_64 local'
256   variables:
257     TEST_SUITE: 'check.gst*'
258
259 cross-android universal examples local:
260   extends: '.cross-android universal examples'
261   image: "${CI_REGISTRY_IMAGE}/amd64/android:latest"
262   <<: *local_rules
263   dependencies:
264     - 'build cerbero cross-android universal local'
265
266 integration testsuites fedora local:
267   extends: '.test fedora x86_64 local'
268   before_script:
269     - rm -f gst-build/build/subprojects/gstreamer-vaapi/gst/vaapi/libgstvaapi.so
270   variables:
271     EXTRA_VALIDATE_ARGS: "--timeout-factor=2 --retry-on-failures"
272     TEST_SUITE: "validate ges"