gitlab: ci: Run build_manifest tests only if the script changes
[platform/upstream/gstreamer.git] / .gitlab-ci.yml
1 stages:
2   - "test"
3   - "build runtime"
4   - "build base"
5   - "manifest"
6   - "build"
7
8 test manifest:
9   variables:
10     GIT_STRATEGY: fetch
11   image: "fedora"
12   stage: "test"
13   before_script:
14     - dnf install -y python3-pytest python3-pytest-cov python3-requests
15   script:
16     - pytest-3 --junitxml=junit.xml --cov=build_manifest gitlab/build_manifest.py
17   only:
18     changes:
19       - "gitlab/build_manifest.py"
20   coverage: '/TOTAL.*\s+(\d+%)$/'
21   artifacts:
22     reports:
23       junit:
24         - "junit.xml"
25   only:
26     changes:
27       - gitlab/build_manifest.py
28
29 .base:
30   image: "docker:stable"
31   services:
32     - docker:dind
33   variables:
34     # When using dind, it's wise to use the overlayfs driver for
35     # improved performance.
36     DOCKER_DRIVER: "overlay2"
37     GIT_STRATEGY: fetch
38   script:
39     - export IMAGE="${CI_REGISTRY_IMAGE}/${ARCH}/${TAG}"
40     - export REF="${IMAGE}:${CI_COMMIT_SHA}"
41     - export LATEST="${IMAGE}:latest"
42
43     - docker build --pull -f ${DOCKERFILE} -t ${REF} ${CONTEXT_DIR}
44     - docker image tag ${REF} ${LATEST}
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 ${REF}
51         docker push ${LATEST}
52       fi
53
54     # Push the images to the upstream registry
55     - |
56       if [ "$CI_COMMIT_REF_NAME" = "master" -a "$CI_PROJECT_NAMESPACE" = "gstreamer" ]; then
57         docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
58         docker push ${REF}
59         docker push ${LATEST}
60       fi
61   only:
62     changes:
63       - ".gitlab-ci.yml"
64       - "docker/**"
65       - "docker/*/**"
66
67
68 fedora amd64 run docker:
69   stage: "build runtime"
70   variables:
71     ARCH: "amd64"
72     TAG: "fedora-runtime"
73     CONTEXT_DIR: "docker/runtime-images/"
74     DOCKERFILE: "docker/runtime-images/Dockerfile-fedora"
75   extends: .base
76
77 fedora amd64 build docker:
78   stage: "build base"
79   variables:
80     ARCH: "amd64"
81     TAG: "fedora-build"
82     CONTEXT_DIR: "docker/build-base-images/"
83     DOCKERFILE: "docker/build-base-images/Dockerfile-fedora"
84   extends: .base
85
86 include: "gitlab/ci_template.yml"
87
88 # Overwrite the job with the same name that comes from the include template,
89 # in order to use the `:latest` tag of the image built
90 build fedora x86_64:
91   # This comes from the `include:` above
92   extends: .build
93   image: "${CI_REGISTRY_IMAGE}/amd64/fedora-build:latest"