You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by bm...@apache.org on 2023/01/09 20:37:31 UTC

[maven-wrapper] 01/01: [BUILD] add code style check for shell scripts

This is an automated email from the ASF dual-hosted git repository.

bmarwell pushed a commit to branch add_shfmt_action
in repository https://gitbox.apache.org/repos/asf/maven-wrapper.git

commit 6b1fefdba2c8783ddc821203e90de2632a116584
Author: Benjamin Marwell <bm...@apache.org>
AuthorDate: Mon Jan 9 21:39:25 2023 +0100

    [BUILD] add code style check for shell scripts
---
 .github/workflows/shfmt.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/.github/workflows/shfmt.yml b/.github/workflows/shfmt.yml
new file mode 100644
index 0000000..93518a5
--- /dev/null
+++ b/.github/workflows/shfmt.yml
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: "Shellcheck: POSIX conformity"
+
+on:
+  push:
+  pull_request:
+
+jobs:
+  shfmt:
+    name: shfmt
+    runs-on: ubuntu-latest
+    env:
+      SHFMT_VERSION: '3.6.0'
+      # --indent 2: 2 spaces of indentation
+      # --case-indent: switch cases will be indented
+      # --diff: error with a diff when the formatting differs
+      SHFMT_OPTS: '--indent 2 --case-indent --diff'
+    steps:
+      - uses: actions/checkout@v3
+      - name: download
+        run: |
+          mkdir -p "$GITHUB_WORKSPACE/shfmt"
+          curl --silent --fail --show-error --retry 2 --retry-delay 1 --connect-timeout 5 --location --url "https://github.com/mvdan/sh/releases/download/v${SHFMT_VERSION}/shfmt_v${SHFMT_VERSION}_linux_amd64" -o "shfmt/shfmt_v${SHFMT_VERSION}_linux_amd64"
+          chmod +x "$GITHUB_WORKSPACE/shfmt/shfmt_v${SHFMT_VERSION}_linux_amd64"
+      - name: check
+        run: |
+          echo "$GITHUB_WORKSPACE/shfmt" >> $GITHUB_PATH
+          readarray -t SCRIPT_FILES < <(shfmt -f "$GITHUB_WORKSPACE/maven-wrapper-distribution/src/resources")
+          shfmt ${SHFMT_OPTS} "${SCRIPT_FILES[@]}"