From be57d456532897fa48d29a8ccb28b1a16e9875eb Mon Sep 17 00:00:00 2001
From: Pascal Vizeli <pvizeli@syshack.ch>
Date: Mon, 27 Apr 2020 12:09:31 +0200
Subject: [PATCH] Add hadolint to CI (#34758)

* Add hadolint to CI

* Fix lint & name

* Update azure-pipelines-ci.yml

Co-Authored-By: Franck Nijhof <git@frenck.dev>

Co-authored-by: Franck Nijhof <git@frenck.dev>
---
 .hadolint.yaml         |  5 +++++
 Dockerfile.dev         |  3 +--
 azure-pipelines-ci.yml | 18 ++++++++++++++++++
 3 files changed, 24 insertions(+), 2 deletions(-)
 create mode 100644 .hadolint.yaml

diff --git a/.hadolint.yaml b/.hadolint.yaml
new file mode 100644
index 00000000000..06de09b5460
--- /dev/null
+++ b/.hadolint.yaml
@@ -0,0 +1,5 @@
+ignored:
+  - DL3006
+  - DL3008
+  - DL3013
+  - DL3018
diff --git a/Dockerfile.dev b/Dockerfile.dev
index b692e9104fe..be8e2223390 100644
--- a/Dockerfile.dev
+++ b/Dockerfile.dev
@@ -18,8 +18,7 @@ WORKDIR /usr/src
 
 # Setup hass-release
 RUN git clone --depth 1 https://github.com/home-assistant/hass-release \
-    && cd hass-release \
-    && pip3 install -e .
+    && pip3 install -e hass-release/
 
 WORKDIR /workspaces
 
diff --git a/azure-pipelines-ci.yml b/azure-pipelines-ci.yml
index d620cd14594..49b032ed2e8 100644
--- a/azure-pipelines-ci.yml
+++ b/azure-pipelines-ci.yml
@@ -26,6 +26,8 @@ resources:
 variables:
   - name: PythonMain
     value: "37"
+  - name: versionHadolint
+    value: "v1.17.6"
 
 stages:
   - stage: "Overview"
@@ -121,6 +123,22 @@ stages:
               . venv/bin/activate
               pre-commit run black --all-files --show-diff-on-failure
             displayName: "Check Black formatting"
+      - job: "Docker"
+        pool:
+          vmImage: "ubuntu-latest"
+        steps:
+          - script: sudo docker pull hadolint/hadolint:$(versionHadolint)
+            displayName: "Install Hadolint"
+          - script: |
+              set -e
+              for dockerfile in Dockerfile Dockerfile.dev
+              do
+                echo "Linting: $dockerfile"
+                docker run --rm -i \
+                  -v "$(pwd)/.hadolint.yaml:/.hadolint.yaml:ro" \
+                  hadolint/hadolint:$(versionHadolint) < "$dockerfile"
+              done
+            displayName: "Run Hadolint"
 
   - stage: "Tests"
     dependsOn:
-- 
GitLab