sgsfdh
This commit is contained in:
parent
ef83c61abc
commit
7f9b8d4e64
56
.github/workflows/bash.yml
vendored
56
.github/workflows/bash.yml
vendored
@ -6,18 +6,62 @@ on:
|
||||
types: [synchronize, opened, reopened, ready_for_review]
|
||||
paths:
|
||||
- '**.bash'
|
||||
- "tools/dockerfreeze"
|
||||
|
||||
jobs:
|
||||
# Linting
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
container: debian:stable
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Installing dependencies..
|
||||
run: if ! apt list --installed 2>/dev/null | grep -q ".*shellcheck.*"; then apt install -y shellcheck; fi
|
||||
- name: Linting..
|
||||
run: |
|
||||
cd "$GITHUB_WORKSPACE" && for file in $(git ls-tree --name-only -r ${{ github.sha }} | grep '\.bash$'); do
|
||||
printf 'linting bash file %s' "$file"
|
||||
shellcheck --external-sources --shell=bash "$file"
|
||||
# Sync repos
|
||||
# Check for git
|
||||
if ! apt list --installed 2>/dev/null | grep -qP "^git\/stable.*"; then
|
||||
# Check if we can install git
|
||||
if ! apt list | grep -qP "^git\/stable.*"; then
|
||||
apt update
|
||||
elif apt list | grep -qP "^git\/stable.*"; then
|
||||
true
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
# Install git
|
||||
apt install -y git
|
||||
elif apt list --installed 2>/dev/null | grep -qP "^git\/stable.*"; then
|
||||
true
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
# Check for shellcheck
|
||||
if ! apt list --installed 2>/dev/null | grep -qP "^shellcheck\s{1}-.*"; then
|
||||
# Check if we can install shellcheck
|
||||
if ! apt list | grep -qP "^shellcheck\s{1}-.*"; then
|
||||
apt update
|
||||
elif apt list | grep -qP "^shellcheck\s{1}-.*"; then
|
||||
true
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
# Install shellcheck
|
||||
apt install -y shellcheck
|
||||
elif apt list --installed 2>/dev/null | grep -qP "^shellcheck\s{1}-.*"; then
|
||||
true
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
- name: Pulling git dir..
|
||||
uses: actions/checkout@v2
|
||||
- name: Processing files..
|
||||
# Make sure that bash is used
|
||||
shell: bash
|
||||
run: |
|
||||
cd "$GITHUB_WORKSPACE"
|
||||
|
||||
# Process files
|
||||
## NOTICE: Do not use for loop to avoid pitfall https://mywiki.wooledge.org/BashPitfalls#pf1
|
||||
git --git-dir="$GITHUB_WORKSPACE/.git" ls-files -z -- '*.bash' tools/dockerfreeze | while IFS= read -rd '' file; do
|
||||
printf 'linting bash file %s\n' "$file"
|
||||
shellcheck --external-sources --shell=bash "$file"
|
||||
done
|
56
.github/workflows/shell.yml
vendored
56
.github/workflows/shell.yml
vendored
@ -11,14 +11,56 @@ jobs:
|
||||
# Linting
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
container: debian:stable
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Installing dependencies..
|
||||
run: if ! apt list --installed | grep -qP ".*shellcheck.*"; then apt install -y shellcheck; fi
|
||||
- name: Linting..
|
||||
# FIXME: False triggers on files which names continues after `.sh` i.e `something.sh.something`
|
||||
run: |
|
||||
cd "$GITHUB_WORKSPACE" && for file in $(git ls-tree --name-only -r ${{ github.sha }} | grep '\.sh$'); do
|
||||
printf 'linting shell file %s' "$file"
|
||||
shellcheck --external-sources --shell=sh "$file"
|
||||
# Sync repos
|
||||
# Check for git
|
||||
if ! apt list --installed 2>/dev/null | grep -qP "^git\/stable.*"; then
|
||||
# Check if we can install git
|
||||
if ! apt list | grep -qP "^git\/stable.*"; then
|
||||
apt update
|
||||
elif apt list | grep -qP "^git\/stable.*"; then
|
||||
true
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
# Install git
|
||||
apt install -y git
|
||||
elif apt list --installed 2>/dev/null | grep -qP "^git\/stable.*"; then
|
||||
true
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
# Check for shellcheck
|
||||
if ! apt list --installed 2>/dev/null | grep -qP "^shellcheck\s{1}-.*"; then
|
||||
# Check if we can install shellcheck
|
||||
if ! apt list | grep -qP "^shellcheck\s{1}-.*"; then
|
||||
apt update
|
||||
elif apt list | grep -qP "^shellcheck\s{1}-.*"; then
|
||||
true
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
# Install shellcheck
|
||||
apt install -y shellcheck
|
||||
elif apt list --installed 2>/dev/null | grep -qP "^shellcheck\s{1}-.*"; then
|
||||
true
|
||||
else
|
||||
exit 255
|
||||
fi
|
||||
- name: Pulling git dir..
|
||||
uses: actions/checkout@v2
|
||||
- name: Processing files..
|
||||
# Make sure that bash is used
|
||||
shell: bash
|
||||
run: |
|
||||
cd "$GITHUB_WORKSPACE"
|
||||
|
||||
# Process files
|
||||
## NOTICE: Do not use for loop to avoid pitfall https://mywiki.wooledge.org/BashPitfalls#pf1
|
||||
git --git-dir="$GITHUB_WORKSPACE/.git" ls-files -z -- '*.sh' | while IFS= read -rd '' file; do
|
||||
printf 'linting shell file %s\n' "$file"
|
||||
shellcheck --external-sources --shell=sh "$file"
|
||||
done
|
Loading…
Reference in New Issue
Block a user