Skip to content

Commit

Permalink
Setup actionlint and shellcheck prior to running pre-commit
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Algarvio <[email protected]>
  • Loading branch information
s0undt3ch committed Jan 31, 2023
1 parent 736a7ca commit 3d89f81
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
29 changes: 29 additions & 0 deletions .github/actions/setup-actionlint/action.yml
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions .github/actions/setup-shellcheck/action.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions .github/workflows/pre-commit-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 3d89f81

Please sign in to comment.