Skip to content

Commit

Permalink
shellcheckLint parallel processing
Browse files Browse the repository at this point in the history
tag: 4.0.0

## shellcheckLint enhancements

Added ability to shellcheck all git files in parallel
using xargs with compatiility with json, json1,
checkstyle formats

## Breaking changes

- removed bin/test binary
- removed bin/runBuildContainer
- removed Docker::runBuildContainer
- added GNU sed to alpine image
- changed runUnitTests hook to rely on a test.sh file
  needed to be present in the target repository.

## Github workflow

- refactored bin/doc
- ensure installRequirements executed
- removed uneeded steps for pre-commit
- unit test generate checkstyle even if error
- cspell - remove global dictionaries config key
  and adapt cspell rules accordingly
- replaced technote-space/workflow-conclusion-action@v3
  by AbsoLouie/[email protected]
  • Loading branch information
fchastanet committed May 8, 2024
1 parent 37ae985 commit 60fe286
Show file tree
Hide file tree
Showing 34 changed files with 532 additions and 5,361 deletions.
1 change: 1 addition & 0 deletions .cspell/bash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ friday
frégate
getopt
getsys
GKHF
gpgsign
gsub
HISTFILE
Expand Down
1 change: 1 addition & 0 deletions .cspell/codespellrc-dic.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
adpat -> adapt
fileTest -> fileTest
tst -> test
8 changes: 8 additions & 0 deletions .cspell/myAwk.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apos
asort
gensub
getline
gsub
substr
tolower
varchar
15 changes: 15 additions & 0 deletions .cspell/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,38 @@ bingitisancestorof
bingitrenamebranch
binmysql
Brzóska
Chastanet
cklmurl
elif
esac
exitcode
fchastanet
fplain
Inlines
inlines
installfile
Jetbrains
lastpipe
libassertsh
libutilssh
loadprofile
mandatorysoftware
manpages
markdownlint
Michał
noargs
openapi
posix
Powerlevel
powerlevel
readlink
realpath
Scrasnups
setupsh
shopt
Slatis
templating
TMPDIR
Tratif
unserialize
untar
Expand Down
5 changes: 5 additions & 0 deletions .cspell/softwares.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,13 @@ MAILHOG
mailserver
mattrose
mbstring
megalinter
minikube
Minikube
mlocate
Mlocate
Msys
MSYS
MULTIPARTS
mypy
mysql
Expand Down Expand Up @@ -129,6 +132,8 @@ resolvconf
runc
scrasnups
screenlock
shellcheck
shellcheckrc
SpacesAftertabs
stylelint
Sume
Expand Down
4 changes: 3 additions & 1 deletion .docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ RUN \
"gettext" \
"git" \
"jq" \
"parallel"
"parallel" \
# GNU sed
"sed"

# Create a default www-data user
COPY createUser.alpine.sh /usr/local/bin/createUser.sh
Expand Down
2 changes: 1 addition & 1 deletion .framework-config
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fi
# describe the functions that will be skipped from being imported
FRAMEWORK_FUNCTIONS_IGNORE_REGEXP="${FRAMEWORK_FUNCTIONS_IGNORE_REGEXP:-^(Namespace::functions|Functions::myFunction|Namespace::requireSomething|IMPORT::dir::file|Acquire::ForceIPv4)$}"
# describe the files that do not contain function to be imported
NON_FRAMEWORK_FILES_REGEXP="${NON_FRAMEWORK_FILES_REGEXP:-(^bin/|^hooks/|^test.sh$|^.github/|^.docker/createUser.|.framework-config|.bats$|/testsData/|^manualTests/|/_.sh$|/ZZZ.sh$|/__all.sh$|^src/_binaries|^src/_includes|^src/batsHeaders.sh$|^src/_standalone)}"
NON_FRAMEWORK_FILES_REGEXP="${NON_FRAMEWORK_FILES_REGEXP:-(^bin/|^hooks/|^test.sh$|^preCommitTest.sh$|^.github/|^.docker/createUser.|.framework-config|.bats$|/testsData/|^manualTests/|/_.sh$|/ZZZ.sh$|/__all.sh$|^src/_binaries|^src/_includes|^src/batsHeaders.sh$|^src/_standalone)}"
# describe the files that are allowed to not have an associated bats file
BATS_FILE_NOT_NEEDED_REGEXP="${BATS_FILE_NOT_NEEDED_REGEXP:-(^bin/|.framework-config|^.docker/|^.github/|.bats$|/testsData/|^manualTests/|/_.sh$|/ZZZ.sh$|/__all.sh$|^src/batsHeaders.sh$|^src/_includes)}"
# describe the files that are allowed to not have a function matching the filename
Expand Down
5 changes: 4 additions & 1 deletion .github/preCommitGeneration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ awk \
print "###############################################################################"
}
''' .pre-commit-config.yaml >.pre-commit-config-github.yaml
sed -i -E '0,/fail_fast: true/s//fail_fast: false/' .pre-commit-config-github.yaml
sed -i -E \
-e '0,/fail_fast: true/s//fail_fast: false/' \
-e 's/stages: \[\] # GITHUB/stages: \[manual\] # GITHUB/' \
.pre-commit-config-github.yaml
2 changes: 1 addition & 1 deletion .github/workflows/docsify-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

- name: Check if doc up to date
run: |
./bin/doc
./bin/doc --ci
- name: Setup Pages
uses: actions/configure-pages@v4
Expand Down
41 changes: 16 additions & 25 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ on: # yamllint disable-line rule:truthy
- "**"
# avoid infinite loop for auto created PRs
- "!update/pre-commit-*"
# only rely on tag push for master branch
- "!master"
tags:
- "*"
workflow_dispatch:

# cancel previous build if several pushes
Expand Down Expand Up @@ -199,26 +195,19 @@ jobs:
echo "branch_name=${GITHUB_REF##*/}"
) >> "${GITHUB_ENV}"
- name: Cache pre-commit
uses: actions/cache@v4
env:
cache_name: pre-commit
hash: ${{hashFiles('**/.pre-commit-config-github.yaml')}}
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-${{ env.cache_name }}-${{ env.hash }}
restore-keys: ${{ runner.os }}-${{ env.cache_name }}-

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9

- name: Install pre-commit
run: pip install pre-commit

- uses: fchastanet/[email protected]

- name: Install requirements
run: |
set -exo pipefail
bin/installRequirements
- name: Run pre-commit
uses: pre-commit/[email protected]
id: preCommit
Expand Down Expand Up @@ -382,13 +371,15 @@ jobs:
- name: run unit tests
id: unitTests
run: |
set -x
set -o errexit
chmod -R 777 logs
set -exo pipefail
bin/installRequirements
chmod 777 logs
docker pull "scrasnups/build:${{env.image_tag}}"
status=0
docker run --rm \
-e KEEP_TEMP_FILES=0 \
-e BATS_FIX_TEST=0 \
Expand All @@ -401,15 +392,15 @@ jobs:
/bash/vendor/bats/bin/bats \
${{env.batsOptions}} \
--formatter junit -o logs -r src 2>&1 |
tee "logs/bats-${{ env.job_tag }}.log" || exit 1
tee "logs/bats-${{ env.job_tag }}.log" || status=$?
awk '/xml version="1.0"/{flag=1} flag; /<\/testsuites>/{flag=0}' \
"logs/bats-${{ env.job_tag }}.log" >"logs/junit-${{ env.job_tag }}.xml"
exit "${status}"
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
# https://stackoverflow.com/a/70549615/3045926
if: ${{ always() && steps.unitTests.conclusion == 'success' }}
if: ${{ always() }}
with:
token: ${{ github.token }}
check_name: JUnit ${{ env.image_tag }}
Expand All @@ -419,7 +410,7 @@ jobs:
report_paths: "logs/**.xml"

- name: Upload Test Results
if: ${{ always() && steps.unitTests.conclusion == 'success' }}
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: Test Results ${{ env.image_tag }}
Expand All @@ -443,7 +434,7 @@ jobs:
steps:
# run this action to get the workflow conclusion
# You can get the conclusion via env (env.WORKFLOW_CONCLUSION)
- uses: technote-space/workflow-conclusion-action@v3
- uses: AbsoLouie/workflow-conclusion-[email protected]

- uses: akatov/commit-status-updater@a9e988ec5454692ff7745a509452422a35172ad6
with:
Expand Down
7 changes: 3 additions & 4 deletions .pre-commit-config-github.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ repos:
)
- repo: https://github.com/fchastanet/bash-tools-framework
rev: 3.2.0
rev: 3.2.1
hooks:
- id: fixShebangExecutionBit
- id: awkLint
Expand Down Expand Up @@ -214,8 +214,7 @@ repos:
name: build doc files for github actions
language: script
entry: bin/doc
args: [--verbose]
args: [--verbose, --ci]
pass_filenames: false
require_serial: true
always_run: true
stages: [manual]
stages: [manual] # GITHUB
7 changes: 3 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ repos:
)
- repo: https://github.com/fchastanet/bash-tools-framework
rev: 3.2.0
rev: 3.2.1
hooks:
- id: fixShebangExecutionBit
- id: awkLint
Expand Down Expand Up @@ -209,8 +209,7 @@ repos:
name: build doc files for github actions
language: script
entry: bin/doc
args: [--verbose]
args: [--verbose, --ci]
pass_filenames: false
require_serial: true
always_run: true
stages: [manual]
stages: [] # GITHUB
4 changes: 2 additions & 2 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
name: Run unit tests
description: run unit test using bats in docker isolated environment
language: script
entry: bin/test
args: [-r, src, -j, "30"]
entry: preCommitTest.sh
args: ["scrasnups/build:bash-tools-ubuntu-5.3", -r, src, -j, "30"]
pass_filenames: false
always_run: true
require_serial: true
Expand Down
2 changes: 1 addition & 1 deletion .shellcheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ enable=quote-safe-variables
enable=require-double-brackets
source-path=SCRIPTDIR
# special property used by shellcheckLint
exclude=(^bin/bash-tpl$|\.bats$|\.tpl$|/testsData/)
exclude=(^bin/|\.bats$|\.tpl$|src/batsHeaders.sh$|/testsData/)
Loading

0 comments on commit 60fe286

Please sign in to comment.