[gjs: 1/8] CI: Create cpplint image using Alpine Linux



commit 811d9f9debed06a24af6078d5dd4af5e824b0538
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat Sep 7 21:49:54 2019 -0700

    CI: Create cpplint image using Alpine Linux
    
    The 'fedora.static-analysis' image is now only necessary for cpplint, so
    we create as small an image as possible using Alpine Linux to install
    git and python, and then cpplint via pip.
    
    We can't change the actual job yet, as the image will have to be built
    first.

 .gitlab-ci.yml                               | 25 +++++++++++++++----------
 test/extra/Dockerfile.alpine.cpplint         | 15 +++++++++++++++
 test/extra/Dockerfile.fedora.static-analysis | 16 ----------------
 3 files changed, 30 insertions(+), 26 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1f1d068a..4b2ed634 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -203,6 +203,7 @@ cppcheck:
 cpplint:
   <<: *build
   stage: source_check
+  # FIXME: Change to alpine.cpplint image when available
   image: registry.gitlab.gnome.org/gnome/gjs:fedora.static-analysis
   variables:
     TASK_ID: "cpplint"
@@ -371,12 +372,6 @@ zeal_11:
     # CI starts here. Previous messages are from GitLab Runner setup.
     - *CI_header
 
-    # Build using the Dockerfile
-    - |
-      if [[ -n "${DOCKERFILE}" ]]; then
-        docker build -f "$DOCKERFILE" -t "$CI_REGISTRY_IMAGE:$NAME" .
-      fi
-
     # Where the real magic happens
     - |
       if [[ -n "${IMAGE}" ]]; then
@@ -400,17 +395,27 @@ zeal_11:
     # Done
     - *CI_footer
 
-fedora.static-analysis:
+alpine.cpplint:
   <<: *create_docker_image
+  script:
+    # Overrides the script from create_docker_image above
+    - *CI_header
+    - docker build -f test/extra/Dockerfile.alpine.cpplint -t "$CI_REGISTRY_IMAGE:alpine.cpplint" .
+    - docker tag "$CI_REGISTRY_IMAGE:alpine.cpplint" "$CI_REGISTRY_IMAGE:job-"$CI_JOB_ID"_alpine.cpplint"
+    - docker images
+    - docker login ${CI_REGISTRY} -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD}
+    - |
+      if [[ "${CI_PIPELINE_SOURCE}" == "schedule" ]]; then
+        docker push "$CI_REGISTRY_IMAGE"
+      fi
+    - *CI_footer
   variables:
     DOCKER_DRIVER: overlay
     # https://about.gitlab.com/2019/07/31/docker-in-docker-with-docker-19-dot-03
     DOCKER_TLS_CERTDIR: ""
-    DOCKERFILE: "test/extra/Dockerfile.fedora.static-analysis"
-    NAME: "fedora.static-analysis"
   except:
     variables:
-      - $CI_COMMIT_MESSAGE =~ /\[skip images\]/ && $CI_COMMIT_MESSAGE =~ /fedora.static-analysis/
+      - $CI_COMMIT_MESSAGE =~ /\[skip images\]/ && $CI_COMMIT_MESSAGE =~ /alpine.cpplint/
 
 SM60-gcc.fedora-dev:
   <<: *create_docker_image
diff --git a/test/extra/Dockerfile.alpine.cpplint b/test/extra/Dockerfile.alpine.cpplint
new file mode 100644
index 00000000..ace23e4d
--- /dev/null
+++ b/test/extra/Dockerfile.alpine.cpplint
@@ -0,0 +1,15 @@
+FROM alpine:latest
+MAINTAINER Claudio André (c) 2018 V1.0
+
+LABEL architecture="x86_64"
+LABEL version="1.0"
+LABEL description="Docker image to run CI for GNOME GJS (JavaScript bindings for GNOME)."
+
+RUN apk add --no-cache python3 git
+RUN python3 -m ensurepip && \
+    rm -r /usr/lib/python*/ensurepip && \
+    pip3 install --no-cache --upgrade pip setuptools wheel
+RUN pip3 install --no-cache --upgrade cpplint
+RUN mkdir -p /cwd
+
+CMD ["/bin/bash"]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]