Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 5 additions & 23 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ jobs:
uses: ./.github/actions/install_runner
- run: source venv/bin/activate
shell: bash
- name: Black, pylint, tailing whitespaces, and yaml checks
- name: Install node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 20
- name: Black, pylint, tailing whitespaces, yaml, shellcheck, and language-specific checks
shell: bash
run: ./format.sh --check
- if: ${{ failure() }}
Expand All @@ -24,25 +28,3 @@ jobs:
exit 1

'
- name: 'Install shellcheck'
shell: bash
run: sudo apt-get install -y shellcheck
- name: 'Run shellcheck'
shell: bash
run: ./utils/scripts/shellcheck.sh
- name: Install node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 20
- name: 'Run nodejs express lint'
shell: bash
working-directory: ./utils/build/docker/nodejs/express
run: |
npm install
npm run lint
- name: 'Run nodejs fastify lint'
shell: bash
working-directory: ./utils/build/docker/nodejs/fastify
run: |
npm install
npm run lint
1 change: 1 addition & 0 deletions .shellcheck
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ TODO=(
utils/interfaces/schemas/serve.sh
build.sh
format.sh
*node_modules*
)
35 changes: 24 additions & 11 deletions format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ if ! mypy --config pyproject.toml; then
exit 1
fi

echo "Running ruff checks..."
if ! which ruff > /dev/null; then
echo "ruff is not installed, installing it (ETA 5s)"
./build.sh -i runner > /dev/null
fi

echo "Running ruff formatter..."
if [ "$COMMAND" == "fix" ]; then
ruff format
Expand Down Expand Up @@ -133,11 +127,6 @@ else
fi

echo "Running yamllint checks..."
if ! which ./venv/bin/yamllint > /dev/null; then
echo "yamllint is not installed, installing it (ETA 60s)"
./build.sh -i runner > /dev/null
fi

if ! ./venv/bin/yamllint -s manifests/; then
echo "yamllint checks failed. Please fix the errors above. 💥 💔 💥"
exit 1
Expand All @@ -149,5 +138,29 @@ if ! python ./manifests/parser/core.py; then
exit 1
fi

echo "Running shellcheck checks..."
if ! ./utils/scripts/shellcheck.sh; then
echo "shellcheck checks failed. Please fix the errors above. 💥 💔 💥"
exit 1
fi

echo "Running language-specific linters..."
# This will not run if npm is not installed as written and there is no "install" step today
# TODO: Install node as part of this script
if which npm > /dev/null; then
echo "Running Node.js linters"

# currently only fastify requires linting
# this can be added later
nodejs_dirs=("express" "fastify")

for dir in "${nodejs_dirs[@]}"; do
if ! NODE_NO_WARNINGS=1 npm --prefix ./utils/build/docker/nodejs/"$dir" install --silent && npm --prefix ./utils/build/docker/nodejs/"$dir" run --silent lint; then
echo "$dir linter failed. Please fix the errors above. 💥 💔 💥"
exit 1
fi
done
fi


echo "All good, the system-tests CI will be happy! ✨ 🍰 ✨"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ ruff==0.8.1
scp==0.14.5
semantic-version==2.10.0
setuptools==75.8.0
shellcheck-py==0.11.0.1
types-aiofiles==24.1.0.20241221
types-protobuf==5.29.1.20241207
types-python-dateutil==2.9.0.20241206
Expand Down
31 changes: 31 additions & 0 deletions utils/build/docker/nodejs/express/package-lock.json
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This came from running npm install; npm ci would fail otherwise

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions utils/scripts/shellcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function has() {
shift

local e
for e; do [[ "${e}" == "${needle}" ]] && return 0; done

# shellcheck disable=SC2053 # explicitly allow glob matching
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed glob matching to ignore *node_modules*, otherwise this fails locally if you've installed any of them before

for e in "$@"; do [[ $needle == $e ]] && return 0; done
return 1
}

Expand Down Expand Up @@ -43,7 +43,7 @@ function lint() {
files+=("$f")
done < <( find utils -name '*.sh'; ls -1 -- *.sh )

shellcheck "${files[@]}"
./venv/bin/shellcheck "${files[@]}"
}

function root() {
Expand Down
Loading