From 218ffd2244676e08001e89b23b09f4646a5c4e2b Mon Sep 17 00:00:00 2001
From: georg <georg@riseup.net>
Date: Mon, 15 Apr 2019 10:11:32 +0000
Subject: [PATCH] CI: Introduce Dockerfile linting

---
 .gitlab-ci.yml | 41 +++++++++++++++++++++++++++++++++++------
 .hadolint.yaml |  5 +++++
 fedora         |  7 ++++---
 3 files changed, 44 insertions(+), 9 deletions(-)
 create mode 100644 .hadolint.yaml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9e0bbc1..02335ac 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,14 +1,28 @@
 ---
-image: docker:latest
 services:
   - docker:dind
 stages:
+  - lint
   - build
 variables:
   DOCKER_DRIVER: overlay2
   DOCKER_HOST: tcp://docker:2375
 
+.transform-job-name: &transform-job-name
+  before_script:
+    - CI_JOB_NAME="$(echo $CI_JOB_NAME | cut -d - -f 2)"
+    - export CI_JOB_NAME
+
+.lint-dockerfile: &lint-dockerfile
+  image: hadolint/hadolint:latest-debian
+  <<: *transform-job-name
+  script:
+    - hadolint $CI_JOB_NAME
+  stage: lint
+
 .build-docker-image: &build-docker-image
+  image: docker:latest
+  <<: *transform-job-name
   script:
     # Disable bash history to prevent the $CI_JOB_TOKEN to be recorded and saved
     - unset HISTFILE
@@ -21,17 +35,32 @@ variables:
     - rm /root/.docker/config.json
   stage: build
 
-archlinux:
+lint-archlinux:
+  <<: *lint-dockerfile
+
+lint-debian:
+  <<: *lint-dockerfile
+
+lint-fedora:
+  <<: *lint-dockerfile
+
+lint-gentoo:
+  <<: *lint-dockerfile
+
+lint-linting:
+  <<: *lint-dockerfile
+
+build-archlinux:
   <<: *build-docker-image
 
-debian:
+build-debian:
   <<: *build-docker-image
 
-fedora:
+build-fedora:
   <<: *build-docker-image
 
-gentoo:
+build-gentoo:
   <<: *build-docker-image
 
-linting:
+build-linting:
   <<: *build-docker-image
diff --git a/.hadolint.yaml b/.hadolint.yaml
new file mode 100644
index 0000000..c29bd05
--- /dev/null
+++ b/.hadolint.yaml
@@ -0,0 +1,5 @@
+ignored:
+  - DL3006
+  - DL3007  
+  - DL3008
+  - DL3013  
diff --git a/fedora b/fedora
index 4fd8fd5..3a5f279 100644
--- a/fedora
+++ b/fedora
@@ -1,9 +1,10 @@
 FROM fedora
 
-RUN export FEDORA_VERSION=$(rpm -E %fedora) \
+RUN FEDORA_VERSION="$(rpm -E %fedora)" \
+&&  export FEDORA_VERSION \
 &&  dnf install -y \
-    https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$FEDORA_VERSION.noarch.rpm \
-    https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$FEDORA_VERSION.noarch.rpm \
+    https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-"$FEDORA_VERSION".noarch.rpm \
+    https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-"$FEDORA_VERSION".noarch.rpm \
 &&  dnf update -y \
 &&  dnf install -y \
     cairo \
-- 
GitLab