ソースを参照

[CI] Run shellcheck as part of Jenkins pipelines

The pipeline is failed only when pylint whines about the code actually
touched as part of the pull request.

The `run-shellcheck` script is provided so it can be reused, maybe in
`.git/hooks/pre-push`.
Wojtek Porczyk 4 年 前
コミット
efbf2706dd

+ 21 - 0
.ci/run-shellcheck

@@ -0,0 +1,21 @@
+#!/bin/sh
+
+cd "$(git rev-parse --show-toplevel)"
+
+shellcheck "$@" \
+    LibOS/shim/test/apps/bash/scripts/bash_test.sh \
+    LibOS/shim/test/apps/common_tools/benchmark-http.sh \
+    LibOS/shim/test/apps/python-simple/run-tests.sh \
+    LibOS/shim/test/native/*.sh \
+    Pal/ipc/linux/*.sh \
+    Pal/src/host/FreeBSD/pal-gdb.template \
+    Pal/src/host/Linux-SGX/debugger/gdb \
+    Pal/src/host/Linux-SGX/sgx-driver/load.sh \
+    Runtime/pal_loader \
+    Scripts/clean-check \
+    Scripts/clean-check-prepare \
+    Scripts/clean-check-test-copy \
+    Scripts/list-all-graphene.sh \
+    Scripts/memusg \
+    .ci/run-pylint \
+    .ci/run-shellcheck

+ 8 - 0
Jenkinsfiles/Linux

@@ -3,6 +3,14 @@ pipeline {
               dockerfile { filename 'Jenkinsfiles/ubuntu-16.04.dockerfile' }
         }
         stages {
+                stage('Lint') {
+                    steps {
+                        sh '''
+                            ./.ci/run-shellcheck || :
+                            ./.ci/run-shellcheck -f json | ./.ci/prfilter
+                        '''
+                    }
+                }
                 stage('Build') {
                     steps {
                         sh '''

+ 3 - 0
Jenkinsfiles/Linux-18.04

@@ -8,6 +8,9 @@ pipeline {
                         sh '''
                             ./.ci/run-pylint -f text || :
                             ./.ci/run-pylint -f json | ./.ci/prfilter
+
+                            ./.ci/run-shellcheck || :
+                            ./.ci/run-shellcheck -f json | ./.ci/prfilter
                         '''
                     }
                 }

+ 8 - 0
Jenkinsfiles/Linux-Debug

@@ -3,6 +3,14 @@ pipeline {
               dockerfile { filename 'Jenkinsfiles/ubuntu-16.04.dockerfile' }
         }
         stages {
+                stage('Lint') {
+                    steps {
+                        sh '''
+                            ./.ci/run-shellcheck || :
+                            ./.ci/run-shellcheck -f json | ./.ci/prfilter
+                        '''
+                    }
+                }
                 stage('Build') {
                     steps {
                         sh '''

+ 3 - 0
Jenkinsfiles/Linux-Debug-18.04

@@ -8,6 +8,9 @@ pipeline {
                         sh '''
                             ./.ci/run-pylint -f text || :
                             ./.ci/run-pylint -f json | ./.ci/prfilter
+
+                            ./.ci/run-shellcheck || :
+                            ./.ci/run-shellcheck -f json | ./.ci/prfilter
                         '''
                     }
                 }

+ 8 - 0
Jenkinsfiles/Linux-SGX

@@ -6,6 +6,14 @@ pipeline {
                        }
         }
         stages {
+                stage('Lint') {
+                    steps {
+                        sh '''
+                            ./.ci/run-shellcheck || :
+                            ./.ci/run-shellcheck -f json | ./.ci/prfilter
+                        '''
+                    }
+                }
                 stage('Build') {
                     steps {
                         sh '''

+ 3 - 0
Jenkinsfiles/Linux-SGX-18.04

@@ -11,6 +11,9 @@ pipeline {
                         sh '''
                             ./.ci/run-pylint -f text || :
                             ./.ci/run-pylint -f json | ./.ci/prfilter
+
+                            ./.ci/run-shellcheck || :
+                            ./.ci/run-shellcheck -f json | ./.ci/prfilter
                         '''
                     }
                 }

+ 1 - 0
Jenkinsfiles/ubuntu-16.04.dockerfile

@@ -35,6 +35,7 @@ RUN apt-get update \
        python3-pip \
        python3-pytest \
        python3-scipy \
+       shellcheck \
        texinfo \
        wget \
        zlib1g \

+ 1 - 0
Jenkinsfiles/ubuntu-18.04.dockerfile

@@ -37,6 +37,7 @@ RUN apt-get update && env DEBIAN_FRONTEND=noninteractive apt-get install -y \
     python3-protobuf \
     python3-pytest \
     python3-scipy \
+    shellcheck \
     texinfo \
     wget \
     zlib1g \