From 3d89f81fb5e8e30b889cf08860a1743f9b982cd7 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Tue, 31 Jan 2023 05:39:43 +0000 Subject: [PATCH] Setup `actionlint` and `shellcheck` prior to running `pre-commit` Signed-off-by: Pedro Algarvio --- .github/actions/setup-actionlint/action.yml | 29 +++++++++++++++++++ .github/actions/setup-shellcheck/action.yml | 31 +++++++++++++++++++++ .github/workflows/pre-commit-action.yml | 6 ++-- .pre-commit-config.yaml | 4 +++ 4 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 .github/actions/setup-actionlint/action.yml create mode 100644 .github/actions/setup-shellcheck/action.yml diff --git a/.github/actions/setup-actionlint/action.yml b/.github/actions/setup-actionlint/action.yml new file mode 100644 index 000000000000..cbf835ea6275 --- /dev/null +++ b/.github/actions/setup-actionlint/action.yml @@ -0,0 +1,29 @@ +--- +name: setup-actionlint +description: Setup actionlint +inputs: + version: + description: The version of actionlint + default: v1.6.23 + +runs: + using: composite + steps: + + - name: Cache actionlint Binary + uses: actions/cache@v3 + with: + path: /usr/local/bin/actionlint + key: ${{ runner.os }}-${{ runner.arch }}-actionlint-${{ inputs.version }} + + - name: Setup actionlint + shell: bash + run: | + if ! command -v actionlint; then + bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/${{ inputs.version }}/scripts/download-actionlint.bash) + mv ./actionlint /usr/local/bin/actionlint + fi + - name: Show actionlint Version + shell: bash + run: | + actionlint --version diff --git a/.github/actions/setup-shellcheck/action.yml b/.github/actions/setup-shellcheck/action.yml new file mode 100644 index 000000000000..9471f9b48b96 --- /dev/null +++ b/.github/actions/setup-shellcheck/action.yml @@ -0,0 +1,31 @@ +--- +name: setup-shellcheck +description: Setup shellcheck +inputs: + version: + description: The version of shellcheck + default: v0.9.0 + +runs: + using: composite + steps: + + - name: Cache shellcheck Binary + uses: actions/cache@v3 + with: + path: /usr/local/bin/shellcheck + key: ${{ runner.os }}-${{ runner.arch }}-shellcheck-${{ inputs.version }} + + - name: Setup shellcheck + shell: bash + run: | + if ! command -v shellcheck; then + wget https://github.com/koalaman/shellcheck/releases/download/${{ inputs.version }}/shellcheck-${{ inputs.version }}.${{ runner.os }}.x86_64.tar.xz + tar xf shellcheck-${{ inputs.version }}.${{ runner.os }}.x86_64.tar.xz + mv shellcheck-${{ inputs.version }}/shellcheck /usr/local/bin/shellcheck + rm -rf shellcheck-${{ inputs.version }}.${{ runner.os }}.x86_64.tar.xz shellcheck-${{ inputs.version }} + fi + - name: Show shellcheck Version + shell: bash + run: | + shellcheck --version diff --git a/.github/workflows/pre-commit-action.yml b/.github/workflows/pre-commit-action.yml index 6cfb4ef17098..29a83ba4fec5 100644 --- a/.github/workflows/pre-commit-action.yml +++ b/.github/workflows/pre-commit-action.yml @@ -26,17 +26,19 @@ jobs: run: | echo "deb http://deb.debian.org/debian buster-backports main" >> /etc/apt/sources.list apt-get update - apt-get install -y enchant git gcc make zlib1g-dev libc-dev libffi-dev g++ libxml2 libxml2-dev libxslt-dev libcurl4-openssl-dev libssl-dev libgnutls28-dev + apt-get install -y wget curl enchant git gcc make zlib1g-dev libc-dev libffi-dev g++ libxml2 libxml2-dev libxslt-dev libcurl4-openssl-dev libssl-dev libgnutls28-dev apt-get install -y git/buster-backports - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-actionlint + - uses: ./.github/actions/setup-shellcheck - name: Install Pre-Commit env: PIP_INDEX_URL: https://pypi-proxy.saltstack.net/root/local/+simple/ PIP_EXTRA_INDEX_URL: https://pypi.org/simple run: | - pip install wheel pre-commit==${PRE_COMMIT_VERSION} + pip install wheel "pre-commit==${PRE_COMMIT_VERSION}" pre-commit install --install-hooks - name: Check ALL Files On Branch diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 14c143af2b40..71f6bc6b5e6c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,6 +28,10 @@ repos: args: - pre-commit - actionlint + additional_dependencies: + - boto3==1.21.46 + - pyyaml==6.0 + - jinja2==3.1.2 - repo: https://github.com/saltstack/pip-tools-compile-impersonate rev: "4.6"